s4/tests: Implement a blackbox test for 'samba-tool drs' command
authorKamen Mazdrashki <kamenim@samba.org>
Wed, 9 Feb 2011 01:40:52 +0000 (03:40 +0200)
committerKamen Mazdrashki <kamenim@samba.org>
Wed, 9 Feb 2011 10:45:30 +0000 (11:45 +0100)
Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Wed Feb  9 11:45:30 CET 2011 on sn-devel-104

source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py [new file with mode: 0644]
source4/selftest/tests.py

diff --git a/source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py b/source4/scripting/python/samba/tests/blackbox/samba_tool_drs.py
new file mode 100644 (file)
index 0000000..51274cc
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+# Blackbox tests for "samba-tool drs" command
+# Copyright (C) Kamen Mazdrashki <kamenim@samba.org> 2011
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""Blackbox tests for samba-tool drs."""
+
+import os
+import samba.tests
+
+
+class SambaToolDrsTests(samba.tests.BlackboxTestCase):
+    """Blackbox test case for samba-tool drs."""
+
+    def setUp(self):
+        super(SambaToolDrsTests, self).setUp()
+
+        self.dc1 = samba.tests.env_get_var_value("DC1")
+        self.dc2 = samba.tests.env_get_var_value("DC2")
+
+        creds = self.get_credentials()
+        self.cmdline_creds = "-U%s/%s%%%s" % (creds.get_domain(),
+                                              creds.get_username(), creds.get_password())
+
+    def _get_rootDSE(self, dc):
+        samdb = samba.tests.connect_samdb(dc, lp=self.get_loadparm(),
+                                          credentials=self.get_credentials(),
+                                          ldap_only=True)
+        return samdb.search(base="", scope=samba.tests.ldb.SCOPE_BASE)[0]
+
+    def test_samba_tool_bind(self):
+        """Tests 'samba-tool drs bind' command
+           Output should be like:
+               Extensions supported:
+                 <list-of-supported-extensions>
+               Site GUID: <GUID>
+               Repl epoch: 0"""
+        out = self.check_output("samba-tool drs bind %s %s" % (self.dc1,
+                                                               self.cmdline_creds))
+        self.assertTrue("Site GUID:" in out)
+        self.assertTrue("Repl epoch:" in out)
+
+    def test_samba_tool_kcc(self):
+        """Tests 'samba-tool drs kcc' command
+           Output should be like 'Consistency check on <DC> successful.'"""
+        out = self.check_output("samba-tool drs kcc %s %s" % (self.dc1,
+                                                              self.cmdline_creds))
+        self.assertTrue("Consistency check on" in out)
+        self.assertTrue("successful" in out)
+
+    def test_samba_tool_showrepl(self):
+        """Tests 'samba-tool drs showrepl' command
+           Output should be like:
+               <site-name>/<domain-name>
+               DSA Options: <hex-options>
+               DSA object GUID: <DSA-object-GUID>
+               DSA invocationId: <DSA-invocationId>
+               <Inbound-connections-list>
+               <Outbound-connections-list>
+               <KCC-objects>
+               ...
+            TODO: Perhaps we should check at least for
+                  DSA's objectGUDI and invocationId"""
+        out = self.check_output("samba-tool drs showrepl %s %s" % (self.dc1,
+                                                                   self.cmdline_creds))
+        self.assertTrue("DSA Options:" in out)
+        self.assertTrue("DSA object GUID:" in out)
+        self.assertTrue("DSA invocationId:" in out)
+
+    def test_samba_tool_options(self):
+        """Tests 'samba-tool drs options' command
+           Output should be like 'Current DSA options: IS_GC <OTHER_FLAGS>'"""
+        out = self.check_output("samba-tool drs options %s %s" % (self.dc1,
+                                                                  self.cmdline_creds))
+        self.assertTrue("Current DSA options:" in out)
+
+    def test_samba_tool_replicate(self):
+        """Tests 'samba-tool drs replicate' command
+           Output should be like 'Replicate from <DC-SRC> to <DC-DEST> was successful.'"""
+        nc_name = self._get_rootDSE(self.dc1)["defaultNamingContext"]
+        out = self.check_output("samba-tool drs replicate %s %s %s %s" % (self.dc1,
+                                                                          self.dc2,
+                                                                          nc_name,
+                                                                          self.cmdline_creds))
+        self.assertTrue("Replicate from" in out)
+        self.assertTrue("was successful" in out)
index 33524e63a79f92a657c98f45b2c4d22d0d51b125..aa7ee5a5e88e74255b5575d2f3b5d5298b0c868d 100755 (executable)
@@ -536,6 +536,7 @@ plantestsuite("samba4.blackbox.spn.py(dc:local)", "dc:local", ["PYTHON=%s" % pyt
 plantestsuite("samba4.ldap.bind(dc)", "dc", [python, os.path.join(samba4srcdir, "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"'])
 
 # DRS python tests
+plansambapythontestsuite("samba4.blackbox.samba-tool.drs(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'scripting/python'), "samba.tests.blackbox.samba_tool_drs", environ={'DC1': '$DC_SERVER', 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
 plansambapythontestsuite("samba4.drs.delete_object.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "delete_object", environ={'DC1': '$DC_SERVER', 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
 plansambapythontestsuite("samba4.drs.fsmo.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "fsmo", environ={'DC1': "$DC_SERVER", 'DC2': "$VAMPIRE_DC_SERVER"}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])
 plansambapythontestsuite("samba4.drs.repl_schema.python(vampire_dc)", "vampire_dc", os.path.join(samba4srcdir, 'torture/drs/python'), "repl_schema", environ={'DC1': "$DC_SERVER", 'DC2': '$VAMPIRE_DC_SERVER'}, extra_args=['-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD'])