param: use the generated parameter table.
[Samba.git] / selftest / tests / test_samba.py
blob4bcfcba9e13e5441632e874d20eee5055a54ec1c
1 # test_run.py -- Tests for selftest.target.samba
2 # Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 3
7 # of the License or (at your option) any later version of
8 # the License.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # MA 02110-1301, USA.
20 """Tests for selftest.target.samba."""
22 from cStringIO import StringIO
24 from samba.tests import TestCase
26 from selftest.target.samba import (
27 bindir_path,
28 get_interface,
29 mk_realms_stanza,
30 write_krb5_conf,
34 class BinDirPathTests(TestCase):
36 def test_mapping(self):
37 self.assertEquals("exe",
38 bindir_path("/some/path", "exe"))
39 self.assertEquals("/bin/exe",
40 bindir_path("/bin", "/bin/exe"))
42 def test_no_mapping(self):
43 self.assertEqual("exe", bindir_path("/some/path", "exe"))
44 self.assertEqual("/bin/ls",
45 bindir_path("/bin", "ls"))
48 class MkRealmsStanzaTests(TestCase):
50 def test_basic(self):
51 self.assertEqual(
52 mk_realms_stanza("rijk", "dnsnaam", "domein", "ipv4_kdc"),
53 '''\
54 rijk = {
55 kdc = ipv4_kdc:88
56 admin_server = ipv4_kdc:88
57 default_domain = dnsnaam
59 dnsnaam = {
60 kdc = ipv4_kdc:88
61 admin_server = ipv4_kdc:88
62 default_domain = dnsnaam
64 domein = {
65 kdc = ipv4_kdc:88
66 admin_server = ipv4_kdc:88
67 default_domain = dnsnaam
70 ''')
73 class WriteKrb5ConfTests(TestCase):
75 def test_simple(self):
76 f = StringIO()
77 write_krb5_conf(f, "rijk", "dnsnaam", "domein", "kdc_ipv4")
78 self.assertEquals('''\
79 #Generated krb5.conf for rijk
81 [libdefaults]
82 \tdefault_realm = rijk
83 \tdns_lookup_realm = false
84 \tdns_lookup_kdc = false
85 \tticket_lifetime = 24h
86 \tforwardable = yes
87 \tallow_weak_crypto = yes
89 [realms]
90 rijk = {
91 kdc = kdc_ipv4:88
92 admin_server = kdc_ipv4:88
93 default_domain = dnsnaam
95 dnsnaam = {
96 kdc = kdc_ipv4:88
97 admin_server = kdc_ipv4:88
98 default_domain = dnsnaam
100 domein = {
101 kdc = kdc_ipv4:88
102 admin_server = kdc_ipv4:88
103 default_domain = dnsnaam
106 ''', f.getvalue())
109 class GetInterfaceTests(TestCase):
111 def test_get_interface(self):
112 self.assertEquals(21, get_interface("localdc"))
113 self.assertEquals(4, get_interface("localshare4"))
115 def test_unknown(self):
116 self.assertRaises(KeyError, get_interface, "unknown")