diff options
Diffstat (limited to 'selftest')
-rw-r--r-- | selftest/target/samba.py | 32 | ||||
-rw-r--r-- | selftest/tests/test_samba.py | 34 |
2 files changed, 63 insertions, 3 deletions
diff --git a/selftest/target/samba.py b/selftest/target/samba.py index 5e652a3528..025dbaeed8 100644 --- a/selftest/target/samba.py +++ b/selftest/target/samba.py @@ -22,3 +22,35 @@ def bindir_path(binary_mapping, bindir, path): if os.path.isfile(valpath): return valpath return path + + +def mk_realms_stanza(realm, dnsname, domain, kdc_ipv4): + """Create a realms stanza for use in a krb5.conf file. + + :param realm: Real name + :param dnsname: DNS name matching the realm + :param domain: Domain name + :param kdc_ipv4: IPv4 address of the KDC + :return: String with stanza + """ + return """\ + %(realm)s = { + kdc = %(kdc_ipv4)s:88 + admin_server = %(kdc_ipv4)s:88 + default_domain = %(dnsname)s + } + %(dnsname)s = { + kdc = %(kdc_ipv4)s:88 + admin_server = %(kdc_ipv4)s:88 + default_domain = %(dnsname)s + } + %(domain)s = { + kdc = %(kdc_ipv4)s:88 + admin_server = %(kdc_ipv4)s:88 + default_domain = %(dnsname)s + } + +""" % { + "kdc_ipv4": kdc_ipv4, "dnsname": dnsname, "realm": realm, "domain": domain} + + diff --git a/selftest/tests/test_samba.py b/selftest/tests/test_samba.py index d3da930553..60f6f7fca0 100644 --- a/selftest/tests/test_samba.py +++ b/selftest/tests/test_samba.py @@ -21,7 +21,10 @@ from selftest.tests import TestCase -from selftest.target.samba import bindir_path +from selftest.target.samba import ( + bindir_path, + mk_realms_stanza, + ) class BinDirPathTests(TestCase): @@ -33,6 +36,31 @@ class BinDirPathTests(TestCase): bindir_path({"exe": "ls"}, "/bin", "exe")) def test_no_mapping(self): - self.assertEquals("exe", bindir_path({}, "/some/path", "exe")) - self.assertEquals("/bin/ls", + self.assertEqual("exe", bindir_path({}, "/some/path", "exe")) + self.assertEqual("/bin/ls", bindir_path({}, "/bin", "ls")) + + +class MkRealmsStanzaTests(TestCase): + + def test_basic(self): + self.assertEqual( + mk_realms_stanza("rijk", "dnsnaam", "domein", "ipv4_kdc"), + '''\ + rijk = { + kdc = ipv4_kdc:88 + admin_server = ipv4_kdc:88 + default_domain = dnsnaam + } + dnsnaam = { + kdc = ipv4_kdc:88 + admin_server = ipv4_kdc:88 + default_domain = dnsnaam + } + domein = { + kdc = ipv4_kdc:88 + admin_server = ipv4_kdc:88 + default_domain = dnsnaam + } + +''') |