From: Rob van der Linde Date: Thu, 7 Dec 2023 02:28:04 +0000 (+1300) Subject: netcmd: getpassword: print OK message on stderr X-Git-Tag: talloc-2.4.2~252 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf37d538e63791d740a9a0bc50557915e7401c0e;p=thirdparty%2Fsamba.git netcmd: getpassword: print OK message on stderr This makes it easier to machine parse the output in tests Signed-off-by: Rob van der Linde Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/netcmd/user/readpasswords/getpassword.py b/python/samba/netcmd/user/readpasswords/getpassword.py index b06bf58fdea..b5496a8d631 100644 --- a/python/samba/netcmd/user/readpasswords/getpassword.py +++ b/python/samba/netcmd/user/readpasswords/getpassword.py @@ -197,4 +197,4 @@ samba-tool user getpassword --filter=samaccountname=TestUser3 --attributes=msDS- ldif = samdb.write_ldif(obj, ldb.CHANGETYPE_NONE) self.outf.write("%s" % ldif) - self.outf.write("Got password OK\n") + self.errf.write("Got password OK\n") diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index e43a00c472e..00f667bc487 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -346,8 +346,7 @@ class UserCmdTestCase(SambaToolCmdTest): "--attributes=%s" % attributes, "--decrypt-samba-gpg") self.assertCmdSuccess(result, out, err, "Ensure getpassword runs") - self.assertEqual(err, "", "getpassword without url") - self.assertMatch(out, "Got password OK", "getpassword without url") + self.assertEqual(err, "Got password OK\n", "getpassword without url") self.assertMatch(out, "sAMAccountName: %s" % (user["name"]), "getpassword: 'sAMAccountName': %s out[%s]" % (user["name"], out)) if expect_nt_hash: @@ -357,7 +356,7 @@ class UserCmdTestCase(SambaToolCmdTest): self.assertNotIn("unicodePwd:: %s" % unicodePwd, out) self.assertMatch(out, "supplementalCredentials:: ", "getpassword supplementalCredentials: out[%s]" % out) - self._verify_supplementalCredentials(out.replace("\nGot password OK\n", "")) + self._verify_supplementalCredentials(out) if "virtualSambaGPG:: " in out: self.assertMatch(out, "virtualClearTextUTF8:: %s" % virtualClearTextUTF8, "getpassword virtualClearTextUTF8: out[%s]" % out) diff --git a/python/samba/tests/samba_tool/user_virtualCryptSHA.py b/python/samba/tests/samba_tool/user_virtualCryptSHA.py index e58340436a2..e95a4be2aa9 100644 --- a/python/samba/tests/samba_tool/user_virtualCryptSHA.py +++ b/python/samba/tests/samba_tool/user_virtualCryptSHA.py @@ -73,10 +73,7 @@ class UserCmdCryptShaTestCase(SambaToolCmdTest): out, err, "Ensure getpassword runs") - self.assertEqual(err, "", "getpassword") - self.assertMatch(out, - "Got password OK", - "getpassword out[%s]" % out) + self.assertEqual(err, "Got password OK\n", "getpassword") return out # Change the just the NT password hash, as would happen if the password diff --git a/python/samba/tests/samba_tool/user_virtualCryptSHA_base.py b/python/samba/tests/samba_tool/user_virtualCryptSHA_base.py index 19cd713eacf..14e3de97a2f 100644 --- a/python/samba/tests/samba_tool/user_virtualCryptSHA_base.py +++ b/python/samba/tests/samba_tool/user_virtualCryptSHA_base.py @@ -79,10 +79,7 @@ class UserCmdCryptShaTestCase(SambaToolCmdTest): out, err, "Ensure getpassword runs") - self.assertEqual(err, "", "getpassword") - self.assertMatch(out, - "Got password OK", - "getpassword out[%s]" % out) + self.assertEqual(err, "Got password OK\n", "getpassword") return out # Change the just the NT password hash, as would happen if the password diff --git a/python/samba/tests/samba_tool/user_wdigest.py b/python/samba/tests/samba_tool/user_wdigest.py index d1153120599..0d8776203de 100644 --- a/python/samba/tests/samba_tool/user_wdigest.py +++ b/python/samba/tests/samba_tool/user_wdigest.py @@ -89,10 +89,7 @@ class UserCmdWdigestTestCase(SambaToolCmdTest): out, err, "Ensure getpassword runs") - self.assertEqual(err, "", "getpassword") - self.assertMatch(out, - "Got password OK", - "getpassword out[%s]" % out) + self.assertEqual(err, "Got password OK\n", "getpassword") if missing: self.assertTrue(attribute not in out)