summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2017-09-13 16:13:06 +1200
committerStefan Metzmacher <metze@samba.org>2017-09-14 18:43:16 +0200
commit51be27522caffde8a3806f8c0c877a0f85eaf398 (patch)
treeb85927ee466dbe9fac65bf796f6f90f0f1d8a984 /python
parenta808c0200197a4648caba88a550c8d63f3c8fe63 (diff)
downloadsamba-51be27522caffde8a3806f8c0c877a0f85eaf398.tar.gz
selftest: Check re-opening sam.ldb corrects the @ATTRIBUTES and @INDEXLIST
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/dsdb_schema_attributes.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/python/samba/tests/dsdb_schema_attributes.py b/python/samba/tests/dsdb_schema_attributes.py
index df6c8bb11b2..2bebbb569f2 100644
--- a/python/samba/tests/dsdb_schema_attributes.py
+++ b/python/samba/tests/dsdb_schema_attributes.py
@@ -173,3 +173,56 @@ systemOnly: FALSE
self.assertIn(attr_ldap_name, [str(x) for x in idx_res[0]["@IDXATTR"]])
self.assertIn(attr_ldap_name2, [str(x) for x in idx_res[0]["@IDXATTR"]])
+
+ def test_modify_at_attributes(self):
+ m = {"dn": "@ATTRIBUTES",
+ "@TEST_EXTRA": ["HIDDEN"]
+ }
+
+ msg = ldb.Message.from_dict(self.samdb, m, ldb.FLAG_MOD_ADD)
+ self.samdb.modify(msg)
+
+ res = self.samdb.search(base="@ATTRIBUTES", scope=ldb.SCOPE_BASE,
+ attrs=["@TEST_EXTRA"])
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), "@ATTRIBUTES")
+ self.assertEquals(len(res[0]), 1)
+ self.assertTrue("@TEST_EXTRA" in res[0])
+ self.assertEquals(len(res[0]["@TEST_EXTRA"]), 1)
+ self.assertEquals(res[0]["@TEST_EXTRA"][0], "HIDDEN")
+
+ samdb2 = samba.tests.connect_samdb(self.lp.samdb_url())
+
+ res = self.samdb.search(base="@ATTRIBUTES", scope=ldb.SCOPE_BASE,
+ attrs=["@TEST_EXTRA"])
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), "@ATTRIBUTES")
+ self.assertEquals(len(res[0]), 0)
+ self.assertFalse("@TEST_EXTRA" in res[0])
+
+
+ def test_modify_at_indexlist(self):
+ m = {"dn": "@INDEXLIST",
+ "@TEST_EXTRA": ["1"]
+ }
+
+ msg = ldb.Message.from_dict(self.samdb, m, ldb.FLAG_MOD_ADD)
+ self.samdb.modify(msg)
+
+ res = self.samdb.search(base="@INDEXLIST", scope=ldb.SCOPE_BASE,
+ attrs=["@TEST_EXTRA"])
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), "@INDEXLIST")
+ self.assertEquals(len(res[0]), 1)
+ self.assertTrue("@TEST_EXTRA" in res[0])
+ self.assertEquals(len(res[0]["@TEST_EXTRA"]), 1)
+ self.assertEquals(res[0]["@TEST_EXTRA"][0], "1")
+
+ samdb2 = samba.tests.connect_samdb(self.lp.samdb_url())
+
+ res = self.samdb.search(base="@INDEXLIST", scope=ldb.SCOPE_BASE,
+ attrs=["@TEST_EXTRA"])
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), "@INDEXLIST")
+ self.assertEquals(len(res[0]), 0)
+ self.assertFalse("@TEST_EXTRA" in res[0])