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
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,
20 """Tests for selftest.target.samba."""
22 from cStringIO
import StringIO
24 from samba
.tests
import TestCase
26 from selftest
.target
.samba
import (
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
):
52 mk_realms_stanza("rijk", "dnsnaam", "domein", "ipv4_kdc"),
56 admin_server = ipv4_kdc:88
57 default_domain = dnsnaam
61 admin_server = ipv4_kdc:88
62 default_domain = dnsnaam
66 admin_server = ipv4_kdc:88
67 default_domain = dnsnaam
73 class WriteKrb5ConfTests(TestCase
):
75 def test_simple(self
):
77 write_krb5_conf(f
, "rijk", "dnsnaam", "domein", "kdc_ipv4")
78 self
.assertEquals('''\
79 #Generated krb5.conf for rijk
82 \tdefault_realm = rijk
83 \tdns_lookup_realm = false
84 \tdns_lookup_kdc = false
85 \tticket_lifetime = 24h
87 \tallow_weak_crypto = yes
92 admin_server = kdc_ipv4:88
93 default_domain = dnsnaam
97 admin_server = kdc_ipv4:88
98 default_domain = dnsnaam
102 admin_server = kdc_ipv4:88
103 default_domain = dnsnaam
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")