use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testNoUserModification.
/**
* Tests NO-USER-MODIFICATION
*
* @throws ParseException
*/
@Test
public void testNoUserModification() throws ParseException {
String value = null;
AttributeType attributeType = null;
// not NO-USER-MODIFICATION
value = "( 1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' )";
attributeType = parser.parseAttributeTypeDescription(value);
assertTrue(attributeType.isUserModifiable());
// NO-USER-MODIFICATION
value = "(1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' NO-USER-MODIFICATION USAGE directoryOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isUserModifiable());
// NO-USER-MODIFICATION
value = "(1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE directoryOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isUserModifiable());
// ivalid
value = "(1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' NO-USER-MODIFICATIO USAGE directoryOperation )";
try {
attributeType = parser.parseAttributeTypeDescription(value);
fail("Exception expected, invalid NO-USER-MODIFICATION value");
} catch (ParseException pe) {
// expected
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testNoqualityMR.
/**
* Tests without EQUALITY
*
* @throws ParseException
*/
@Test
public void testNoqualityMR() throws ParseException {
String value = "( 2.5.4.58 NAME 'attributeCertificateAttribute' " + "DESC 'attribute certificate use ;binary' " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.8 ) ";
AttributeType attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("2.5.4.58", attributeType.getOid());
assertEquals(1, attributeType.getNames().size());
assertEquals("attributeCertificateAttribute", attributeType.getNames().get(0));
assertEquals("attribute certificate use ;binary", attributeType.getDescription());
assertNull(attributeType.getSuperiorOid());
assertNull(attributeType.getEqualityOid());
assertEquals("1.3.6.1.4.1.1466.115.121.1.8", attributeType.getSyntaxOid());
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
assertEquals(0, attributeType.getExtensions().size());
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testCollecitveConstraint.
/**
* Test collective constraint:
* COLLECTIVE requires USAGE userApplications
*
* @throws ParseException
*/
@Test
public void testCollecitveConstraint() throws ParseException {
String value = null;
AttributeType attributeType = null;
value = "( 1.1 SYNTAX 1.1 COLLECTIVE )";
attributeType = parser.parseAttributeTypeDescription(value);
assertTrue(attributeType.isCollective());
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE userApplications )";
attributeType = parser.parseAttributeTypeDescription(value);
assertTrue(attributeType.isCollective());
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
if (!parser.isQuirksMode()) {
value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE directoryOperation )";
try {
parser.parseAttributeTypeDescription(value);
fail("Exception expected, COLLECTIVE requires USAGE userApplications");
} catch (ParseException pe) {
// expected
}
value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE dSAOperation )";
try {
parser.parseAttributeTypeDescription(value);
fail("Exception expected, COLLECTIVE requires USAGE userApplications");
} catch (ParseException pe) {
// expected
}
value = "( 1.1 SYNTAX 1.1 COLLECTIVE USAGE distributedOperation )";
try {
parser.parseAttributeTypeDescription(value);
fail("Exception expected, COLLECTIVE requires USAGE userApplications");
} catch (ParseException pe) {
// expected
}
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testIgnoreElementOrder.
/**
* Ensure that element order is ignored
*
* @throws ParseException
*/
@Test
public void testIgnoreElementOrder() throws ParseException {
String value = "( 2.5.4.3 SUP name SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE userApplications DESC 'RFC2256: common name(s) for which the entity is known by' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch NAME ( 'cn' 'commonName' ) )";
AttributeType attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("2.5.4.3", attributeType.getOid());
assertEquals(2, attributeType.getNames().size());
assertEquals("cn", attributeType.getNames().get(0));
assertEquals("commonName", attributeType.getNames().get(1));
assertEquals("RFC2256: common name(s) for which the entity is known by", attributeType.getDescription());
assertEquals("name", attributeType.getSuperiorOid());
assertEquals("caseIgnoreMatch", attributeType.getEqualityOid());
assertEquals("caseIgnoreSubstringsMatch", attributeType.getSubstringOid());
assertEquals("1.3.6.1.4.1.1466.115.121.1.15", attributeType.getSyntaxOid());
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
assertEquals(0, attributeType.getExtensions().size());
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testATWithSpacesInDesc.
/**
* Tests with spaces in DESC
*
* @throws ParseException
*/
@Test
public void testATWithSpacesInDesc() throws ParseException {
String value = "( 1.3.18.0.2.4.216 NAME 'SAFDfpDataClass' DESC ' ' " + "EQUALITY 2.5.13.2 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )";
AttributeType attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("1.3.18.0.2.4.216", attributeType.getOid());
assertEquals(1, attributeType.getNames().size());
assertEquals("SAFDfpDataClass", attributeType.getNames().get(0));
assertEquals(" ", attributeType.getDescription());
assertNull(attributeType.getSuperiorOid());
assertEquals("2.5.13.2", attributeType.getEqualityOid());
assertEquals("1.3.6.1.4.1.1466.115.121.1.15", attributeType.getSyntaxOid());
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
assertTrue(attributeType.isSingleValued());
assertEquals(0, attributeType.getExtensions().size());
}
Aggregations