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
commit8791960bf6bcca75a5790bfb7319acdbf63560f6 (patch)
tree0dd2966bba6a156904fc311890753849ab66b2bc /python
parentc68cb6a1d9d366ac3e564245ecca34348a4f1aa2 (diff)
downloadsamba-8791960bf6bcca75a5790bfb7319acdbf63560f6.tar.gz
python:samba/tests: add simple 'samba-tool user syncpasswords' test
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/user.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py
index 0ecd51753d8..a4bba2f6b7f 100644
--- a/python/samba/tests/samba_tool/user.py
+++ b/python/samba/tests/samba_tool/user.py
@@ -188,13 +188,41 @@ class UserCmdTestCase(SambaToolCmdTest):
self.assertEquals(err,"","setpassword with url")
self.assertMatch(out, "Changed password OK", "setpassword with url")
+ attributes = "sAMAccountName,unicodePwd,supplementalCredentials"
+ (result, out, err) = self.runsubcmd("user", "syncpasswords",
+ "--cache-ldb-initialize",
+ "--attributes=%s" % attributes)
+ self.assertCmdSuccess(result, "Ensure syncpasswords --cache-ldb-initialize runs")
+ self.assertEqual(err,"","getpassword without url")
+ cache_attrs = {
+ "objectClass": { "value": "userSyncPasswords" },
+ "samdbUrl": { },
+ "dirsyncFilter": { },
+ "dirsyncAttribute": { },
+ "dirsyncControl": { "value": "dirsync:1:0:0"},
+ "passwordAttribute": { },
+ "currentTime": { },
+ }
+ for a in cache_attrs.keys():
+ v = cache_attrs[a].get("value", "")
+ self.assertMatch(out, "%s: %s" % (a, v),
+ "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.assertEqual(err,"","syncpasswords --no-wait")
+ self.assertMatch(out, "dirsync_loop(): results 0",
+ "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out))
+ for user in self.users:
+ self.assertMatch(out, "sAMAccountName: %s" % (user["name"]),
+ "syncpasswords --no-wait: 'sAMAccountName': %s out[%s]" % (user["name"], out))
+
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",
@@ -204,6 +232,22 @@ class UserCmdTestCase(SambaToolCmdTest):
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.assertEqual(err,"","syncpasswords --no-wait")
+ self.assertMatch(out, "dirsync_loop(): results 0",
+ "syncpasswords --no-wait: 'dirsync_loop(): results 0': out[%s]" % (out))
+ self.assertMatch(out, "sAMAccountName: %s" % (user["name"]),
+ "syncpasswords --no-wait: 'sAMAccountName': %s out[%s]" % (user["name"], out))
+ self.assertMatch(out, "# unicodePwd::: REDACTED SECRET ATTRIBUTE",
+ "getpassword '# unicodePwd::: REDACTED SECRET ATTRIBUTE': out[%s]" % out)
+ self.assertMatch(out, "unicodePwd:: %s" % unicodePwd,
+ "getpassword unicodePwd: out[%s]" % out)
+ self.assertMatch(out, "# supplementalCredentials::: REDACTED SECRET ATTRIBUTE",
+ "getpassword '# supplementalCredentials::: REDACTED SECRET ATTRIBUTE': out[%s]" % out)
+ self.assertMatch(out, "supplementalCredentials:: ",
+ "getpassword supplementalCredentials: out[%s]" % out)
+
(result, out, err) = self.runsubcmd("user", "getpassword",
user["name"],
"--attributes=%s" % attributes)