From: Jule Anger Date: Wed, 28 Aug 2019 08:40:39 +0000 (+0200) Subject: samba-tool tests: add test case for 'user list --full-dn' X-Git-Tag: samba-4.12.0rc1~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08207f77f13e82cbe1c5a1f82f45680cadfd65d9;p=thirdparty%2Fsamba.git samba-tool tests: add test case for 'user list --full-dn' Check if the --full-dn option displays DN instead of the sAMAccountName. Signed-off-by: Jule Anger Reviewed-by: Björn Baumbach Reviewed-by: Ralph Boehme --- diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 4ebc9eb3bab..69876450cd1 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -380,6 +380,28 @@ class UserCmdTestCase(SambaToolCmdTest): found = self.assertMatch(out, name, "user '%s' not found" % name) + def test_list_full_dn(self): + (result, out, err) = self.runsubcmd("user", "list", "--full-dn", + "-H", "ldap://%s" % os.environ["DC_SERVER"], + "-U%s%%%s" % (os.environ["DC_USERNAME"], + os.environ["DC_PASSWORD"])) + self.assertCmdSuccess(result, out, err, "Error running list") + + search_filter = ("(&(objectClass=user)(userAccountControl:%s:=%u))" % + (ldb.OID_COMPARATOR_AND, dsdb.UF_NORMAL_ACCOUNT)) + + userlist = self.samdb.search(base=self.samdb.domain_dn(), + scope=ldb.SCOPE_SUBTREE, + expression=search_filter, + attrs=["dn"]) + + self.assertTrue(len(userlist) > 0, "no users found in samdb") + + for userobj in userlist: + name = str(userobj.get("dn", idx=0)) + found = self.assertMatch(out, name, + "user '%s' not found" % name) + def test_show(self): for user in self.users: (result, out, err) = self.runsubcmd(