tests:samba_tool: pass stdout and stderr to assertCmdSuccess()
authorStefan Metzmacher <metze@samba.org>
Tue, 2 Aug 2016 10:33:34 +0000 (12:33 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 4 Aug 2016 16:26:06 +0000 (18:26 +0200)
This allows us to generate better assert messages and give the
developer some ideas why the command wasn't able to run.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
12 files changed:
python/samba/tests/samba_tool/base.py
python/samba/tests/samba_tool/fsmo.py
python/samba/tests/samba_tool/gpo.py
python/samba/tests/samba_tool/group.py
python/samba/tests/samba_tool/ntacl.py
python/samba/tests/samba_tool/processes.py
python/samba/tests/samba_tool/rodc.py
python/samba/tests/samba_tool/sites.py
python/samba/tests/samba_tool/timecmd.py
python/samba/tests/samba_tool/user.py
python/samba/tests/samba_tool/user_check_password_script.py
source4/torture/drs/python/fsmo.py

index de6cf18434811506ba663f3a7026776462051cf3..8f00534bf664df9b6bacd98fd42b3e4a540120bb 100644 (file)
@@ -81,8 +81,9 @@ class SambaToolCmdTest(samba.tests.BlackboxTestCase):
         result = cmd._run("samba-tool %s %s" % (name, sub), *args)
         return (result, cmd.outf.getvalue(), cmd.errf.getvalue())
 
-    def assertCmdSuccess(self, val, msg=""):
-        self.assertIsNone(val, msg)
+    def assertCmdSuccess(self, exit, out, err, msg=""):
+        self.assertIsNone(exit, msg="exit[%s] stdout[%s] stderr[%s]: %s" % (
+                          exit, out, err, msg))
 
     def assertCmdFail(self, val, msg=""):
         self.assertIsNotNone(val, msg)
index 207aa1778ed121ba3ad848a0997a4c91ed987c7e..c985830cf6c1fd37d118a054330e84c3100afed4 100644 (file)
@@ -25,7 +25,7 @@ class FsmoCmdTestCase(SambaToolCmdTest):
         """Run fsmo show to see if it errors"""
         (result, out, err) = self.runsubcmd("fsmo", "show")
 
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
 
         # Check that the output is sensible
index e20a97794ae43808b5064456fc38d36262cccdda..cd22706a3203e55e5ce36fa68a6d2d3ea63f6a9f 100644 (file)
@@ -30,7 +30,7 @@ class GpoCmdTestCase(SambaToolCmdTest):
     def test_gpo_list(self):
         """Run gpo list against the server and make sure it looks accurate"""
         (result, out, err) = self.runsubcmd("gpo", "listall", "-H", "ldap://%s" % os.environ["SERVER"])
-        self.assertCmdSuccess(result, "Ensuring gpo listall ran successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo listall ran successfully")
 
     def test_fetchfail(self):
         """Run against a non-existent GPO, and make sure it fails (this hard-coded UUID is very unlikely to exist"""
@@ -40,23 +40,23 @@ class GpoCmdTestCase(SambaToolCmdTest):
     def test_fetch(self):
         """Run against a real GPO, and make sure it passes"""
         (result, out, err) = self.runsubcmd("gpo", "fetch", self.gpo_guid, "-H", "ldap://%s" % os.environ["SERVER"], "--tmpdir", self.tempdir)
-        self.assertCmdSuccess(result, "Ensuring gpo fetched successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo fetched successfully")
         shutil.rmtree(os.path.join(self.tempdir, "policy"))
 
     def test_show(self):
         """Show a real GPO, and make sure it passes"""
         (result, out, err) = self.runsubcmd("gpo", "show", self.gpo_guid, "-H", "ldap://%s" % os.environ["SERVER"])
-        self.assertCmdSuccess(result, "Ensuring gpo fetched successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo fetched successfully")
 
     def test_show_as_admin(self):
         """Show a real GPO, and make sure it passes"""
         (result, out, err) = self.runsubcmd("gpo", "show", self.gpo_guid, "-H", "ldap://%s" % os.environ["SERVER"], "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"]))
