samba-tool tests: add test-case for 'ou list --base-dn'
authorJule Anger <ja@sernet.de>
Tue, 27 Aug 2019 10:21:29 +0000 (12:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 21 Jan 2020 14:38:46 +0000 (14:38 +0000)
Check if the ou list --base-dn / -b command uses a specific base dn.

Signed-off-by: Jule Anger <ja@sernet.de>
Reviewed-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
python/samba/tests/samba_tool/ou.py

index 39b0cad425037521b1b670525c9f6c08f6a0cae1..9a6ccfe226a4b6359c45ee877f07d5fe76756770 100644 (file)
@@ -145,6 +145,25 @@ class OUCmdTestCase(SambaToolCmdTest):
             found = self.assertMatch(out, str(name),
                                      "ou '%s' not found" % name)
 
+    def test_list_base_dn(self):
+        base_dn = str(self.samdb.domain_dn())
+        (result, out, err) = self.runsubcmd("ou", "list", "-b", base_dn)
+        self.assertCmdSuccess(result, out, err, "Error running list")
+
+        search_filter = "(objectClass=organizationalUnit)"
+
+        oulist = self.samdb.search(base=base_dn,
+                                   scope=ldb.SCOPE_SUBTREE,
+                                   expression=search_filter,
+                                   attrs=["name"])
+
+        self.assertTrue(len(oulist) > 0, "no ous found in samdb")
+
+        for ouobj in oulist:
+            name = ouobj.get("name", idx=0)
+            found = self.assertMatch(out, str(name),
+                                     "ou '%s' not found" % name)
+
     def test_rename(self):
         for ou in self.ous:
             ousuffix = "RenameTest"