use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNameOfAnObjectClass.
/**
* Try to inject an AttributeType with an ObjectClass name
*/
@Test
public void testAddAttributeTypeNameOfAnObjectClass() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid("2.5.13.1");
attributeType.setSubstringOid("2.5.13.1");
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setNames("Test", "referral");
// It should be ok
assertTrue(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(0, errors.size());
// The AT must be present
assertTrue(isATPresent(schemaManager, "1.1.1.0"));
assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize + 1, schemaManager.getGlobalOidRegistry().size());
AttributeType added = schemaManager.lookupAttributeTypeRegistry("referral");
assertNotNull(added);
assertEquals("1.1.1.0", added.getOid());
assertTrue(added.getNames().contains("referral"));
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupInvalidSubstringMR.
/**
* Try to inject an AttributeType with an invalid SUBSTR MR
*/
@Test
public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid(null);
attributeType.setOrderingOid(null);
attributeType.setSubstringOid("0.0");
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// It should fail
assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertFalse(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupNoUserModificationOpAttr.
/**
* Try to inject an AttributeType which is a NO-USER-MODIFICATION and is operational
*/
@Test
public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
attributeType.setUserModifiable(false);
// It should not fail
assertTrue(schemaManager.add(attributeType));
assertTrue(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize + 1, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeSupDifferentUsage.
/**
* Try to inject an AttributeType with a superior and different USAGE
*/
@Test
public void testAddAttributeTypeSupDifferentUsage() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid(null);
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
attributeType.setSuperiorOid("2.5.18.4");
attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
// It should fail
assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertFalse(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupCollectiveOperational.
/**
* Try to inject an AttributeType which is Collective, but an operational AT
*/
@Test
public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setUsage(UsageEnum.DIRECTORY_OPERATION);
attributeType.setCollective(true);
// It should fail
assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertFalse(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Aggregations