-        self.assertCmdSuccess(result, "Ensuring gpo fetched successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo fetched successfully")
 
     def test_aclcheck(self):
         """Check all the GPOs on the remote server have correct ACLs"""
         (result, out, err) = self.runsubcmd("gpo", "aclcheck", "-H", "ldap://%s" % os.environ["SERVER"], "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"]))
-        self.assertCmdSuccess(result, "Ensuring gpo checked successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo checked successfully")
 
     def setUp(self):
         """set up a temporary GPO to work with"""
@@ -66,7 +66,7 @@ class GpoCmdTestCase(SambaToolCmdTest):
                                             "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"]),
                                             "--tmpdir", self.tempdir)
         shutil.rmtree(os.path.join(self.tempdir, "policy"))
-        self.assertCmdSuccess(result, "Ensuring gpo created successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo created successfully")
         try:
             self.gpo_guid = "{%s}" % out.split("{")[1].split("}")[0]
         except IndexError:
@@ -75,5 +75,5 @@ class GpoCmdTestCase(SambaToolCmdTest):
     def tearDown(self):
         """remove the temporary GPO to work with"""
         (result, out, err) = self.runsubcmd("gpo", "del", self.gpo_guid, "-H", "ldap://%s" % os.environ["SERVER"], "-U%s%%%s" % (os.environ["USERNAME"], os.environ["PASSWORD"]))
-        self.assertCmdSuccess(result, "Ensuring gpo deleted successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring gpo deleted successfully")
         super(GpoCmdTestCase, self).tearDown()
index 2c0c46e5dc8435b81583d83ad92093e49cfd175b..09ba59d8a4dcedbd1bade9cd0eaf5ab54d9d6bfe 100644 (file)
@@ -43,7 +43,7 @@ class GroupCmdTestCase(SambaToolCmdTest):
         for group in self.groups:
             (result, out, err) = self._create_group(group)
 
-            self.assertCmdSuccess(result)
+            self.assertCmdSuccess(result, out, err)
             self.assertEquals(err, "", "There shouldn't be any error message")
             self.assertIn("Added group %s" % group["name"], out)
 
@@ -73,7 +73,7 @@ class GroupCmdTestCase(SambaToolCmdTest):
         # try to delete all the groups we just added
         for group in self.groups:
             (result, out, err) = self.runsubcmd("group", "delete", group["name"])
-            self.assertCmdSuccess(result,
+            self.assertCmdSuccess(result, out, err,
                                   "Failed to delete group '%s'" % group["name"])
             found = self._find_group(group["name"])
             self.assertIsNone(found,
@@ -87,7 +87,7 @@ class GroupCmdTestCase(SambaToolCmdTest):
                                                  "-U%s%%%s" % (os.environ["DC_USERNAME"],
                                                  os.environ["DC_PASSWORD"]))
 
-            self.assertCmdSuccess(result)
+            self.assertCmdSuccess(result, out, err)
             self.assertEquals(err,"","There shouldn't be any error message")
             self.assertIn("Added group %s" % group["name"], out)
 
@@ -102,7 +102,7 @@ class GroupCmdTestCase(SambaToolCmdTest):
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"],
                                                           os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Error running list")
+        self.assertCmdSuccess(result, out, err, "Error running list")
 
         search_filter = "(objectClass=group)"
 
@@ -123,7 +123,7 @@ class GroupCmdTestCase(SambaToolCmdTest):
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"],
                                                           os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Error running listmembers")
+        self.assertCmdSuccess(result, out, err, "Error running listmembers")
 
         search_filter = "(|(primaryGroupID=513)(memberOf=CN=Domain Users,CN=Users,%s))" % self.samdb.domain_dn()
 
index 2a329fe7d403802b8c21b7d081fead7fceeb7602..c01d5acd73f8a76c944485d9ee81b365a1722aaf 100644 (file)
@@ -31,7 +31,7 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest):
     def test_ntvfs(self):
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolreset",
                                              "--use-ntvfs")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(out,"","Shouldn't be any output messages")
         self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err)
 
