summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-03-23 23:46:19 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-03-24 03:19:31 +0100
commit289632f85eefe987b429f6ca8500b3a17e42ebbb (patch)
tree2d98d41fd42ea42194f64ce1d7a2e752e570380a
parentf18d9e147d4a242cdfb31a816d91d277b99badae (diff)
downloadsamba-289632f85eefe987b429f6ca8500b3a17e42ebbb.tar.gz
selftest.py: Add mk_realms_stanza function.
-rw-r--r--selftest/target/samba.py32
-rw-r--r--selftest/tests/test_samba.py34
2 files changed, 63 insertions, 3 deletions
diff --git a/selftest/target/samba.py b/selftest/target/samba.py
index 5e652a35284..025dbaeed81 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 d3da9305530..60f6f7fca00 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
+ }
+
+''')