From: Stefan Metzmacher Date: Tue, 16 Feb 2016 02:19:58 +0000 (+0100) Subject: python:samba/tests: add simple 'samba-tool user syncpasswords' test X-Git-Tag: tdb-1.3.10~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8791960bf6bcca75a5790bfb7319acdbf63560f6;p=thirdparty%2Fsamba.git python:samba/tests: add simple 'samba-tool user syncpasswords' test Signed-off-by: Stefan Metzmacher Reviewed-by: Alexander Bokovoy --- 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)