@@ -39,19 +39,19 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest):
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolreset",
                                              "--use-s3fs")
 
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(out,"","Shouldn't be any output messages")
 
     def test_ntvfs_check(self):
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolreset",
                                              "--use-ntvfs")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(out,"","Shouldn't be any output messages")
         self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err)
         # Now check they were set correctly
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolcheck")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(out,"","Shouldn't be any output messages")
 
@@ -59,13 +59,13 @@ class NtACLCmdSysvolTestCase(SambaToolCmdTest):
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolreset",
                                              "--use-s3fs")
 
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(out,"","Shouldn't be any output messages")
 
         # Now check they were set correctly
         (result, out, err) =  self.runsubcmd("ntacl", "sysvolcheck")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(out,"","Shouldn't be any output messages")
 
@@ -82,7 +82,7 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
 
         (result, out, err) =  self.runsubcmd("ntacl", "set", self.acl, tempf,
                                              "--use-ntvfs")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(out,"","Shouldn't be any output messages")
         self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err)
 
@@ -94,7 +94,7 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
         (result, out, err) =  self.runsubcmd("ntacl", "set", self.acl, tempf,
                                              "--use-s3fs")
 
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(out,"","Shouldn't be any output messages")
 
@@ -105,14 +105,14 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
 
         (result, out, err) =  self.runsubcmd("ntacl", "set", self.acl, tempf,
                                              "--use-ntvfs")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(out,"","Shouldn't be any output messages")
         self.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err)
 
         # Now check they were set correctly
         (result, out, err) =  self.runsubcmd("ntacl",  "get", tempf,
                                              "--use-ntvfs", "--as-sddl")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(self.acl+"\n", out, "Output should be the ACL")
 
@@ -123,13 +123,13 @@ class NtACLCmdGetSetTestCase(SambaToolCmdTest):
 
         (result, out, err) =  self.runsubcmd("ntacl", "set", self.acl, tempf,
                                              "--use-s3fs")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(out,"","Shouldn't be any output messages")
         self.assertEquals(err,"","Shouldn't be any error messages")
 
         # Now check they were set correctly
         (result, out, err) =  self.runsubcmd("ntacl",  "get", tempf,
                                              "--use-s3fs", "--as-sddl")
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertEquals(self.acl+"\n", out,"Output should be the ACL")
index 91a5266b54acdffca5747ee1ae82dc825e4d5d0a..5b8f50241838100a355557564e2e4506ace06a90 100644 (file)
@@ -27,9 +27,9 @@ class ProcessCmdTestCase(SambaToolCmdTest):
     def test_name(self):
         """Run processes command"""
         (result, out, err) = self.runcmd("processes", "--name", "samba")
-        self.assertCmdSuccess(result, "Ensuring processes ran successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring processes ran successfully")
 
     def test_all(self):
         """Run processes command"""
         (result, out, err) = self.runcmd("processes")
-        self.assertCmdSuccess(result, "Ensuring processes ran successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring processes ran successfully")
index 798bc178eeeb02be57afa125c17b066bc7e66932..4851a53910a81c6aeb01b029085c58647cdc230b 100644 (file)
@@ -66,26 +66,26 @@ class RodcCmdTestCase(SambaToolCmdTest):
     def test_single_by_account_name(self):
         (result, out, err) = self.runsubcmd("rodc", "preload", "sambatool1",
                                             "--server", os.environ["DC_SERVER"])
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool1,CN=Users,%s\n" % self.base_dn)
         self.assertEqual(err, "")
 
     def test_single_by_dn(self):
         (result, out, err) = self.runsubcmd("rodc", "preload", "cn=sambatool2,cn=users,%s" % self.base_dn,
                                             "--server", os.environ["DC_SERVER"])
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool2,CN=Users,%s\n" % self.base_dn)
 
     def test_multi_by_account_name(self):
         (result, out, err) = self.runsubcmd("rodc", "preload", "sambatool1", "sambatool2",
                                             "--server", os.environ["DC_SERVER"])
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool1,CN=Users,%s\nReplicating DN CN=sambatool2,CN=Users,%s\n" % (self.base_dn, self.base_dn))
 
     def test_multi_by_dn(self):
         (result, out, err) = self.runsubcmd("rodc", "preload", "cn=sambatool3,cn=users,%s" % self.base_dn, "cn=sambatool4,cn=users,%s" % self.base_dn,
                                             "--server", os.environ["DC_SERVER"])
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool3,CN=Users,%s\nReplicating DN CN=sambatool4,CN=Users,%s\n" % (self.base_dn, self.base_dn))
 
     def test_multi_in_file(self):
