[SCM] Samba Shared Repository - branch master updated

Kamen Mazdrashki kamenim at samba.org
Sun Feb 20 15:04:02 MST 2011


The branch, master has been updated
       via  1273d50 s4/drs-tests:Blackbox test to verify DsReplicaSync handling
       via  bfb0adf s4/samba.tests: Raise BlackboxProcessError exception in case check_output method fails
       via  348295b s4/samba.tests: Extend CalledProcessError class to store STDOUT and STDERR for a failed rocess call
       via  adfb618 s4/drs-tests: Allow _net_drs_replicate to force replication and return output from command execution
       via  288e20c s4/drs-tests: Split samba-tool command line generation into separate method
       via  75856d5 s4/drs-tests: Inherit DrsReplSchemaTestCase from DrsBaseTestCase
       via  60bb40c s4/drs-tests: Inherit DrsFsmoTestCase from DrsBaseTestCase
       via  fcd4aa8 s4/drs-tests: Inherit DrsDeleteObjectTestCase from DrsBaseTestCase
       via  e210391 s4/drs-tests: Add a base class to hold common functionality for all DRS python tests
      from  367b35b s3: Fix pdb_ads_enum_aliasmem for empty aliases

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1273d504f2abb6b87c45bf664b56c1902ba99219
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Sun Feb 20 04:21:32 2011 +0200

    s4/drs-tests:Blackbox test to verify DsReplicaSync handling
    
    DsReplicaSync is indirectly called using 'samba-tool drs options' command
    to enable/disable replication and 'samba-tool drs replicate' command
    to trigger inbound replication cycle
    
    Autobuild-User: Kamen Mazdrashki <kamenim at samba.org>
    Autobuild-Date: Sun Feb 20 23:03:03 CET 2011 on sn-devel-104

commit bfb0adf0b450452e3daf0b60269768b77c6291c3
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Sun Feb 20 04:17:25 2011 +0200

    s4/samba.tests: Raise BlackboxProcessError exception in case check_output method fails
    
    This way the caller gets the chance to receive STDOUT and STDERR for
    a failed process.
    We may use this info to check if a process has failed properly,
    e.g. with expected output

commit 348295bf8ac5f39e5be23c0a6adb8c31e64766a2
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Sun Feb 20 04:15:08 2011 +0200

    s4/samba.tests: Extend CalledProcessError class to store STDOUT and STDERR for a failed rocess call

commit adfb618ef5f7307bb5cf68185c6055375196db3a
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 04:27:19 2011 +0200

    s4/drs-tests: Allow _net_drs_replicate to force replication and return output from command execution

commit 288e20cfb7c7e39bfd07626c77a9a0eaa8955bcf
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 04:09:45 2011 +0200

    s4/drs-tests: Split samba-tool command line generation into separate method
    
    so we can use to exec samba-tool passing different commands

commit 75856d53cb0d733c4df3a58708eb9f272260c176
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 03:25:20 2011 +0200

    s4/drs-tests: Inherit DrsReplSchemaTestCase from DrsBaseTestCase
    
    and remove duplicated functionality

commit 60bb40cd25bc8fd037f6a5e29e6fa3d62a88533e
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 03:25:02 2011 +0200

    s4/drs-tests: Inherit DrsFsmoTestCase from DrsBaseTestCase
    
    and remove duplicated functionality

commit fcd4aa84edb79d40e3616918b710b8a3a277f4a8
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 03:24:08 2011 +0200

    s4/drs-tests: Inherit DrsDeleteObjectTestCase from DrsBaseTestCase
    
    and remove duplicated functionality

commit e21039110cfa6303f2f7de14918d4492298ad996
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Feb 18 02:54:50 2011 +0200

    s4/drs-tests: Add a base class to hold common functionality for all DRS python tests

-----------------------------------------------------------------------

