s4:ldap_schema.py - add an additional check for validity of "defaultObjectCategory"
[ira/wip.git] / source4 / lib / ldb / tests / python / ldap_schema.py
index 9dd9240414052bc74b41bd9ca0b0888af8be9aad..9e547321048e0e55e750fce17c0ec7e81bf34b14 100755 (executable)
@@ -142,6 +142,31 @@ systemOnly: FALSE
         class_name = "test-Class" + time.strftime("%s", time.gmtime())
         class_ldap_display_name = class_name.replace("-", "")
 
+        # First try to create a class with a wrong "defaultObjectCategory"
+        ldif = """
+dn: CN=%s,%s""" % (class_name, self.schema_dn) + """
+objectClass: top
+objectClass: classSchema
+defaultObjectCategory: CN=_
+adminDescription: """ + class_name + """
+adminDisplayName: """ + class_name + """
+cn: """ + class_name + """
+governsId: 1.2.840.""" + str(random.randint(1,100000)) + """.1.5.9939
+instanceType: 4
+objectClassCategory: 1
+subClassOf: organizationalPerson
+systemFlags: 16
+rDNAttID: cn
+systemMustContain: cn
+systemMustContain: """ + attr_ldap_display_name + """
+systemOnly: FALSE
+"""
+        try:
+                 self.ldb.add_ldif(ldif)
+                 self.fail()
+        except LdbError, (num, _):
+                 self.assertEquals(num, ERR_CONSTRAINT_VIOLATION)
+
         ldif = """
 dn: CN=%s,%s""" % (class_name, self.schema_dn) + """
 objectClass: top