@@ -93,7 +93,7 @@ class RodcCmdTestCase(SambaToolCmdTest):
         open(tempf, 'w').write("sambatool1\nsambatool2")
         (result, out, err) = self.runsubcmd("rodc", "preload", "--file", tempf,
                                             "--server", os.environ["DC_SERVER"])
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool1,CN=Users,%s\nReplicating DN CN=sambatool2,CN=Users,%s\n" % (self.base_dn, self.base_dn))
         os.unlink(tempf)
 
@@ -103,7 +103,7 @@ class RodcCmdTestCase(SambaToolCmdTest):
                                             "nonexistentuser2",
                                             "--server", os.environ["DC_SERVER"],
                                             "--ignore-errors")
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool5,CN=Users,%s\n" % self.base_dn)
 
     def test_multi_with_missing_name_failure(self):
@@ -118,7 +118,7 @@ class RodcCmdTestCase(SambaToolCmdTest):
                                             "sambatool6", "sambatool5",
                                             "--server", os.environ["DC_SERVER"],
                                             "--ignore-errors")
-        self.assertCmdSuccess(result, "ensuring rodc prefetch ran successfully")
+        self.assertCmdSuccess(result, out, err, "ensuring rodc prefetch ran successfully")
         self.assertEqual(out, "Replicating DN CN=sambatool6,CN=Users,%s\nReplicating DN CN=sambatool5,CN=Users,%s\n" % (self.base_dn, self.base_dn))
 
     def test_multi_without_group_failure(self):
index ee281094d2ac9674e0997be985f911b909b95ac5..8f96bba4df80b8dcbdba99547c933a29d5596843 100644 (file)
@@ -44,7 +44,7 @@ class SitesCmdTestCase(BaseSitesCmdTestCase):
 
         result, out, err = self.runsubcmd("sites", "create", sitename,
                                           "-H", self.dburl, self.creds_string)
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
 
         dnsites = ldb.Dn(self.samdb, "CN=Sites,%s" % self.config_dn)
         dnsite = ldb.Dn(self.samdb, "CN=%s,%s" % (sitename, dnsites))
@@ -89,7 +89,7 @@ class SitesSubnetCmdTestCase(BaseSitesCmdTestCase):
                                               cidr, sitename,
                                               "-H", self.dburl,
                                               self.creds_string)