Summary of changes:
 source4/scripting/python/samba/tests/__init__.py |   17 +++-
 source4/torture/drs/python/delete_object.py      |   46 +---------
 source4/torture/drs/python/drs_base.py           |  111 ++++++++++++++++++++++
 source4/torture/drs/python/fsmo.py               |   37 +-------
 source4/torture/drs/python/repl_schema.py        |   47 +---------
 source4/torture/drs/python/replica_sync.py       |   91 ++++++++++++++++++
 6 files changed, 223 insertions(+), 126 deletions(-)
 create mode 100644 source4/torture/drs/python/drs_base.py
 create mode 100644 source4/torture/drs/python/replica_sync.py


Changeset truncated at 500 lines:

diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index d6b962c..58e4130 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -121,6 +121,19 @@ class ValidNetbiosNameTests(TestCase):
         self.assertFalse(samba.valid_netbios_name("*BLA"))
 
 
+class BlackboxProcessError(subprocess.CalledProcessError):
+    """This exception is raised when a process run by check_output() returns
+    a non-zero exit status. Exception instance should contain
+    the exact exit code (S.returncode), command line (S.cmd),
+    process output (S.stdout) and process error stream (S.stderr)"""
+    def __init__(self, returncode, cmd, stdout, stderr):
+        super(BlackboxProcessError, self).__init__(returncode, cmd)
+        self.stdout = stdout
+        self.stderr = stderr
+    def __str__(self):
+        return "Command '%s'; exit status %d; stdout: '%s'; stderr: '%s'" % (self.cmd, self.returncode,
+                                                                             self.stdout, self.stderr)
+
 class BlackboxTestCase(TestCase):
     """Base test case for blackbox tests."""
 
@@ -138,10 +151,10 @@ class BlackboxTestCase(TestCase):
 
     def check_output(self, line):
         line = self._make_cmdline(line)
-        p = subprocess.Popen(line, stdout=subprocess.PIPE, shell=True, close_fds=True)
+        p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
         retcode = p.wait()
         if retcode:
