summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-02-16 03:19:58 +0100
committerStefan Metzmacher <metze@samba.org>2016-07-22 16:03:26 +0200
commit3add197e202d3d540d65e7b9b856e95b4829724f (patch)
tree194c6b08628717cea6d7dd8381de06e79717ff27 /python
parentdeb2a0258e74b0fd6a570d7abbe3485a7d346b5f (diff)
downloadsamba-3add197e202d3d540d65e7b9b856e95b4829724f.tar.gz
python:samba/tests: add simple 'samba-tool user getpassword' test
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/user.py24
1 files changed, 23 insertions, 1 deletions
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",