From: Stefan Metzmacher Date: Tue, 16 Feb 2016 02:19:58 +0000 (+0100) Subject: python:samba/tests: add simple 'samba-tool user getpassword' test X-Git-Tag: tdb-1.3.10~202 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3add197e202d3d540d65e7b9b856e95b4829724f;p=thirdparty%2Fsamba.git python:samba/tests: add simple 'samba-tool user getpassword' test Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 645eb402c64..0ce7f19a842 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -17,9 +17,11 @@ import os import time +import base64 import ldb from samba.tests.samba_tool.base import SambaToolCmdTest from samba import ( + credentials, nttime2unix, dsdb ) @@ -114,13 +116,33 @@ class UserCmdTestCase(SambaToolCmdTest): for user in self.users: newpasswd = self.randomPass() + creds = credentials.Credentials() + creds.set_anonymous() + creds.set_password(newpasswd) + nthash = creds.get_nt_hash() + attributes = "sAMAccountName,unicodePwd,supplementalCredentials" + unicodePwd = base64.b64encode(creds.get_nt_hash()) + (result, out, err) = self.runsubcmd("user", "setpassword", user["name"], "--newpassword=%s" % newpasswd) - # self.assertCmdSuccess(result, "Ensure setpassword runs") + self.assertCmdSuccess(result, "Ensure setpassword runs") self.assertEquals(err,"","setpassword without url") self.assertMatch(out, "Changed password OK", "setpassword without url") + (result, out, err) = self.runsubcmd("user", "getpassword", + user["name"], + "--attributes=%s" % attributes) + self.assertCmdSuccess(result, "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"]), + "getpassword: 'sAMAccountName': %s out[%s]" % (user["name"], out)) + self.assertMatch(out, "unicodePwd:: %s" % unicodePwd, + "getpassword unicodePwd: out[%s]" % out) + self.assertMatch(out, "supplementalCredentials:: ", + "getpassword supplementalCredentials: out[%s]" % out) + for user in self.users: newpasswd = self.randomPass() (result, out, err) = self.runsubcmd("user", "setpassword",