Skip to content

Commit

Permalink
netcmd: getpassword: print OK message on stderr
Browse files Browse the repository at this point in the history
This makes it easier to machine parse the output in tests

Signed-off-by: Rob van der Linde <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
  • Loading branch information
robvdl authored and douglasbagnall committed Dec 21, 2023
1 parent 587642a commit bf37d53
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/samba/netcmd/user/readpasswords/getpassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ def run(self, username=None, H=None, filter=None,

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")
5 changes: 2 additions & 3 deletions python/samba/tests/samba_tool/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ def test_setpassword(self):
"--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:
Expand All @@ -357,7 +356,7 @@ def test_setpassword(self):
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)
Expand Down
5 changes: 1 addition & 4 deletions python/samba/tests/samba_tool/user_virtualCryptSHA.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def _get_password(self, attributes, decrypt=False):
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
Expand Down
5 changes: 1 addition & 4 deletions python/samba/tests/samba_tool/user_virtualCryptSHA_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ def _get_password(self, attributes, decrypt=False):
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
Expand Down
5 changes: 1 addition & 4 deletions python/samba/tests/samba_tool/user_wdigest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ def _testWDigest(self, attribute, expected, missing=False):
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)
Expand Down

0 comments on commit bf37d53

Please sign in to comment.