From: Jule Anger Date: Wed, 28 Aug 2019 09:06:13 +0000 (+0200) Subject: samba-tool tests: add test-case for 'user list --base-dn' X-Git-Tag: samba-4.12.0rc1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=918d91bb8432ffc0788409ef94fa8b1365be8500;p=thirdparty%2Fsamba.git samba-tool tests: add test-case for 'user list --base-dn' Check if the user list --base-dn / -b command uses a specific base dn. 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 69876450cd1..65930ed89de 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -380,6 +380,30 @@ class UserCmdTestCase(SambaToolCmdTest): found = self.assertMatch(out, name, "user '%s' not found" % name) + + def test_list_base_dn(self): + base_dn = "CN=Users" + (result, out, err) = self.runsubcmd("user", "list", "-b", base_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.normalize_dn_in_domain(base_dn), + scope=ldb.SCOPE_SUBTREE, + expression=search_filter, + attrs=["samaccountname"]) + + self.assertTrue(len(userlist) > 0, "no users found in samdb") + + for userobj in userlist: + name = str(userobj.get("samaccountname", idx=0)) + 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"],