-            self.assertCmdSuccess(result)
+            self.assertCmdSuccess(result, out, err)
 
             ret = self.samdb.search(base=self.config_dn,
                                     scope=ldb.SCOPE_SUBTREE,
index 000f0f2828228c8b2b7050599f0a5c5d2ef122ff..310f861f7090f853c01061db307069d9d0ff28ca 100644 (file)
@@ -25,7 +25,7 @@ class TimeCmdTestCase(SambaToolCmdTest):
     def test_timeget(self):
         """Run time against the server and make sure it looks accurate"""
         (result, out, err) = self.runcmd("time", os.environ["SERVER"])
-        self.assertCmdSuccess(result, "Ensuring time ran successfully")
+        self.assertCmdSuccess(result, out, err, "Ensuring time ran successfully")
 
         timefmt = strptime(out, "%a %b %d %H:%M:%S %Y %Z\n")
         servertime = int(mktime(timefmt))
index 91e45c312cbccfa5639f804a210dd9c529df580b..d2eb0e63ae57663fc470a743d763d2e6560785be 100644 (file)
@@ -51,7 +51,7 @@ class UserCmdTestCase(SambaToolCmdTest):
         for user in self.users:
             (result, out, err) = user["createUserFn"](user)
 
-            self.assertCmdSuccess(result)
+            self.assertCmdSuccess(result, out, err)
             self.assertEquals(err,"","Shouldn't be any error messages")
             self.assertIn("User '%s' created successfully" % user["name"], out)
 
@@ -76,7 +76,7 @@ class UserCmdTestCase(SambaToolCmdTest):
         # try to delete all the 4 users we just added
         for user in self.users:
             (result, out, err) = self.runsubcmd("user", "delete", user["name"])
-            self.assertCmdSuccess(result, "Can we delete users")
+            self.assertCmdSuccess(result, out, err, "Can we delete users")
             found = self._find_user(user["name"])
             self.assertIsNone(found)
 
@@ -93,7 +93,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                  "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                  "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
 
-            self.assertCmdSuccess(result)
+            self.assertCmdSuccess(result, out, err)
             self.assertEquals(err,"","Shouldn't be any error messages")
             self.assertIn("User '%s' created successfully" % user["name"], out)
 
@@ -193,7 +193,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "--newpassword=%s" % newpasswd,
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-            # self.assertCmdSuccess(result, "Ensure setpassword runs")
+            self.assertCmdSuccess(result, out, err, "Ensure setpassword runs")
             self.assertEquals(err,"","setpassword with url")
             self.assertMatch(out, "Changed password OK", "setpassword with url")
 
@@ -202,7 +202,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                             "--cache-ldb-initialize",
                                             "--attributes=%s" % attributes,
                                             "--decrypt-samba-gpg")
