From 88f0a1390b854f4ea1f6e29914e3bac85457c745 Mon Sep 17 00:00:00 2001 From: Jule Anger Date: Tue, 27 Aug 2019 13:08:34 +0200 Subject: [PATCH] samba-tool tests: add test-case for 'computer list --base-dn' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Check if the computer list --base-dn / -b command uses a specific base dn. Signed-off-by: Jule Anger Reviewed-by: Björn Baumbach Reviewed-by: Ralph Boehme --- python/samba/tests/samba_tool/computer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/python/samba/tests/samba_tool/computer.py b/python/samba/tests/samba_tool/computer.py index 11ee4e1a3fd..9912fd408a4 100644 --- a/python/samba/tests/samba_tool/computer.py +++ b/python/samba/tests/samba_tool/computer.py @@ -209,6 +209,26 @@ class ComputerCmdTestCase(SambaToolCmdTest): found = self.assertMatch(out, str(name), "computer '%s' not found" % name) + def test_list_base_dn(self): + base_dn = str(self.samdb.domain_dn()) + (result, out, err) = self.runsubcmd("computer", "list", "-b", base_dn) + self.assertCmdSuccess(result, out, err, "Error running list") + + search_filter = ("(sAMAccountType=%u)" % + dsdb.ATYPE_WORKSTATION_TRUST) + + computerlist = self.samdb.search(base=base_dn, + scope=ldb.SCOPE_SUBTREE, + expression=search_filter, + attrs=["name"]) + + self.assertTrue(len(computerlist) > 0, "no computers found in samdb") + + for computerobj in computerlist: + name = computerobj.get("name", idx=0) + found = self.assertMatch(out, str(name), + "computer '%s' not found" % name) + def test_move(self): parentou = self._randomOU({"name": "parentOU"}) (result, out, err) = self._create_ou(parentou) -- 2.11.4.GIT