tests: Rework backup test_backup_invalid_args test-case
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 22 Nov 2018 01:35:58 +0000 (14:35 +1300)
committerTim Beale <timbeale@samba.org>
Tue, 27 Nov 2018 02:43:17 +0000 (03:43 +0100)
self.create_backup() uses self.run_cmd(), which is a wrapper around
self.check_output(). Rework the code to call the underlying
check_output() function directly instead.

The reason we're doing this is we want run_cmd() to catch exceptions and
fail the test (i.e. in the next patch). However, we can't do that because
this test case relies on receiving the exceptions.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/domain_backup.py

index e9fcd31fb2513bbb1c544fc54382ec836dea0170..5b68ea92b5e043784619d7d1c249f269ab68f6c7 100644 (file)
@@ -479,14 +479,17 @@ class DomainBackupRename(DomainBackupBase):
         """Checks that rename commands with invalid args are rejected"""
 
         # try a "rename" using the same realm as the DC currently has
-        self.base_cmd = ["domain", "backup", "rename", self.restore_domain,
-                         os.environ["REALM"]]
-        self.assertRaises(BlackboxProcessError, self.create_backup)
+        rename_cmd = "samba-tool domain backup rename "
+        bad_cmd = "{cmd} {domain} {realm}".format(cmd=rename_cmd,
+                                                  domain=self.restore_domain,
+                                                  realm=os.environ["REALM"])
+        self.assertRaises(BlackboxProcessError, self.check_output, bad_cmd)
 
         # try a "rename" using the same domain as the DC currently has
-        self.base_cmd = ["domain", "backup", "rename", os.environ["DOMAIN"],
-                         self.restore_realm]
-        self.assertRaises(BlackboxProcessError, self.create_backup)
+        bad_cmd = "{cmd} {domain} {realm}".format(cmd=rename_cmd,
+                                                  domain=os.environ["DOMAIN"],
+                                                  realm=self.restore_realm)
+        self.assertRaises(BlackboxProcessError, self.check_output, bad_cmd)
 
     def add_link(self, attr, source, target):
         m = ldb.Message()