selftest: Add test for samba-tool dsacl get, cross-checked with samba-tool dsacl set
authorAndrew Bartlett <abartlet@samba.org>
Thu, 21 Feb 2019 02:49:25 +0000 (15:49 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 21 Feb 2019 03:09:21 +0000 (04:09 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/samba_tool/dsacl.py

index 61cd5c5d35534353409555862db064661db6b98f..4b5f4c827fc9cd1ecb0bc84d91fee8c117b981f7 100644 (file)
@@ -48,6 +48,36 @@ class DSaclSetSddlTestCase(SambaToolCmdTest):
         acl_list=re.findall('.*descriptor for.*:\n(.*?)\n',out)
         self.assertMatch(acl_list[1], self.sddl, "new SDDL string should be contained within second sddl output")
 
+    def test_sddl_set_get(self):
+        """Tests if a sddl string can be added 'the normal way' and the output of 'get' is the same"""
+        (result, out, err) = self.runsubcmd("dsacl", "get",
+                                            "--objectdn=%s" % self.dn)
+        self.assertCmdSuccess(result, out, err)
+        self.assertEquals(err, "", "Shouldn't be any error messages")
+        #extract only the two sddl strings from samba-tool output
+        acl_list_get=re.findall('^descriptor for.*:\n(.*?)\n', out)
+
+        (result, out, err) = self.runsubcmd("dsacl", "set",
+                                            "--objectdn=%s" % self.dn,
+                                            "--sddl=%s" % self.sddl)
+        self.assertCmdSuccess(result, out, err)
+        self.assertEquals(err, "", "Shouldn't be any error messages")
+        #extract only the two sddl strings from samba-tool output
+        acl_list_old=re.findall('old descriptor for.*:\n(.*?)\n', out)
+        self.assertEqual(acl_list_old, acl_list_get,
+                         "output of dsacl get should be the same as before set")
+
+        acl_list=re.findall('new descriptor for.*:\n(.*?)\n', out)
+
+        (result, out, err) = self.runsubcmd("dsacl", "get",
+                                            "--objectdn=%s" % self.dn)
+        self.assertCmdSuccess(result, out, err)
+        self.assertEquals(err, "", "Shouldn't be any error messages")
+        #extract only the two sddl strings from samba-tool output
+        acl_list_get2=re.findall('^descriptor for.*:\n(.*?)\n', out)
+        self.assertEqual(acl_list, acl_list_get2,
+                         "output of dsacl get should be the same as after set")
+
     def test_multisddl(self):
         """Tests if we can add multiple, different sddl strings at the same time"""
         (result, out, err) = self.runsubcmd("dsacl", "set","--objectdn=%s" % self.dn, "--sddl=%s" % self.sddl_multi)