-            raise subprocess.CalledProcessError(retcode, line)
+            raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read())
         return p.stdout.read()
 
 def connect_samdb(samdb_url, lp=None, session_info=None, credentials=None,
diff --git a/source4/torture/drs/python/delete_object.py b/source4/torture/drs/python/delete_object.py
index c52060f..b652377 100644
--- a/source4/torture/drs/python/delete_object.py
+++ b/source4/torture/drs/python/delete_object.py
@@ -37,46 +37,17 @@ from ldb import (
     SCOPE_SUBTREE
     )
 
-import samba.tests
+import drs_base
 
 
-class DrsDeleteObjectTestCase(samba.tests.TestCase):
+class DrsDeleteObjectTestCase(drs_base.DrsBaseTestCase):
 
     def setUp(self):
         super(DrsDeleteObjectTestCase, self).setUp()
 
-        # connect to DCs
-        url_dc = samba.tests.env_get_var_value("DC1")
-        (self.ldb_dc1, self.info_dc1) = samba.tests.connect_samdb_ex(url_dc,
-                                                                     ldap_only=True)
-        url_dc = samba.tests.env_get_var_value("DC2")
-        (self.ldb_dc2, self.info_dc2) = samba.tests.connect_samdb_ex(url_dc,
-                                                                     ldap_only=True)
-
-        # cache some of RootDSE props
-        self.schema_dn = self.info_dc1["schemaNamingContext"][0]
-        self.domain_dn = self.info_dc1["defaultNamingContext"][0]
-        self.config_dn = self.info_dc1["configurationNamingContext"][0]
-        self.forest_level = int(self.info_dc1["forestFunctionality"][0])
-
-        # we will need DCs DNS names for 'samba-tool drs' command
-        self.dnsname_dc1 = self.info_dc1["dnsHostName"][0]
-        self.dnsname_dc2 = self.info_dc2["dnsHostName"][0]
-
     def tearDown(self):
         super(DrsDeleteObjectTestCase, self).tearDown()
 
-    def _GUID_string(self, guid):
-        return self.ldb_dc1.schema_format_value("objectGUID", guid)
-
-    def _deleted_objects_dn(self, sam_ldb):
-        wkdn = "<WKGUID=18E2EA80684F11D2B9AA00C04F79F805,%s>" % self.domain_dn
-        res = sam_ldb.search(base=wkdn,
-                             scope=SCOPE_BASE,
-                             controls=["show_deleted:1"])
-        self.assertEquals(len(res), 1)
-        return str(res[0]["dn"])
-
     def _make_username(self):
         return "DrsDelObjUser_" + time.strftime("%s", time.gmtime())
 
@@ -107,19 +78,6 @@ class DrsDeleteObjectTestCase(samba.tests.TestCase):
             self.assertEquals(user_orig["dn"], user_cur["dn"])
             self.assertTrue(dodn not in str(user_cur["dn"]))
 
-    def _net_drs_replicate(self, DC, fromDC):
-        # find out where is net command
-        samba_tool_cmd = os.path.abspath("./bin/samba-tool")
-        # make command line credentials string
-        creds = self.get_credentials()
-        cmd_line_auth = "-U%s/%s%%%s" % (creds.get_domain(),
-                                         creds.get_username(), creds.get_password())
-        # bin/samba-tool drs replicate <Dest_DC_NAME> <Src_DC_NAME> <Naming Context>
-        cmd_line = "%s drs replicate %s %s %s %s" % (samba_tool_cmd, DC, fromDC,
-                                                     self.domain_dn, cmd_line_auth)
-        ret = os.system(cmd_line)
-        self.assertEquals(ret, 0, "Replicating %s from %s has failed!" % (DC, fromDC))
-
     def test_NetReplicateCmd(self):
         """Triggers replication from DC1 to DC2
            and vice versa so both DCs are synchronized
diff --git a/source4/torture/drs/python/drs_base.py b/source4/torture/drs/python/drs_base.py
new file mode 100644
index 0000000..56d1ebe
--- /dev/null
+++ b/source4/torture/drs/python/drs_base.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Unix SMB/CIFS implementation.
+# Copyright (C) Kamen Mazdrashki <kamenim at 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/>.
+#
+
+
+import sys
+import time
+import os
+
+sys.path.insert(0, "bin/python")
+import samba
+samba.ensure_external_module("testtools", "testtools")
+samba.ensure_external_module("subunit", "subunit/python")
+
+from ldb import (
+    SCOPE_BASE,
+    Message,
+    FLAG_MOD_REPLACE,
+    )
+
+import samba.tests
+
+
+class DrsBaseTestCase(samba.tests.BlackboxTestCase):
+    """Base class implementation for all DRS python tests.
+       It is intended to provide common initialization and
+       and functionality used by all DRS tests in drs/python
+       test package. For instance, DC1 and DC2 are always used
+       to pass URLs for DCs to test against"""
+
+    def setUp(self):
+        super(DrsBaseTestCase, self).setUp()
+
+        # connect to DCs
+        url_dc = samba.tests.env_get_var_value("DC1")
+        (self.ldb_dc1, self.info_dc1) = samba.tests.connect_samdb_ex(url_dc,
+                                                                     ldap_only=True)
+        url_dc = samba.tests.env_get_var_value("DC2")
+        (self.ldb_dc2, self.info_dc2) = samba.tests.connect_samdb_ex(url_dc,
+                                                                     ldap_only=True)
+
+        # cache some of RootDSE props
+        self.schema_dn = self.info_dc1["schemaNamingContext"][0]
+        self.domain_dn = self.info_dc1["defaultNamingContext"][0]
+        self.config_dn = self.info_dc1["configurationNamingContext"][0]
+        self.forest_level = int(self.info_dc1["forestFunctionality"][0])
+
+        # we will need DCs DNS names for 'samba-tool drs' command
+        self.dnsname_dc1 = self.info_dc1["dnsHostName"][0]
+        self.dnsname_dc2 = self.info_dc2["dnsHostName"][0]
+
+    def tearDown(self):
+        super(DrsBaseTestCase, self).tearDown()
+
+    def _GUID_string(self, guid):
+        return self.ldb_dc1.schema_format_value("objectGUID", guid)
+
+    def _ldap_schemaUpdateNow(self, sam_db):
+        rec = {"dn": "",
+               "schemaUpdateNow": "1"}
+        m = Message.from_dict(sam_db, rec, FLAG_MOD_REPLACE)
+        sam_db.modify(m)
+
+    def _deleted_objects_dn(self, sam_ldb):
+        wkdn = "<WKGUID=18E2EA80684F11D2B9AA00C04F79F805,%s>" % self.domain_dn
+        res = sam_ldb.search(base=wkdn,
+                             scope=SCOPE_BASE,
+                             controls=["show_deleted:1"])
+        self.assertEquals(len(res), 1)
+        return str(res[0]["dn"])
+
+    def _make_obj_name(self, prefix):
+        return prefix + time.strftime("%s", time.gmtime())
+
+    def _samba_tool_cmdline(self, drs_command):
+        # find out where is net command
+        samba_tool_cmd = os.path.abspath("./bin/samba-tool")
+        # make command line credentials string
+        creds = self.get_credentials()
+        cmdline_auth = "-U%s/%s%%%s" % (creds.get_domain(),
+                                        creds.get_username(), creds.get_password())
+        # bin/samba-tool drs <drs_command> <cmdline_auth>
+        return "%s drs %s %s" % (samba_tool_cmd, drs_command, cmdline_auth)
+
+    def _net_drs_replicate(self, DC, fromDC, nc_dn=None, forced=True):
+        if nc_dn is None:
+            nc_dn = self.domain_dn
+        # make base command line
+        samba_tool_cmdline = self._samba_tool_cmdline("replicate")
+        if forced:
+            samba_tool_cmdline += " --sync-forced"
+        # bin/samba-tool drs replicate <Dest_DC_NAME> <Src_DC_NAME> <Naming Context>
+        cmd_line = "%s %s %s %s" % (samba_tool_cmdline, DC, fromDC, nc_dn)
+        return self.check_output(cmd_line)
+
diff --git a/source4/torture/drs/python/fsmo.py b/source4/torture/drs/python/fsmo.py
index d7b3c16..c137c7e 100644
--- a/source4/torture/drs/python/fsmo.py
+++ b/source4/torture/drs/python/fsmo.py
@@ -33,16 +33,9 @@ sys.path.insert(0, "bin/python")
 
 from ldb import SCOPE_BASE
 
-import samba.tests
+import drs_base
 
-class DrsFsmoTestCase(samba.tests.TestCase):
-
-    # RootDSE msg for DC1
-    info_dc1 = None
-    ldb_dc1 = None
-    # RootDSE msg for DC1
-    info_dc2 = None
-    ldb_dc2 = None
+class DrsFsmoTestCase(drs_base.DrsBaseTestCase):
 
     def setUp(self):
         super(DrsFsmoTestCase, self).setUp()
@@ -50,40 +43,14 @@ class DrsFsmoTestCase(samba.tests.TestCase):
         # we have to wait for the replication before we make the check
         self.fsmo_wait_max_time = 20
         self.fsmo_wait_sleep_time = 0.2
-        # connect to DCs singleton
-        if self.ldb_dc1 is None:
-            DrsFsmoTestCase.dc1 = samba.tests.env_get_var_value("DC1")
-            DrsFsmoTestCase.ldb_dc1 = samba.tests.connect_samdb(self.dc1, ldap_only=True)
-        if self.ldb_dc2 is None:
-            DrsFsmoTestCase.dc2 = samba.tests.env_get_var_value("DC2")
-            DrsFsmoTestCase.ldb_dc2 = samba.tests.connect_samdb(self.dc2, ldap_only=True)
-
-        # fetch rootDSEs
-        if self.info_dc1 is None:
-            ldb = self.ldb_dc1
-            res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
-            self.assertEquals(len(res), 1)
-            DrsFsmoTestCase.info_dc1 = res[0]
-        if self.info_dc2 is None:
-            ldb = self.ldb_dc2
-            res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
-            self.assertEquals(len(res), 1)
-            DrsFsmoTestCase.info_dc2 = res[0]
 
         # cache some of RootDSE props
-        self.schema_dn = self.info_dc1["schemaNamingContext"][0]
-        self.domain_dn = self.info_dc1["defaultNamingContext"][0]
-        self.config_dn = self.info_dc1["configurationNamingContext"][0]
         self.dsServiceName_dc1 = self.info_dc1["dsServiceName"][0]
         self.dsServiceName_dc2 = self.info_dc2["dsServiceName"][0]
         self.infrastructure_dn = "CN=Infrastructure," + self.domain_dn
         self.naming_dn = "CN=Partitions," + self.config_dn
         self.rid_dn = "CN=RID Manager$,CN=System," + self.domain_dn
 
-        # we will need DCs DNS names for 'net fsmo' command
-        self.dnsname_dc1 = self.info_dc1["dnsHostName"][0]
-        self.dnsname_dc2 = self.info_dc2["dnsHostName"][0]
-
     def tearDown(self):
         super(DrsFsmoTestCase, self).tearDown()
 
diff --git a/source4/torture/drs/python/repl_schema.py b/source4/torture/drs/python/repl_schema.py
index db14c37..4a8a5be 100644
--- a/source4/torture/drs/python/repl_schema.py
+++ b/source4/torture/drs/python/repl_schema.py
@@ -46,10 +46,10 @@ from ldb import (
     FLAG_MOD_REPLACE,
     )
 
-import samba.tests
+import drs_base
 
 
-class DrsReplSchemaTestCase(samba.tests.TestCase):
+class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase):
 
     # prefix for all objects created
     obj_prefix = None
@@ -59,57 +59,14 @@ class DrsReplSchemaTestCase(samba.tests.TestCase):
     def setUp(self):
         super(DrsReplSchemaTestCase, self).setUp()
 
-        # connect to DCs
-        url_dc = samba.tests.env_get_var_value("DC1")
-        (self.ldb_dc1, self.info_dc1) = samba.tests.connect_samdb_ex(url_dc, 
-                                                                     ldap_only=True)
-        url_dc = samba.tests.env_get_var_value("DC2")
-        (self.ldb_dc2, self.info_dc2) = samba.tests.connect_samdb_ex(url_dc, 
-                                                                     ldap_only=True)
-
         # initialize objects prefix if not done yet
         if self.obj_prefix is None:
             t = time.strftime("%s", time.gmtime())
             DrsReplSchemaTestCase.obj_prefix = "DrsReplSchema-%s" % t
 
-        # cache some of RootDSE props
-        self.schema_dn = self.info_dc1["schemaNamingContext"][0]
-        self.domain_dn = self.info_dc1["defaultNamingContext"][0]
-        self.config_dn = self.info_dc1["configurationNamingContext"][0]
-        self.forest_level = int(self.info_dc1["forestFunctionality"][0])
-
-        # we will need DCs DNS names for 'samba-tool drs' command
-        self.dnsname_dc1 = self.info_dc1["dnsHostName"][0]
-        self.dnsname_dc2 = self.info_dc2["dnsHostName"][0]
-
     def tearDown(self):
         super(DrsReplSchemaTestCase, self).tearDown()
 
-    def _net_drs_replicate(self, DC, fromDC, nc_dn):
-        """Triggers replication cycle on 'DC' to
-           replicate from 'fromDC'. Naming context to
-           be replicated is 'nc_dn' dn"""
-        # find out where is net command
-        samba_tool_cmd = os.path.abspath("./bin/samba-tool")
-        # make command line credentials string
-        creds = self.get_credentials()
-        cmd_line_auth = "-U%s/%s%%%s" % (creds.get_domain(),
-                                         creds.get_username(), creds.get_password())
-        # bin/samba-tool drs replicate <Dest_DC_NAME> <Src_DC_NAME> <Naming Context>
-        cmd_line = "%s drs replicate %s %s %s %s" % (samba_tool_cmd, DC, fromDC,
-                                                     nc_dn, cmd_line_auth)
-        ret = os.system(cmd_line)
-        self.assertEquals(ret, 0, "Replicating %s from %s has failed!" % (DC, fromDC))
-
-    def _GUID_string(self, guid):
-        return self.ldb_dc1.schema_format_value("objectGUID", guid)
-
-    def _ldap_schemaUpdateNow(self, sam_db):
-        rec = {"dn": "",
-               "schemaUpdateNow": "1"}
-        m = Message.from_dict(sam_db, rec, FLAG_MOD_REPLACE)
-        sam_db.modify(m)
-
     def _make_obj_names(self, base_name):
         '''Try to create a unique name for an object
            that is to be added to schema'''
diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py
new file mode 100644
index 0000000..5410ed6
--- /dev/null
+++ b/source4/torture/drs/python/replica_sync.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Tests various schema replication scenarios
+#
+# Copyright (C) Kamen Mazdrashki <kamenim at 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/>.
+#
+
+#
+# Usage:
+#  export DC1=dc1_dns_name
+#  export DC2=dc2_dns_name
+#  export SUBUNITRUN=$samba4srcdir/scripting/bin/subunitrun
+#  PYTHONPATH="$PYTHONPATH:$samba4srcdir/torture/drs/python" $SUBUNITRUN replica_sync -U"$DOMAIN/$DC_USERNAME"%"$DC_PASSWORD"
+#
+
+import sys
+import time
+import random
+import os
+
+import drs_base
+import samba.tests
+
+from ldb import (
+    ERR_NO_SUCH_OBJECT,
+    LdbError,
+    SCOPE_BASE,
+    Message,
+    FLAG_MOD_ADD,
+    FLAG_MOD_REPLACE,
+    )
+
+
+class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
+    """Intended as a black box test case for DsReplicaSync
+       implementation. It should test the behavior of this
+       case in cases when inbound replication is disabled"""
+
+    def setUp(self):
+        super(DrsReplicaSyncTestCase, self).setUp()
+
+    def tearDown(self):
+        # re-enable replication
+        self._enable_inbound_repl(self.dnsname_dc1)
+        super(DrsReplicaSyncTestCase, self).tearDown()
+
+    def _enable_inbound_repl(self, DC):
+        # make base command line
+        samba_tool_cmd = self._samba_tool_cmdline("options")
+        # disable replication
+        self.check_run("%s %s --dsa-option=-DISABLE_INBOUND_REPL" %(samba_tool_cmd, DC))
+
+    def _disable_inbound_repl(self, DC):
+        # make base command line
+        samba_tool_cmd = self._samba_tool_cmdline("options")
+        # disable replication
+        self.check_run("%s %s --dsa-option=+DISABLE_INBOUND_REPL" %(samba_tool_cmd, DC))
+
+    def test_ReplEnabled(self):
+        """Tests we can replicate when replication is enabled"""
+        self._enable_inbound_repl(self.dnsname_dc1)
+        self._net_drs_replicate(DC=self.dnsname_dc1, fromDC=self.dnsname_dc2, forced=False)
+
+    def test_ReplDisabled(self):
+        """Tests we cann't replicate when replication is disabled"""
+        self._disable_inbound_repl(self.dnsname_dc1)
+        try:
+            self._net_drs_replicate(DC=self.dnsname_dc1, fromDC=self.dnsname_dc2, forced=False)
+        except samba.tests.BlackboxProcessError, e:
+            self.assertTrue('WERR_DS_DRA_SINK_DISABLED' in e.stderr)
+        else:
+            self.fail("'drs replicate' command should have failed!")
+
+    def test_ReplDisabledForced(self):
+        """Tests we cann't replicate when replication is disabled"""
+        self._disable_inbound_repl(self.dnsname_dc1)
+        out = self._net_drs_replicate(DC=self.dnsname_dc1, fromDC=self.dnsname_dc2, forced=True)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list