-        self.assertCmdSuccess(result, "Ensure syncpasswords --cache-ldb-initialize runs")
+        self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --cache-ldb-initialize runs")
         self.assertEqual(err,"","getpassword without url")
         cache_attrs = {
             "objectClass": { "value": "userSyncPasswords" },
@@ -220,7 +220,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                 "syncpasswords --cache-ldb-initialize: %s: %s out[%s]" % (a, v, out))
 
         (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait")
-        self.assertCmdSuccess(result, "Ensure syncpasswords --no-wait runs")
+        self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs")
         self.assertEqual(err,"","syncpasswords --no-wait")
         self.assertMatch(out, "dirsync_loop(): results 0",
             "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out))
@@ -241,12 +241,12 @@ class UserCmdTestCase(SambaToolCmdTest):
             (result, out, err) = self.runsubcmd("user", "setpassword",
                                                 user["name"],
                                                 "--newpassword=%s" % newpasswd)
-            self.assertCmdSuccess(result, "Ensure setpassword runs")
+            self.assertCmdSuccess(result, out, err, "Ensure setpassword runs")
             self.assertEquals(err,"","setpassword without url")
             self.assertMatch(out, "Changed password OK", "setpassword without url")
 
             (result, out, err) = self.runsubcmd("user", "syncpasswords", "--no-wait")
-            self.assertCmdSuccess(result, "Ensure syncpasswords --no-wait runs")
+            self.assertCmdSuccess(result, out, err, "Ensure syncpasswords --no-wait runs")
             self.assertEqual(err,"","syncpasswords --no-wait")
             self.assertMatch(out, "dirsync_loop(): results 0",
                 "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out))
@@ -272,7 +272,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 user["name"],
                                                 "--attributes=%s" % attributes,
                                                 "--decrypt-samba-gpg")
-            self.assertCmdSuccess(result, "Ensure getpassword runs")
+            self.assertCmdSuccess(result, out, err, "Ensure getpassword runs")
             self.assertEqual(err,"","getpassword without url")
             self.assertMatch(out, "Got password OK", "getpassword without url")
             self.assertMatch(out, "sAMAccountName: %s" % (user["name"]),
@@ -298,7 +298,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "--must-change-at-next-login",
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-            # self.assertCmdSuccess(result, "Ensure setpassword runs")
+            self.assertCmdSuccess(result, out, err, "Ensure setpassword runs")
             self.assertEquals(err,"","setpassword with forced change")
             self.assertMatch(out, "Changed password OK", "setpassword with forced change")
 
@@ -313,7 +313,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "--days=2",
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-            self.assertCmdSuccess(result, "Can we run setexpiry with names")
+            self.assertCmdSuccess(result, out, err, "Can we run setexpiry with names")
             self.assertIn("Expiry for user '%s' set to 2 days." % user["name"], out)
 
         for user in self.users:
@@ -333,7 +333,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "--days=4",
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Can we run setexpiry with a filter")
+        self.assertCmdSuccess(result, out, err, "Can we run setexpiry with a filter")
 
         for user in self.users:
             found = self._find_user(user["name"])
@@ -350,7 +350,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"],
                                                           os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Error running list")
+        self.assertCmdSuccess(result, out, err, "Error running list")
 
         search_filter = ("(&(objectClass=user)(userAccountControl:%s:=%u))" %
                          (ldb.OID_COMPARATOR_AND, dsdb.UF_NORMAL_ACCOUNT))
@@ -410,8 +410,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
 
-        msg = "command should return %s" % err
-        self.assertCmdSuccess(result, msg)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertIn("User '%s' created successfully" % user["name"], out)
 
@@ -440,8 +439,7 @@ class UserCmdTestCase(SambaToolCmdTest):
                                                 "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                                 "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
 
-        msg = "command should return %s" % err
-        self.assertCmdSuccess(result, msg)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         self.assertIn("User '%s' created successfully" % user["name"], out)
 
index 5d4fbaec233d85e077b6a577a0ae46eda2673013..f1deb88ee65ad097b89140e2c94ef3a12f98622a 100644 (file)
@@ -54,12 +54,12 @@ class UserCheckPwdTestCase(SambaToolCmdTest):
         (result, out, err) = self.runsubcmd("user", "delete", user["name"],
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Should delete user with bad password.")
+        self.assertCmdSuccess(result, out, err, "Should delete user with bad password.")
 
         (result, out, err) = self.runsubcmd("user", "add", user["name"], good_password,
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Should succeed adding a user with good password.")
+        self.assertCmdSuccess(result, out, err, "Should succeed adding a user with good password.")
 
         # Set password
         (result, out, err) = self.runsubcmd("user", "setpassword", user["name"],
@@ -72,7 +72,7 @@ class UserCheckPwdTestCase(SambaToolCmdTest):
                                             "--newpassword=%s" % good_password,
                                             "-H", "ldap://%s" % os.environ["DC_SERVER"],
                                             "-U%s%%%s" % (os.environ["DC_USERNAME"], os.environ["DC_PASSWORD"]))
-        self.assertCmdSuccess(result, "Should succeed setting a user's password to a good one.")
+        self.assertCmdSuccess(result, out, err, "Should succeed setting a user's password to a good one.")
 
         # Password=
 
@@ -86,7 +86,7 @@ class UserCheckPwdTestCase(SambaToolCmdTest):
                                             "--newpassword=%s" % good_password + 'XYZ',
                                             "--ipaddress", os.environ["DC_SERVER_IP"],
                                             "-U%s%%%s" % (user["name"], good_password))
-        self.assertCmdSuccess(result, "A user setting their own password to a good one should succeed.")
+        self.assertCmdSuccess(result, out, err, "A user setting their own password to a good one should succeed.")
 
     def _randomUser(self, base={}):
         """create a user with random attribute values, you can specify base attributes"""
index df5a274a06d33e37f62389c2aa95f3e761575a82..4dd652d13be19deb03eac2f7dc9ae26d4dc81bac 100644 (file)
@@ -66,7 +66,7 @@ class DrsFsmoTestCase(drs_base.DrsBaseTestCase):
                                             "-H", "ldap://%s:389" % DC,
                                             cmd_line_auth)
 
-        self.assertCmdSuccess(result)
+        self.assertCmdSuccess(result, out, err)
         self.assertEquals(err,"","Shouldn't be any error messages")
         if noop == False:
             self.assertTrue("FSMO transfer of '%s' role successful" % role in out)