Here are the examples of the java api class org.apache.directory.api.ldap.model.entry.Entry taken from open source projects.
1. AbstractKerberosITest#createPrincipal()
Project: directory-server
File: AbstractKerberosITest.java
File: AbstractKerberosITest.java
private void createPrincipal(String rdn, String sn, String cn, String uid, String userPassword, String principalName) throws LdapException { Entry entry = new DefaultEntry(); entry.setDn(rdn + "," + USERS_DN); entry.add("objectClass", "top", "person", "inetOrgPerson", "krb5principal", "krb5kdcentry"); entry.add("cn", cn); entry.add("sn", sn); entry.add("uid", uid); entry.add("userPassword", userPassword); entry.add("krb5PrincipalName", principalName); entry.add("krb5KeyVersionNumber", "0"); conn.add(entry); }
2. KdcConnectionTest#createPrincipal()
Project: directory-server
File: KdcConnectionTest.java
File: KdcConnectionTest.java
private String createPrincipal(String uid, String userPassword, String principalName) throws Exception { Entry entry = new DefaultEntry(session.getDirectoryService().getSchemaManager()); entry.setDn("uid=" + uid + "," + USERS_DN); entry.add("objectClass", "top", "person", "inetOrgPerson", "krb5principal", "krb5kdcentry"); entry.add("cn", uid); entry.add("sn", uid); entry.add("uid", uid); entry.add("userPassword", userPassword); entry.add("krb5PrincipalName", principalName); entry.add("krb5KeyVersionNumber", "0"); session.add(entry); return entry.getDn().getName(); }
3. KdcAsRepTest#createPrincipal()
Project: directory-server
File: KdcAsRepTest.java
File: KdcAsRepTest.java
private String createPrincipal(String uid, String userPassword, String principalName) throws Exception { Entry entry = new DefaultEntry(session.getDirectoryService().getSchemaManager()); entry.setDn("uid=" + uid + "," + USERS_DN); entry.add("objectClass", "top", "person", "inetOrgPerson", "krb5principal", "krb5kdcentry"); entry.add("cn", uid); entry.add("sn", uid); entry.add("uid", uid); entry.add("userPassword", userPassword); entry.add("krb5PrincipalName", principalName); entry.add("krb5KeyVersionNumber", "0"); session.add(entry); return entry.getDn().getName(); }
4. SaslBindIT#getPrincipalAttributes()
Project: directory-server
File: SaslBindIT.java
File: SaslBindIT.java
//////////////////////// protected Entry getPrincipalAttributes(String dn, String sn, String cn, String uid, String userPassword, String principal) throws LdapException { Entry entry = new DefaultEntry(dn); entry.add(SchemaConstants.OBJECT_CLASS_AT, "person", "inetOrgPerson", "krb5principal", "krb5kdcentry"); entry.add(SchemaConstants.CN_AT, cn); entry.add(SchemaConstants.SN_AT, sn); entry.add(SchemaConstants.UID_AT, uid); entry.add(SchemaConstants.USER_PASSWORD_AT, userPassword); entry.add(KerberosAttribute.KRB5_PRINCIPAL_NAME_AT, principal); entry.add(KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT, "0"); return entry; }
5. SchemaAwareEntryTest#testUserCertificateBinary()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for userCertificate;binary AT */ @Test public void testUserCertificateBinary() throws LdapException { Entry entry = new DefaultEntry(schemaManager); entry.add("objectClass", "top", "person", "inetorgPerson"); entry.add("cn", "test1", "test2"); entry.add("sn", "Test1", "Test2"); entry.add("userPassword", BYTES1, BYTES2); entry.add("userCertificate;binary", Strings.getBytesUtf8("secret")); assertTrue(entry.containsAttribute("userCertificate;binary")); assertTrue(entry.containsAttribute("userCertificate")); entry.removeAttributes("userCertificate;binary"); assertFalse(entry.containsAttribute("userCertificate;binary")); assertFalse(entry.containsAttribute("userCertificate")); entry.add("userCertificate", Strings.getBytesUtf8("secret")); assertTrue(entry.containsAttribute("userCertificate;binary")); assertTrue(entry.containsAttribute("userCertificate")); }
6. OperationalAttributeInterceptor#rename()
Project: directory-server
File: OperationalAttributeInterceptor.java
File: OperationalAttributeInterceptor.java
/** * {@inheritDoc} */ public void rename(RenameOperationContext renameContext) throws LdapException { Entry entry = ((ClonedServerEntry) renameContext.getEntry()).getClonedEntry(); entry.put(SchemaConstants.MODIFIERS_NAME_AT, getPrincipal(renameContext).getName()); entry.put(SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); Entry modifiedEntry = renameContext.getOriginalEntry().clone(); modifiedEntry.put(SchemaConstants.MODIFIERS_NAME_AT, getPrincipal(renameContext).getName()); modifiedEntry.put(SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); Attribute csnAt = new DefaultAttribute(directoryService.getAtProvider().getEntryCSN(), directoryService.getCSN().toString()); modifiedEntry.put(csnAt); renameContext.setModifiedEntry(modifiedEntry); next(renameContext); }
7. AttributesFactory#convert()
Project: directory-shared
File: AttributesFactory.java
File: AttributesFactory.java
public Entry convert(String oid, LdapComparator<? super Object> comparator, Schema schema, SchemaManager schemaManager) { Entry entry = new DefaultEntry(schemaManager); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC); entry.put(MetaSchemaConstants.M_OID_AT, oid); entry.put(MetaSchemaConstants.M_FQCN_AT, comparator.getClass().getName()); entry.put(SchemaConstants.CREATORS_NAME_AT, schema.getOwner()); entry.put(SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); return entry; }
8. AttributesFactory#convert()
Project: directory-shared
File: AttributesFactory.java
File: AttributesFactory.java
public Entry convert(SyntaxChecker syntaxChecker, Schema schema, SchemaManager schemaManager) { Entry entry = new DefaultEntry(schemaManager); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC); entry.put(MetaSchemaConstants.M_OID_AT, syntaxChecker.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName()); entry.put(SchemaConstants.CREATORS_NAME_AT, schema.getOwner()); entry.put(SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); return entry; }
9. ExceptionServiceIT#testFailAddOnAlias()
Project: directory-server
File: ExceptionServiceIT.java
File: ExceptionServiceIT.java
// ------------------------------------------------------------------------ // List Operation Tests // ------------------------------------------------------------------------ /** * Test list operation failure when the base searched is non-existant. * * @throws Exception on error * @Test public void testFailListNoSuchObject() throws Exception { LdapConnection connection = getAdminConnection( getService() ); try { connection.list( "ou=blah" ); fail( "Execution should never get here due to exception!" ); } catch ( LdapNoSuchObjectException e ) { assertEquals( "ou=system", e.getResolvedName().toString() ); assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, e.getResultCode() ); } } /** * List operation control to test if normal list operations occur correctly. * * @throws Exception on error * @Test public void testListControl() throws Exception { LdapConnection connection = getAdminConnection( getService() ); NamingEnumeration<?> list = connection.list( "ou=users" ); if ( list.hasMore() ) { SearchResult result = (SearchResult)list.next(); assertNotNull( result.getAttributes() ); assertEquals( "uid=akarasulu,ou=users,ou=system", result.getName() ); } assertFalse( list.hasMore() ); } */ // ------------------------------------------------------------------------ // Add Operation Tests // ------------------------------------------------------------------------ /** * Tests for add operation failure when the parent of the entry to add does * not exist. * * @throws Exception on error */ @Test(expected = LdapAliasException.class) public void testFailAddOnAlias() throws Exception { LdapConnection connection = getAdminConnection(getService()); Entry entry = new DefaultEntry("cn=toanother,ou=system"); entry.add(SchemaConstants.OBJECT_CLASS_AT, "alias", SchemaConstants.EXTENSIBLE_OBJECT_OC); entry.add("aliasedObjectName", "ou=users,ou=system"); connection.add(entry); Entry aliasChild = new DefaultEntry("ou=blah,cn=toanother,ou=system"); aliasChild.add(SchemaConstants.OBJECT_CLASS_AT, "organizationalUnit"); aliasChild.add(SchemaConstants.OU_AT, "blah"); connection.add(aliasChild); }
10. SchemaAwareEntryTest#testCopyConstructorClientEntry()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test the copy constructor of a ClientEntry */ @Test public void testCopyConstructorClientEntry() throws LdapException { Entry clientEntry = new DefaultEntry(); clientEntry.setDn(new Dn(schemaManager, "ou=system")); clientEntry.add("cn", "test1", "test2"); clientEntry.add("objectClass", "top", "person"); Entry copyEntry = new DefaultEntry(schemaManager, clientEntry); assertTrue(copyEntry instanceof Entry); assertTrue(copyEntry.contains("objectClass", "top", "person")); assertTrue(copyEntry.contains("cn", "test1", "test2")); clientEntry.removeAttributes("cn"); assertTrue(copyEntry.contains("objectClass", "top", "person")); assertTrue(copyEntry.contains("cn", "test1", "test2")); }
11. SchemaAwareEntryTest#testRemoveAttributesStringArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for removeAttributes( String... ) */ @Test public void testRemoveAttributesStringArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); entry.put(attrOC, attrCN, attrSN, attrPWD); entry.removeAttributes("CN", "SN"); assertFalse(entry.containsAttribute("cn", "sn")); assertTrue(entry.containsAttribute("objectclass", "userpassword")); entry.removeAttributes("badId"); entry.removeAttributes("l"); entry.removeAttributes((String) null); }
12. SchemaAwareEntryTest#testCopyConstructorServerEntry()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test the copy constructor of a Entry */ @Test public void testCopyConstructorServerEntry() throws LdapException { Entry serverEntry = new DefaultEntry(schemaManager); serverEntry.add("cn", "test1", "test2"); serverEntry.add("objectClass", "top", "person"); Entry copyEntry = new DefaultEntry(schemaManager, serverEntry); assertEquals(copyEntry, serverEntry); assertTrue(copyEntry.contains("objectClass", "top", "person")); assertTrue(copyEntry.contains("cn", "test1", "test2")); serverEntry.removeAttributes("cn"); assertNotSame(copyEntry, serverEntry); assertTrue(copyEntry.contains("objectClass", "top", "person")); assertTrue(copyEntry.contains("cn", "test1", "test2")); }
13. SchemaAwareEntryTest#testSize()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test for method size() */ @Test public void testSize() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertEquals(0, entry.size()); entry.add("ObjectClass", schemaManager.lookupAttributeTypeRegistry("ObjectClass"), "top", "person"); entry.add("CN", schemaManager.lookupAttributeTypeRegistry("Cn"), "test"); entry.add("SN", schemaManager.lookupAttributeTypeRegistry("Sn"), "Test"); assertEquals(3, entry.size()); entry.clear(); assertEquals(0, entry.size()); }
14. OperationalAttributeInterceptor#moveAndRename()
Project: directory-server
File: OperationalAttributeInterceptor.java
File: OperationalAttributeInterceptor.java
/** * {@inheritDoc} */ public void moveAndRename(MoveAndRenameOperationContext moveAndRenameContext) throws LdapException { Entry modifiedEntry = moveAndRenameContext.getOriginalEntry().clone(); modifiedEntry.put(SchemaConstants.MODIFIERS_NAME_AT, getPrincipal(moveAndRenameContext).getName()); modifiedEntry.put(SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); modifiedEntry.setDn(moveAndRenameContext.getNewDn()); Attribute csnAt = new DefaultAttribute(directoryService.getAtProvider().getEntryCSN(), directoryService.getCSN().toString()); modifiedEntry.put(csnAt); moveAndRenameContext.setModifiedEntry(modifiedEntry); next(moveAndRenameContext); }
15. OperationalAttributeInterceptor#move()
Project: directory-server
File: OperationalAttributeInterceptor.java
File: OperationalAttributeInterceptor.java
/** * {@inheritDoc} */ public void move(MoveOperationContext moveContext) throws LdapException { Entry modifiedEntry = moveContext.getOriginalEntry().clone(); modifiedEntry.put(SchemaConstants.MODIFIERS_NAME_AT, getPrincipal(moveContext).getName()); modifiedEntry.put(SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); Attribute csnAt = new DefaultAttribute(directoryService.getAtProvider().getEntryCSN(), directoryService.getCSN().toString()); modifiedEntry.put(csnAt); modifiedEntry.setDn(moveContext.getNewDn()); moveContext.setModifiedEntry(modifiedEntry); next(moveContext); }
16. PasswordHashingInterceptorTest#testAddWithHashedPassword()
Project: directory-server
File: PasswordHashingInterceptorTest.java
File: PasswordHashingInterceptorTest.java
public void testAddWithHashedPassword() throws Exception { LdapConnection connection = IntegrationUtils.getAdminConnection(getService()); byte[] plainPwd = "secret".getBytes(); byte[] hashedPwd = PasswordUtil.createStoragePassword(plainPwd, LdapSecurityConstants.HASH_METHOD_SSHA); Dn dn = new Dn("cn=testHash,ou=system"); Entry entry = new DefaultEntry(getService().getSchemaManager(), dn); entry.add("ObjectClass", "top", "person"); entry.add("sn", "TEST"); entry.add("cn", "testHash"); entry.add(SchemaConstants.USER_PASSWORD_AT, hashedPwd); connection.add(entry); entry = connection.lookup(dn); Attribute pwdAt = entry.get(SchemaConstants.USER_PASSWORD_AT); assertTrue(Arrays.equals(hashedPwd, pwdAt.getBytes())); assertTrue(PasswordUtil.compareCredentials(plainPwd, pwdAt.getBytes())); connection.delete(dn); }
17. ExceptionServiceIT#createSubContext()
Project: directory-server
File: ExceptionServiceIT.java
File: ExceptionServiceIT.java
private AddResponse createSubContext(Dn parent, String type, String value) throws Exception { Dn dn = parent; dn = dn.add("ou=" + value); Entry entry = new DefaultEntry(dn); entry.add(SchemaConstants.OBJECT_CLASS_AT, "person"); entry.add(SchemaConstants.OBJECT_CLASS_AT, "OrganizationalPerson"); entry.add(SchemaConstants.CN_AT, value); entry.add(SchemaConstants.SN_AT, value); AddRequest addRequest = new AddRequestImpl(); addRequest.setEntry(entry); addRequest.setEntryDn(dn); AddResponse resp = getAdminConnection(getService()).add(addRequest); return resp; }
18. SchemaAwareEntryTest#testSerializeEntryWithNoDN()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test the serialization of an entry with no Dn */ @Test public void testSerializeEntryWithNoDN() throws LdapException, IOException, ClassNotFoundException { byte[] password = Strings.getBytesUtf8("secret"); Entry entry = new DefaultEntry(); entry.add("ObjectClass", "top", "person"); entry.add("cn", "test1"); entry.add("userPassword", password); Entry entrySer = deserializeValue(serializeValue(entry)); assertEquals(entry, entrySer); }
19. SchemaAwareEntryTest#testSerializeCompleteEntry()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test the serialization of a complete entry */ @Test public void testSerializeCompleteEntry() throws LdapException, IOException, ClassNotFoundException { Dn dn = new Dn("ou=system"); dn.apply(schemaManager); byte[] password = Strings.getBytesUtf8("secret"); Entry entry = new DefaultEntry(dn); entry.add("ObjectClass", "top", "person"); entry.add("cn", "test1"); entry.add("userPassword", password); Entry entrySer = deserializeValue(serializeValue(entry)); assertEquals(entry, entrySer); }
20. SchemaAwareEntryTest#testSize()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for size() */ @Test public void testSize() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertEquals(0, entry.size()); entry.add("ObjectClass", "top", "person"); entry.add("cn", "test"); entry.add("sn", "Test"); assertEquals(3, entry.size()); entry.clear(); assertEquals(0, entry.size()); }
21. SchemaAwareEntryTest#testRemoveAttributesStringArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for removeAttributes( String... ) */ @Test public void testRemoveAttributesStringArray() throws LdapException { Entry entry = new DefaultEntry(exampleDn); Attribute attrOC = new DefaultAttribute("objectClass", "top", "person"); Attribute attrCN = new DefaultAttribute("cn", "test1", "test2"); Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2); entry.put(attrOC, attrCN, attrSN, attrPWD); entry.removeAttributes("CN", "SN"); assertFalse(entry.containsAttribute("cn", "sn")); assertTrue(entry.containsAttribute("objectclass", "userpassword")); entry.removeAttributes("badId"); entry.removeAttributes((String) null); }
22. AddIT#testAddEntryNonExistingOC()
Project: directory-server
File: AddIT.java
File: AddIT.java
/** * Adding an entry with a non existing attribute type. * * @throws Exception */ @Test(expected = LdapOperationException.class) public void testAddEntryNonExistingOC() throws Exception { LdapConnection connection = getAdminConnection(getLdapServer()); Dn dn = new Dn("cn=Kate Bush," + BASE); Entry personEntry = new DefaultEntry(); personEntry.add(SchemaConstants.OBJECT_CLASS_AT, "nonexistingOC"); personEntry.add(SchemaConstants.CN_AT, "Kate Bush"); personEntry.add(SchemaConstants.SN_AT, "Bush"); personEntry.setDn(dn); connection.add(personEntry); }
23. AddIT#testAddEntryNonExistingOC()
Project: directory-server
File: AddIT.java
File: AddIT.java
/** * Adding an entry with a non existing attribute type. * * @throws Exception */ @Test(expected = LdapOperationException.class) public void testAddEntryNonExistingOC() throws Exception { LdapConnection connection = getAdminConnection(getLdapServer()); Dn dn = new Dn("cn=Kate Bush," + BASE); Entry personEntry = new DefaultEntry(); personEntry.add(SchemaConstants.OBJECT_CLASS_AT, "nonexistingOC"); personEntry.add(SchemaConstants.CN_AT, "Kate Bush"); personEntry.add(SchemaConstants.SN_AT, "Bush"); personEntry.setDn(dn); connection.add(personEntry); }
24. AttributesFactory#convert()
Project: directory-shared
File: AttributesFactory.java
File: AttributesFactory.java
/** * * @param matchingRule * @return Attributes * @throws LdapException */ public Entry convert(MatchingRule matchingRule, Schema schema, SchemaManager schemaManager) throws LdapException { Entry entry = new DefaultEntry(schemaManager); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_MATCHING_RULE_OC); entry.put(MetaSchemaConstants.M_SYNTAX_AT, matchingRule.getSyntaxOid()); entry.put(SchemaConstants.CREATORS_NAME_AT, schema.getOwner()); entry.put(SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime()); injectCommon(matchingRule, entry, schemaManager); return entry; }
25. AddIT#test_DIRSERVER_2109_2()
Project: directory-server
File: AddIT.java
File: AddIT.java
/** * Test for DIRSERVER-2109. */ @Test @Ignore public void test_DIRSERVER_2109_2() throws Exception { Entry entry = new DefaultEntry(new Dn("cn=a\\\\b,ou=users,ou=system")); entry.add("objectClass", "top", "person"); entry.add("cn", "a\\b"); entry.add("sn", "test"); LdapConnection connection = IntegrationUtils.getAdminConnection(getService()); connection.add(entry); entry = connection.lookup(entry.getDn(), SchemaConstants.ALL_USER_ATTRIBUTES); System.out.println(entry); assertEquals(1, entry.get("cn").size()); assertEquals("a\\b", entry.get("cn").get().getString()); }
26. DefaultSchemaLoader#getEntry()
Project: directory-shared
File: DefaultSchemaLoader.java
File: DefaultSchemaLoader.java
private Entry getEntry(NormalizerDescription normalizerDescription) { Entry entry = new DefaultEntry(); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC); entry.put(MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn()); if (normalizerDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(normalizerDescription.getBytecode().toCharArray())); } if (normalizerDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription()); } return entry; }
27. DefaultSchemaLoader#getEntry()
Project: directory-shared
File: DefaultSchemaLoader.java
File: DefaultSchemaLoader.java
private Entry getEntry(SyntaxCheckerDescription syntaxCheckerDescription) { Entry entry = new DefaultEntry(); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC); entry.put(MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn()); if (syntaxCheckerDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(syntaxCheckerDescription.getBytecode().toCharArray())); } if (syntaxCheckerDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription()); } return entry; }
28. DefaultSchemaLoader#getEntry()
Project: directory-shared
File: DefaultSchemaLoader.java
File: DefaultSchemaLoader.java
private Entry getEntry(LdapComparatorDescription comparatorDescription) { Entry entry = new DefaultEntry(); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC); entry.put(MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn()); if (comparatorDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(comparatorDescription.getBytecode().toCharArray())); } if (comparatorDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription()); } return entry; }
29. SchemaAwareEntryTest#testClear()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for clear() */ @Test public void testClear() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); entry.clear(); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); entry.add("ObjectClass", "top", "person"); assertEquals(1, entry.size()); assertNotNull(entry.get("ObjectClass")); entry.clear(); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); }
30. SchemaAwareEntrySerializationTest#testEntryNoAttributesNoDnSerialization()
Project: directory-shared
File: SchemaAwareEntrySerializationTest.java
File: SchemaAwareEntrySerializationTest.java
@Test public void testEntryNoAttributesNoDnSerialization() throws IOException, LdapException, ClassNotFoundException { Entry entry1 = new DefaultEntry(schemaManager, ""); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); entry1.writeExternal(out); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Entry entry2 = new DefaultEntry(schemaManager); entry2.readExternal(in); assertEquals(entry1, entry2); assertEquals(0, entry2.size()); }
31. SchemaAwareEntrySerializationTest#testEntryNoAttributesSerialization()
Project: directory-shared
File: SchemaAwareEntrySerializationTest.java
File: SchemaAwareEntrySerializationTest.java
@Test public void testEntryNoAttributesSerialization() throws IOException, LdapException, ClassNotFoundException { Entry entry1 = new DefaultEntry(schemaManager, "dc=example, dc=com"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); entry1.writeExternal(out); ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream(new ByteArrayInputStream(data)); Entry entry2 = new DefaultEntry(schemaManager); entry2.readExternal(in); assertEquals(entry1, entry2); assertEquals(0, entry2.size()); }
32. ClientModifyRequestTest#testModifyWithEntry()
Project: directory-server
File: ClientModifyRequestTest.java
File: ClientModifyRequestTest.java
@Test public void testModifyWithEntry() throws Exception { Dn dn = new Dn("uid=admin,ou=system"); Entry entry = new DefaultEntry(dn); String expectedSn = String.valueOf(System.currentTimeMillis()); String expectedCn = String.valueOf(System.currentTimeMillis()); entry.add(SchemaConstants.SN_AT, expectedSn); entry.add(SchemaConstants.CN_AT, expectedCn); connection.modify(entry, ModificationOperation.REPLACE_ATTRIBUTE); Entry lookupEntry = session.lookup(dn); String actualSn = lookupEntry.get(SchemaConstants.SN_AT).getString(); assertEquals(expectedSn, actualSn); String actualCn = lookupEntry.get(SchemaConstants.CN_AT).getString(); assertEquals(expectedCn, actualCn); }
33. ClientModifyDnRequestTest#testMoveAndRename()
Project: directory-server
File: ClientModifyDnRequestTest.java
File: ClientModifyDnRequestTest.java
@Test public void testMoveAndRename() throws Exception { Dn origDn = new Dn("cn=testadd,ou=users,ou=system"); Entry entry = new DefaultEntry(origDn); entry.add(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC); entry.add(SchemaConstants.CN_AT, "testadd"); entry.add(SchemaConstants.SN_AT, "testadd_sn"); connection.add(entry); Dn newDn = new Dn("cn=testaddMovedAndRenamed,ou=system"); connection.moveAndRename(origDn, newDn); assertFalse(session.exists(origDn)); entry = session.lookup(newDn, "+"); assertTrue(entry.containsAttribute(SchemaConstants.MODIFIERS_NAME_AT)); assertTrue(entry.containsAttribute(SchemaConstants.MODIFY_TIMESTAMP_AT)); }
34. ClientAddRequestTest#testAddAsync()
Project: directory-server
File: ClientAddRequestTest.java
File: ClientAddRequestTest.java
@Test public void testAddAsync() throws Exception { Dn dn = new Dn("cn=testAsyncAdd,ou=system"); Entry entry = new DefaultEntry(dn); entry.add(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC); entry.add(SchemaConstants.CN_AT, "testAsyncAdd_cn"); entry.add(SchemaConstants.SN_AT, "testAsyncAdd_sn"); assertFalse(session.exists(dn)); AddRequest addRequest = new AddRequestImpl(); addRequest.setEntry(entry); AddFuture addFuture = connection.addAsync(addRequest); AddResponse addResponse = addFuture.get(1000, TimeUnit.MILLISECONDS); assertNotNull(addResponse); assertEquals(ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode()); assertTrue(connection.isAuthenticated()); assertTrue(session.exists(dn)); }
35. SchemaSubentryModifier#getEntry()
Project: directory-server
File: SchemaSubentryModifier.java
File: SchemaSubentryModifier.java
private Entry getEntry(Dn dn, SyntaxCheckerDescription syntaxCheckerDescription) { Entry entry = new DefaultEntry(schemaManager, dn); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC); entry.put(MetaSchemaConstants.M_OID_AT, syntaxCheckerDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, syntaxCheckerDescription.getFqcn()); if (syntaxCheckerDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(syntaxCheckerDescription.getBytecode().toCharArray())); } if (syntaxCheckerDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription()); } return entry; }
36. SchemaSubentryModifier#getEntry()
Project: directory-server
File: SchemaSubentryModifier.java
File: SchemaSubentryModifier.java
private Entry getEntry(Dn dn, NormalizerDescription normalizerDescription) { Entry entry = new DefaultEntry(schemaManager, dn); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC); entry.put(MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn()); if (normalizerDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(normalizerDescription.getBytecode().toCharArray())); } if (normalizerDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription()); } return entry; }
37. SchemaSubentryModifier#getEntry()
Project: directory-server
File: SchemaSubentryModifier.java
File: SchemaSubentryModifier.java
private Entry getEntry(Dn dn, LdapComparatorDescription comparatorDescription) { Entry entry = new DefaultEntry(schemaManager, dn); entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC); entry.put(MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid()); entry.put(MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn()); if (comparatorDescription.getBytecode() != null) { entry.put(MetaSchemaConstants.M_BYTECODE_AT, Base64.decode(comparatorDescription.getBytecode().toCharArray())); } if (comparatorDescription.getDescription() != null) { entry.put(MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription()); } return entry; }
38. SchemaAwareEntryTest#testContainsEntryAttributeArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test for method contains( EntryAttribute... ) */ @Test public void testContainsEntryAttributeArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); assertFalse(entry.contains(attrOC, attrCN)); entry.add(attrOC, attrCN); assertTrue(entry.contains(attrOC, attrCN)); assertFalse(entry.contains(attrOC, attrCN, attrSN)); entry.add(attrSN, attrPWD); assertTrue(entry.contains(attrSN, attrPWD)); assertFalse(entry.contains((Attribute) null)); entry.clear(); assertTrue(entry.contains((Attribute) null)); }
39. SchemaAwareEntryTest#testClear()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for clear() */ @Test public void testClear() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); entry.clear(); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); entry.add("ObjectClass", "top", "person"); assertEquals(1, entry.size()); assertNotNull(entry.get("ObjectClass")); entry.clear(); assertEquals(0, entry.size()); assertNull(entry.get("ObjectClass")); }
40. SchemaAwareEntryTest#testAddAttributeTypeStringArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for add( AttributeType, String... ) */ @Test public void testAddAttributeTypeStringArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); entry.add(atC, "us", "fr"); assertEquals(1, entry.size()); assertFalse(entry.contains(atC, "fr", "us")); entry.add(atC, "de", "fr"); assertEquals(1, entry.size()); Attribute attribute = entry.get(atC); assertEquals(0, attribute.size()); assertFalse(attribute.contains("de")); assertFalse(attribute.contains("fr")); assertFalse(attribute.contains("us")); entry.clear(); assertEquals(0, entry.size()); }
41. ServerEntrySerializerTest#testSerializeServerEntryWithAttributeBinaryValue()
Project: directory-server
File: ServerEntrySerializerTest.java
File: ServerEntrySerializerTest.java
@Test public void testSerializeServerEntryWithAttributeBinaryValue() throws Exception { Entry entry = new DefaultEntry(schemaManager); EntrySerializer ses = new EntrySerializer(schemaManager); entry.add("userPassword", Strings.getBytesUtf8("secret")); byte[] data = ses.serialize(entry); Entry result = (Entry) ses.deserialize(data); assertEquals(entry, result); }
42. ServerEntrySerializerTest#testSerializeServerEntryWithAttributeStringValue()
Project: directory-server
File: ServerEntrySerializerTest.java
File: ServerEntrySerializerTest.java
@Test public void testSerializeServerEntryWithAttributeStringValue() throws Exception { Entry entry = new DefaultEntry(schemaManager); EntrySerializer ses = new EntrySerializer(schemaManager); entry.add("ObjectClass", "top", "person"); byte[] data = ses.serialize(entry); Entry result = (Entry) ses.deserialize(data); assertEquals(entry, result); }
43. ServerEntrySerializerTest#testSerializeServerEntryWithAttributeNoValue()
Project: directory-server
File: ServerEntrySerializerTest.java
File: ServerEntrySerializerTest.java
@Test public void testSerializeServerEntryWithAttributeNoValue() throws Exception { Entry entry = new DefaultEntry(schemaManager); EntrySerializer ses = new EntrySerializer(schemaManager); Attribute oc = new DefaultAttribute("ObjectClass", schemaManager.lookupAttributeTypeRegistry("objectclass")); entry.add(oc); byte[] data = ses.serialize(entry); Entry result = (Entry) ses.deserialize(data); assertEquals(entry, result); }
44. AttributeUtilsTest#testApplyModifyModificationRemoveAttribute()
Project: directory-shared
File: AttributeUtilsTest.java
File: AttributeUtilsTest.java
/** * Test the removing by modification of an existing attribute in an . * * @throws LdapException */ @Test public void testApplyModifyModificationRemoveAttribute() throws LdapException { Entry entry = new DefaultEntry(); entry.put("cn", "test"); entry.put("ou", "apache", "acme corp"); Attribute newOu = new DefaultAttribute("ou"); Modification modification = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, newOu); AttributeUtils.applyModification(entry, modification); assertEquals(1, entry.size()); assertNotNull(entry.get("cn")); assertNull(entry.get("ou")); }
45. SchemaAwareEntryTest#testRemoveStringByteArrayArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for remove(String, byte[]... ) */ @Test public void testRemoveStringByteArrayArray() throws LdapException { Entry entry = new DefaultEntry(exampleDn); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, (byte[]) null, BYTES2); entry.put(attrPWD); assertTrue(entry.remove("userPassword", (byte[]) null)); assertTrue(entry.remove("userPassword", BYTES1, BYTES2)); assertFalse(entry.containsAttribute("userPassword")); entry.add("userPassword", BYTES1, (byte[]) null, BYTES2); assertTrue(entry.remove("userPassword", (byte[]) null)); assertEquals(2, entry.get("userPassword").size()); assertTrue(entry.remove("userPassword", BYTES1, BYTES3)); assertEquals(1, entry.get("userPassword").size()); assertTrue(Arrays.equals(BYTES2, entry.get("userPassword").getBytes())); assertFalse(entry.remove("userPassword", BYTES3)); assertFalse(entry.remove("void", "whatever")); }
46. SchemaAwareEntryTest#testContainsEntryAttributeArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for contains( EntryAttribute... ) */ @Test public void testContainsEntryAttributeArray() throws LdapException { Entry entry = new DefaultEntry(exampleDn); Attribute attrOC = new DefaultAttribute("objectClass", "top", "person"); Attribute attrCN = new DefaultAttribute("cn", "test1", "test2"); Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2); assertFalse(entry.contains(attrOC, attrCN)); entry.add(attrOC, attrCN); assertTrue(entry.contains(attrOC, attrCN)); assertFalse(entry.contains(attrOC, attrCN, attrSN)); entry.add(attrSN, attrPWD); assertTrue(entry.contains(attrSN, attrPWD)); }
47. SchemaAwareEntryTest#testAddStringStringArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for add( String, String... ) */ @Test public void testAddStringStringArray() throws LdapException { Entry entry = new DefaultEntry(); entry.add("cn", (String) null); assertEquals(1, entry.size()); Attribute attributeCN = entry.get("cn"); assertEquals(1, attributeCN.size()); assertNotNull(attributeCN.get()); assertNull(attributeCN.get().getValue()); entry.add("sn", "test", "test", "TEST"); assertEquals(2, entry.size()); Attribute attributeSN = entry.get("sn"); assertEquals(2, attributeSN.size()); assertNotNull(attributeSN.get()); assertTrue(attributeSN.contains("test")); assertTrue(attributeSN.contains("TEST")); }
48. SchemaAwareEntryTest#testAddStringByteArrayArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for add( String, byte[]... ) */ @Test public void testAddStringByteArrayArray() throws LdapException { Entry entry = new DefaultEntry(); entry.add("userPassword", (byte[]) null); assertEquals(1, entry.size()); Attribute attributePWD = entry.get("userPassword"); assertEquals(1, attributePWD.size()); assertNotNull(attributePWD.get()); assertNull(attributePWD.get().getValue()); entry.add("jpegPhoto", BYTES1, BYTES1, BYTES2); assertEquals(2, entry.size()); Attribute attributeJPG = entry.get("jpegPhoto"); assertEquals(2, attributeJPG.size()); assertNotNull(attributeJPG.get()); assertTrue(attributeJPG.contains(BYTES1)); assertTrue(attributeJPG.contains(BYTES2)); }
49. ApacheDS#addFileEntry()
Project: directory-server
File: ApacheDS.java
File: ApacheDS.java
private void addFileEntry(File ldif) throws Exception { String rdnAttr = File.separatorChar == '\\' ? ApacheSchemaConstants.WINDOWS_FILE_AT : ApacheSchemaConstants.UNIX_FILE_AT; String oc = File.separatorChar == '\\' ? ApacheSchemaConstants.WINDOWS_FILE_OC : ApacheSchemaConstants.UNIX_FILE_OC; Entry entry = directoryService.newEntry(buildProtectedFileEntryDn(ldif)); entry.add(rdnAttr, getCanonical(ldif)); entry.add(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, oc); directoryService.getAdminSession().add(entry); }
50. SchemaAwareEntryTest#testRemoveAttributesAttributeTypeArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for removeAttributes( AttributeType... ) */ @Test public void testRemoveAttributesAttributeTypeArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); entry.put(attrOC, attrCN, attrSN, attrPWD); entry.removeAttributes(atCN, atSN); assertFalse(entry.containsAttribute("cn", "sn")); assertTrue(entry.containsAttribute("objectclass", "userpassword")); }
51. SchemaAwareEntryTest#testRemoveAttributeTypeStringArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for remove( AttributeType, String... ) */ @Test public void testRemoveAttributeTypeStringArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrCN = new DefaultAttribute(atEMail, "test1", (String) null, "test2"); entry.put(attrCN); assertTrue(entry.remove(atEMail, (String) null)); assertTrue(entry.remove(atEMail, "test1", "test2")); assertFalse(entry.containsAttribute(atEMail)); entry.add(atEMail, "test1", (String) null, "test2"); assertTrue(entry.remove(atEMail, (String) null)); assertEquals(2, entry.get(atEMail).size()); assertFalse(entry.contains(atEMail, (String) null)); assertTrue(entry.remove(atEMail, "test1", "test3")); assertEquals(1, entry.get(atEMail).size()); assertTrue(entry.contains(atEMail, "test2")); assertFalse(entry.contains(atEMail, "test1")); assertFalse(entry.remove(atEMail, "test3")); assertFalse(entry.remove(atEMail, "test")); }
52. SchemaAwareEntryTest#testRemoveAttributeTypeByteArrayArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
//------------------------------------------------------------------------- // Test the Remove methods //------------------------------------------------------------------------- /** * Test method for remove( AttributeType, byte[]... ) */ @Test public void testRemoveAttributeTypeByteArrayArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, (byte[]) null, BYTES2); entry.put(attrPWD); assertTrue(entry.remove(atPwd, (byte[]) null)); assertTrue(entry.remove(atPwd, BYTES1, BYTES2)); assertFalse(entry.containsAttribute(atPwd)); entry.add(atPwd, BYTES1, (byte[]) null, BYTES2); assertTrue(entry.remove(atPwd, (byte[]) null)); assertEquals(2, entry.get(atPwd).size()); assertFalse(entry.contains(atPwd, (byte[]) null)); assertTrue(entry.remove(atPwd, BYTES1, BYTES3)); assertEquals(1, entry.get(atPwd).size()); assertTrue(entry.contains(atPwd, BYTES2)); assertFalse(entry.contains(atPwd, BYTES1)); assertFalse(entry.remove(atPwd, BYTES3)); assertFalse(entry.remove(atPwd, new byte[] { 0x00 })); }
53. SchemaAwareEntryTest#testContainsAttributeString()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for containsAttribute( String ) */ @Test public void testContainsAttributeString() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.containsAttribute("objectClass")); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); entry.add(attrOC, attrCN, attrSN, attrPWD); assertTrue(entry.containsAttribute("OBJECTCLASS", " cn ", "Sn", " userPASSWORD ")); entry.clear(); assertFalse(entry.containsAttribute("OBJECTCLASS")); assertFalse(entry.containsAttribute(" cn ")); assertFalse(entry.containsAttribute("Sn")); assertFalse(entry.containsAttribute(" userPASSWORD ")); assertFalse(entry.containsAttribute(" userASSWORD ")); }
54. SchemaAwareEntryTest#testAddAttributeTypeByteArrayArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for add( AttributeType, byte[]... ) */ @Test public void testAddAttributeTypeByteArrayArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); entry.add(atPwd, BYTES1, BYTES2); assertEquals(1, entry.size()); assertTrue(entry.contains(atPwd, BYTES1, BYTES2)); entry.add(atPwd, (byte[]) null, BYTES1); assertEquals(1, entry.size()); Attribute attribute = entry.get(atPwd); assertEquals(3, attribute.size()); assertTrue(attribute.contains(BYTES1)); assertTrue(attribute.contains(BYTES2)); assertTrue(attribute.contains((byte[]) null)); }
55. ClonedServerEntryTest#initNames()
Project: directory-server
File: ClonedServerEntryTest.java
File: ClonedServerEntryTest.java
/** * Initialize name instances */ @BeforeClass public static void initNames() throws Exception { Entry eA = new DefaultEntry("dc=example,dc=com"); Entry eB = new DefaultEntry("dc=example,dc=com"); Entry eC = new DefaultEntry("dc=test,dc=org"); clonedServerEntryA = new ClonedServerEntry(); clonedServerEntryACopy = new ClonedServerEntry(); clonedServerEntryB = new ClonedServerEntry(); clonedServerEntryA1 = new ClonedServerEntry(eA); clonedServerEntryACopy1 = new ClonedServerEntry(eA); clonedServerEntryB1 = new ClonedServerEntry(eB); clonedServerEntryC1 = new ClonedServerEntry(eC); }
56. SchemaAwareEntryTest#testSerializeEntryWithNoAttribute()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test the serialization of an entry with no attribute */ @Test public void testSerializeEntryWithNoAttribute() throws LdapException, IOException, ClassNotFoundException { Dn dn = new Dn("ou=system"); dn.apply(schemaManager); Entry entry = new DefaultEntry(dn); Entry entrySer = deserializeValue(serializeValue(entry)); assertEquals(entry, entrySer); }
57. SchemaAwareEntryTest#testRemoveStringStringArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for remove( String, String... ) */ @Test public void testRemoveStringStringArray() throws LdapException { Entry entry = createEntry(); assertTrue(entry.remove("cn", "test1")); assertTrue(entry.remove("cn", "test2")); assertFalse(entry.containsAttribute("cn")); entry.add("cn", "test1", (String) null, "test2"); assertTrue(entry.remove("cn", (String) null)); assertEquals(2, entry.get("cn").size()); assertTrue(entry.remove("cn", "test1", "test3")); assertEquals(1, entry.get("cn").size()); assertEquals("test2", entry.get("cn").get().getString()); assertFalse(entry.remove("cn", "test3")); assertFalse(entry.remove("void", "whatever")); }
58. SchemaAwareEntryTest#testHasObjectClass()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for hasObjectClass( String ) */ @Test public void testHasObjectClass() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertFalse(entry.containsAttribute("objectClass")); assertFalse(entry.hasObjectClass("top")); entry.add(new DefaultAttribute("objectClass", "top", "person")); assertTrue(entry.hasObjectClass("top")); assertTrue(entry.hasObjectClass("person")); assertFalse(entry.hasObjectClass("inetorgperson")); assertFalse(entry.hasObjectClass((String) null)); assertFalse(entry.hasObjectClass("")); }
59. SchemaAwareEntryTest#testGetDn()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for getDN() */ @Test public void testGetDn() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertEquals(exampleDn, entry.getDn()); Dn testDn = new Dn("cn=test"); entry.setDn(testDn); assertEquals(testDn, entry.getDn()); }
60. SchemaAwareEntryTest#testGet()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for get( String ) */ @Test public void testGet() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertNull(entry.get("objectClass")); Attribute attrOC = new DefaultAttribute("objectClass", "top", "person"); Attribute attrCN = new DefaultAttribute("cn", "test1", "test2"); Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2); entry.add(attrOC, attrCN, attrSN, attrPWD); assertNotNull(entry.get(" CN ")); Attribute attribute = entry.get("cN"); assertEquals(attribute, attrCN); assertNull(entry.get((String) null)); assertNull(entry.get(" ")); assertNull(entry.get("l")); }
61. SchemaAwareEntryTest#testContainsStringStringArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for contains( String, String... ) */ @Test public void testContainsStringStringArray() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertFalse(entry.containsAttribute("objectClass")); Attribute attrOC = new DefaultAttribute("objectClass", "top", "person"); Attribute attrCN = new DefaultAttribute("cn", "test1", "test2"); Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2", (String) null); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2); entry.add(attrOC, attrCN, attrSN, attrPWD); assertTrue(entry.contains("OBJECTCLASS", "top", "person")); assertTrue(entry.contains(" cn ", "test1", "test2")); assertTrue(entry.contains("Sn", "Test1", "Test2", (String) null)); assertTrue(entry.contains(" userPASSWORD ", "ab", "b")); assertFalse(entry.contains("OBJECTCLASS", "PERSON")); assertFalse(entry.contains(" cn ", "test1", "test3")); assertFalse(entry.contains("Sn", "Test")); assertFalse(entry.contains(" userPASSWORD ", (String) null)); }
62. SchemaAwareEntryTest#testContainsStringByteArray()
Project: directory-shared
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for contains( String, byte[]... ) */ @Test public void testContainsStringByteArray() throws LdapException { Entry entry = new DefaultEntry(exampleDn); assertFalse(entry.containsAttribute("objectClass")); Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, (byte[]) null, BYTES2); entry.add(attrPWD); assertTrue(entry.contains(" userPASSWORD ", BYTES1, BYTES2)); assertTrue(entry.contains(" userPASSWORD ", (byte[]) null)); // We can search for byte[] using Strings. the strings will be converted to byte[] assertTrue(entry.contains(" userPASSWORD ", "ab", "b")); assertFalse(entry.contains(" userPASSWORD ", "ab", "b", "d")); }
63. ClientServerReplicationIT#compareEntries()
Project: directory-server
File: ClientServerReplicationIT.java
File: ClientServerReplicationIT.java
private void compareEntries(Dn dn) throws Exception { String[] searchAttributes = new String[] { SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ENTRY_UUID_AT }; Entry providerEntry = providerSession.lookup(dn, searchAttributes); Entry consumerEntry = consumerSession.lookup(dn, searchAttributes); assertEquals(providerEntry, consumerEntry); }
64. PasswordPolicyIT#addUser()
Project: directory-server
File: PasswordPolicyIT.java
File: PasswordPolicyIT.java
/** * Add a user with a password */ private Dn addUser(LdapConnection adminConnection, String user, Object password) throws Exception { Entry userEntry = new DefaultEntry("cn=" + user + ",ou=system", "ObjectClass: top", "ObjectClass: person", "cn", user, "sn", user + "_sn", "userPassword", password); AddRequest addRequest = new AddRequestImpl(); addRequest.setEntry(userEntry); addRequest.addControl(PP_REQ_CTRL); AddResponse addResp = adminConnection.add(addRequest); assertEquals(ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode()); PasswordPolicy respCtrl = getPwdRespCtrl(addResp); assertNull(respCtrl); return userEntry.getDn(); }
65. AutzIntegUtils#createUser()
Project: directory-server
File: AutzIntegUtils.java
File: AutzIntegUtils.java
/** * Creates a simple user as an inetOrgPerson under the ou=users,ou=system * container. The user's Rdn attribute is the uid argument. This argument * is also used as the value of the two MUST attributes: sn and cn. * * @param uid the value of the Rdn attriubte (uid), the sn and cn attributes * @param password the password to use to create the user * @return the dn of the newly created user entry * @throws Exception if there are problems creating the user entry */ public static Dn createUser(String uid, String password) throws Exception { LdapConnection connection = getAdminConnection(); Entry entry = new DefaultEntry(service.getSchemaManager(), "uid=" + uid + ",ou=users,ou=system", "uid", uid, "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "sn", uid, "cn", uid, "userPassword", password); connection.add(entry); assertTrue(connection.exists(entry.getDn())); return entry.getDn(); }
66. AdministrativePointServiceIT#testModifyDeleteSomeRole()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the deletion of some role * @throws Exception */ @Test public void testModifyDeleteSomeRole() throws Exception { // Inject an CASA Entry caArea = new DefaultEntry("ou=caArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: caArea", "administrativeRole: collectiveAttributeSpecificArea", "administrativeRole: accessControlSpecificArea"); connection.add(caArea); // Add another specific area Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute("administrativeRole", "accessControlSpecificArea")); connection.modify("ou=caArea, ou=system", modification); Entry entry = getAdminRole("ou=caArea, ou=system"); assertTrue(entry.containsAttribute("administrativeRole")); assertTrue(entry.contains("administrativeRole", "collectiveAttributeSpecificArea")); assertFalse(entry.contains("administrativeRole", "accessControlSpecificArea")); }
67. AdministrativePointServiceIT#testModifyDeleteAll2()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the deletion of all the roles * @throws Exception */ @Test public void testModifyDeleteAll2() throws Exception { // Inject an CASA Entry caArea = new DefaultEntry("ou=caArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: caArea", "administrativeRole: collectiveAttributeSpecificArea", "administrativeRole: accessControlSpecificArea"); connection.add(caArea); // Add another specific area Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute("administrativeRole", "collectiveAttributeSpecificArea", "accessControlSpecificArea")); connection.modify("ou=caArea, ou=system", modification); Entry entry = getAdminRole("ou=caArea, ou=system"); assertFalse(entry.containsAttribute("administrativeRole")); }
68. AdministrativePointServiceIT#testModifyDeleteAll()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the deletion of all the roles * @throws Exception */ @Test public void testModifyDeleteAll() throws Exception { // Inject an CASA Entry caArea = new DefaultEntry("ou=caArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: caArea", "administrativeRole: collectiveAttributeSpecificArea", "administrativeRole: accessControlSpecificArea"); connection.add(caArea); // Add another specific area Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, new DefaultAttribute("administrativeRole")); connection.modify("ou=caArea, ou=system", modification); Entry entry = getAdminRole("ou=caArea, ou=system"); assertFalse(entry.containsAttribute("administrativeRole")); }
69. AdministrativePointServiceIT#testModifyAddInnerArea()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the addition of a ACIA to a CASA * @throws Exception */ @Test public void testModifyAddInnerArea() throws Exception { // Inject an CASA Entry caArea = new DefaultEntry("ou=caArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: caArea", "administrativeRole: collectiveAttributeSpecificArea"); connection.add(caArea); // Add another specific area Modification modification = new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute("administrativeRole", "accessControlInnerArea")); connection.modify("ou=caArea, ou=system", modification); Entry entry = getAdminRole("ou=caArea, ou=system"); assertTrue(entry.contains("administrativeRole", "collectiveAttributeSpecificArea")); assertTrue(entry.contains("administrativeRole", "accessControlInnerArea")); }
70. AdministrativePointServiceIT#testModifyAddSpecificArea()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
// ------------------------------------------------------------------- // Test the Modify operation // ------------------------------------------------------------------- /** * Test the addition of a ACSA to a CASA * @throws Exception */ @Test public void testModifyAddSpecificArea() throws Exception { // Inject an CASA Entry caArea = new DefaultEntry("ou=caArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: caArea", "administrativeRole: collectiveAttributeSpecificArea"); connection.add(caArea); // Add another specific area Modification modification = new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, new DefaultAttribute("administrativeRole", "accessControlSpecificArea")); connection.modify("ou=caArea, ou=system", modification); Entry entry = getAdminRole("ou=caArea, ou=system"); assertTrue(entry.contains("administrativeRole", "accessControlSpecificArea")); assertTrue(entry.contains("administrativeRole", "collectiveAttributeSpecificArea")); }
71. AdministrativePointServiceIT#testAddInnerAreas()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the addition of some inner area * @throws Exception */ @Test public void testAddInnerAreas() throws Exception { Entry autonomousArea = new DefaultEntry("ou=autonomousArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: autonomousArea", "administrativeRole: accessControlINNERArea", "administrativeRole: TRIGGEREXECUTIONINNERAREA"); connection.add(autonomousArea); assertTrue(connection.exists("ou=autonomousArea, ou=system")); // Check that the entry is containing all the roles Entry entry = getAdminRole("ou=autonomousArea, ou=system"); assertFalse(entry.contains("administrativeRole", "autonomousArea")); assertTrue(entry.contains("administrativeRole", "accessControlInnerArea")); assertTrue(entry.contains("administrativeRole", "triggerExecutionInnerArea")); }
72. AdministrativePointServiceIT#testAddSpecificAreas()
Project: directory-server
File: AdministrativePointServiceIT.java
File: AdministrativePointServiceIT.java
/** * Test the addition of some specific area * @throws Exception */ @Test public void testAddSpecificAreas() throws Exception { Entry autonomousArea = new DefaultEntry("ou=autonomousArea, ou=system", "ObjectClass: top", "ObjectClass: organizationalUnit", "ou: autonomousArea", "administrativeRole: accessControlSpecificArea", "administrativeRole: TRIGGEREXECUTIONSPECIFICAREA"); connection.add(autonomousArea); assertTrue(connection.exists("ou=autonomousArea, ou=system")); // Check that the entry is containing all the roles Entry entry = getAdminRole("ou=autonomousArea, ou=system"); assertFalse(entry.contains("administrativeRole", "autonomousArea")); assertTrue(entry.contains("administrativeRole", "accessControlSpecificArea")); assertFalse(entry.contains("administrativeRole", "collectiveAttributeSpecificArea")); assertFalse(entry.contains("administrativeRole", "2.5.23.4")); assertTrue(entry.contains("administrativeRole", "triggerExecutionSpecificArea")); }
73. SchemaAwareEntryTest#testHasObjectClassString()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for hasObjectClass( String ) */ @Test public void testHasObjectClassString() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.containsAttribute("objectClass")); assertFalse(entry.hasObjectClass("top")); entry.add(new DefaultAttribute(atOC, "top", "person")); assertTrue(entry.hasObjectClass("top")); assertTrue(entry.hasObjectClass("person")); assertFalse(entry.hasObjectClass("inetorgperson")); assertFalse(entry.hasObjectClass((String) null)); assertFalse(entry.hasObjectClass("")); }
74. SchemaAwareEntryTest#testHasObjectClassEntryAttribute()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for hasObjectClass( EntryAttribute ) */ @Test public void testHasObjectClassEntryAttribute() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); assertFalse(entry.contains(attrOC)); assertFalse(entry.hasObjectClass(attrOC)); entry.add(attrOC); assertTrue(entry.hasObjectClass(attrOC)); Attribute attrOC2 = new DefaultAttribute(atOC, "person"); assertTrue(entry.hasObjectClass(attrOC2)); Attribute attrOC3 = new DefaultAttribute(atOC, "inetOrgPerson"); assertFalse(entry.hasObjectClass(attrOC3)); assertFalse(entry.hasObjectClass((Attribute) null)); Attribute attrCN = new DefaultAttribute(atCN, "top"); assertFalse(entry.hasObjectClass(attrCN)); }
75. SchemaAwareEntryTest#testGetDn()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for getDN() */ @Test public void testGetDn() throws LdapInvalidDnException { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertEquals(EXAMPLE_DN, entry.getDn()); Dn testDn = new Dn(schemaManager, "cn=test"); entry.setDn(testDn); assertEquals(testDn, entry.getDn()); }
76. SchemaAwareEntryTest#testGetString()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for get( String ) */ @Test public void testGetString() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertNull(entry.get("cn")); assertNull(entry.get("badId")); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); entry.add(attrOC, attrCN, attrSN, attrPWD); assertNotNull(entry.get("CN")); assertNotNull(entry.get(" commonName ")); assertNotNull(entry.get("2.5.4.3")); assertEquals(attrCN, entry.get("2.5.4.3")); assertEquals(attrOC, entry.get(" OBJECTCLASS")); assertEquals(attrSN, entry.get("sn")); assertEquals(attrPWD, entry.get(" userPassword ")); }
77. SchemaAwareEntryTest#testGetAttributeType()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test method for get( AttributeType ) */ @Test public void testGetAttributeType() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertNull(entry.get(atCN)); assertNull(entry.get((AttributeType) null)); Attribute attrOC = new DefaultAttribute(atOC, "top", "person"); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); Attribute attrSN = new DefaultAttribute(atSN, "Test1", "Test2"); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); entry.add(attrOC, attrCN, attrSN, attrPWD); assertNotNull(entry.get(atCN)); assertEquals(attrCN, entry.get(atCN)); assertEquals(attrOC, entry.get(atOC)); assertEquals(attrSN, entry.get(atSN)); assertEquals(attrPWD, entry.get(atPwd)); }
78. SchemaAwareEntryTest#testContainsStringStringArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test for method contains( String, String... ) */ @Test public void testContainsStringStringArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.contains((String) null, "test")); assertFalse(entry.containsAttribute("objectClass")); Attribute attrEMail = new DefaultAttribute(atEMail, "test1", (String) null, "test2"); entry.add(attrEMail); assertTrue(entry.contains(" EMAIL ", "test1", "test2")); assertTrue(entry.contains(" EMAIL ", (String) null)); assertFalse(entry.contains(" EMAIL ", BYTES1, BYTES2)); assertFalse(entry.contains(" EMAIL ", "test3")); assertFalse(entry.contains(" EMMAIL ", "test3")); }
79. SchemaAwareEntryTest#testContainsStringByteArrayArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test for method contains( String, byte[]... ) */ @Test public void testContainsStringByteArrayArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.contains((String) null, BYTES3)); assertFalse(entry.containsAttribute("objectClass")); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, (byte[]) null, BYTES2); entry.add(attrPWD); assertTrue(entry.contains(" userPASSWORD ", BYTES1, BYTES2)); assertTrue(entry.contains(" userPASSWORD ", (byte[]) null)); assertFalse(entry.contains(" userPASSWORD ", "ab", "b")); assertFalse(entry.contains(" userPASSWORD ", BYTES3)); assertFalse(entry.contains(" userASSWORD ", BYTES3)); }
80. SchemaAwareEntryTest#testContainsAttributeTypeStringArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
/** * Test for method contains( AttributeType, String... ) */ @Test public void testContainsAttributeTypeStringArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.contains((AttributeType) null, "test")); assertFalse(entry.contains(atCN, "test")); Attribute attrCN = new DefaultAttribute(atCN, "test1", "test2"); assertFalse(entry.contains(attrCN)); entry.add(attrCN); assertTrue(entry.contains(atCN, "test1", "test2")); assertFalse(entry.contains(atCN, "test1", "test2", "test3")); assertFalse(entry.contains(atCN, BYTES1)); }
81. SchemaAwareEntryTest#testContainsAttributeTypeByteArrayArray()
Project: directory-server
File: SchemaAwareEntryTest.java
File: SchemaAwareEntryTest.java
//------------------------------------------------------------------------- // Test the Contains methods //------------------------------------------------------------------------- /** * Test for method contains( AttributeType, byte[]... ) */ @Test public void testContainsAttributeTypeByteArrayArray() throws Exception { Entry entry = new DefaultEntry(schemaManager, EXAMPLE_DN); assertFalse(entry.contains((AttributeType) null, BYTES1)); assertFalse(entry.contains(atPwd, BYTES1)); Attribute attrPWD = new DefaultAttribute(atPwd, BYTES1, BYTES2); assertFalse(entry.contains(attrPWD)); entry.add(attrPWD); assertTrue(entry.contains(atPwd, BYTES1, BYTES2)); assertFalse(entry.contains(atPwd, BYTES1, BYTES2, BYTES3)); assertFalse(entry.contains(atPwd, "ab")); }
82. MatchingRuleSynchronizer#rename()
Project: directory-server
File: MatchingRuleSynchronizer.java
File: MatchingRuleSynchronizer.java
/** * {@inheritDoc} */ public void rename(Entry entry, Rdn newRdn, boolean cascade) throws LdapException { String schemaName = getSchemaName(entry.getDn()); MatchingRule oldMr = factory.getMatchingRule(schemaManager, entry, schemaManager.getRegistries(), schemaName); Entry targetEntry = (Entry) entry.clone(); String newOid = newRdn.getNormValue(); checkOidIsUnique(newOid); targetEntry.put(MetaSchemaConstants.M_OID_AT, newOid); MatchingRule mr = factory.getMatchingRule(schemaManager, targetEntry, schemaManager.getRegistries(), schemaName); if (isSchemaEnabled(schemaName)) { schemaManager.unregisterMatchingRule(oldMr.getOid()); schemaManager.add(mr); } else { unregisterOids(oldMr); registerOids(mr); } }
83. AttributeUtilsTest#testApplyRemoveModificationFromEntrySameAttributeSameValue()
Project: directory-shared
File: AttributeUtilsTest.java
File: AttributeUtilsTest.java
/** * Test the deletion of an attribute into an entry which contains the attribute. * * The entry should not contain the attribute after the operation */ @Test public void testApplyRemoveModificationFromEntrySameAttributeSameValue() throws LdapException { Entry entry = new DefaultEntry(); entry.put("cn", "test"); Attribute attr = new DefaultAttribute("cn", "test"); Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, attr); AttributeUtils.applyModification(entry, modification); assertNull(entry.get("cn")); assertEquals(0, entry.size()); }
84. AttributeUtilsTest#testApplyRemoveModificationFromEntryAttributeNotSameValue()
Project: directory-shared
File: AttributeUtilsTest.java
File: AttributeUtilsTest.java
/** * Test the deletion of an attribute into an entry which contains the attribute * but without the value to be deleted */ @Test public void testApplyRemoveModificationFromEntryAttributeNotSameValue() throws LdapException { Entry entry = new DefaultEntry(); Attribute cn = new DefaultAttribute("cn", "apache"); entry.put(cn); Attribute attr = new DefaultAttribute("cn", "test"); Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, attr); AttributeUtils.applyModification(entry, modification); assertNotNull(entry.get("cn")); assertEquals(1, entry.size()); assertEquals(cn, entry.get("cn")); }
85. AttributeUtilsTest#testApplyRemoveModificationFromEntryAttributeNotPresent()
Project: directory-shared
File: AttributeUtilsTest.java
File: AttributeUtilsTest.java
/** * Test the deletion of an attribute into an entry which does not contain the attribute */ @Test public void testApplyRemoveModificationFromEntryAttributeNotPresent() throws LdapException { Entry entry = new DefaultEntry(); Attribute dc = new DefaultAttribute("dc", "apache"); entry.put(dc); Attribute cn = new DefaultAttribute("cn", "test"); Modification modification = new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, cn); AttributeUtils.applyModification(entry, modification); assertNull(entry.get("cn")); assertNotNull(entry.get("dc")); assertEquals(1, entry.size()); assertEquals(dc, entry.get("dc")); }
86. AttributeUtilsTest#testApplyAddModificationToEntry()
Project: directory-shared
File: AttributeUtilsTest.java
File: AttributeUtilsTest.java
/** * Test a addModification applied to an entry */ @Test public void testApplyAddModificationToEntry() throws LdapException { Entry entry = new DefaultEntry(); entry.add("dc", "apache"); assertEquals(1, entry.size()); Attribute attr = new DefaultAttribute("cn", "test"); Modification modification = new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, attr); AttributeUtils.applyModification(entry, modification); assertNotNull(entry.get("cn")); assertEquals(2, entry.size()); assertEquals(attr, entry.get("cn")); }
87. SimpleBindIT#testSimpleBindNoPrincipalNoPassword()
Project: directory-server
File: SimpleBindIT.java
File: SimpleBindIT.java
/** * covers the anonymous authentication : we should be able to read the rootDSE, but that's it * * @throws Exception on error */ @Test public void testSimpleBindNoPrincipalNoPassword() throws LdapException, IOException { connection.bind((String) null, null); // We should be anonymous here. // Check that we can read the rootDSE Entry rootDse = connection.lookup(""); assertNotNull(rootDse); // Check that we cannot read another entry being anonymous Entry entry = connection.lookup("uid=admin,ou=system"); assertNull(entry); }
88. DIRSERVER169IT#testAddCasePreservedOnAttributeNames()
Project: directory-server
File: DIRSERVER169IT.java
File: DIRSERVER169IT.java
/** * Test that attribute name case is preserved after adding an entry * in the case the user added them. This is to test DIRSERVER-832. */ @Test public void testAddCasePreservedOnAttributeNames() throws Exception { LdapConnection sysRoot = getAdminConnection(getService()); Entry entry = new DefaultEntry("uID=kevin,ou=system", "ObjectClass: top", "ObjectClass: PERSON", "ObjectClass: organizationalPerson", "ObjectClass: inetORGperson", "Cn: Kevin Spacey", "sN: Spacey", "uID: kevin"); sysRoot.add(entry); Entry returned = sysRoot.lookup("uID=kevin,ou=system"); assertTrue(returned.containsAttribute("uID", "ObjectClass", "sN", "Cn")); }
89. AddIT#testAddNotNormalized()
Project: directory-server
File: AddIT.java
File: AddIT.java
/** * Test an add operation with a value that needs to be normalized */ @Test public void testAddNotNormalized() throws Exception { LdapConnection connection = IntegrationUtils.getAdminConnection(getService()); Dn dn = new Dn("cn=test,ou=system"); Entry entry = new DefaultEntry(dn, "ObjectClass: top", "ObjectClass: person", "sn: TEST ", "cn: test"); connection.add(entry); entry = connection.lookup(entry.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY); Entry contextEntry = connection.lookup("ou=system", SchemaConstants.ALL_ATTRIBUTES_ARRAY); String expectedCsn = entry.get(SchemaConstants.ENTRY_CSN_AT).getString(); String contextCsn = contextEntry.get(SchemaConstants.CONTEXT_CSN_AT).getString(); assertEquals(expectedCsn, contextCsn); }
90. CollectiveAttributeServiceIT#testPolymorphicReturnAttrLookup()
Project: directory-server
File: CollectiveAttributeServiceIT.java
File: CollectiveAttributeServiceIT.java
@Test public void testPolymorphicReturnAttrLookup() throws Exception { LdapConnection connection = IntegrationUtils.getAdminConnection(getService()); // ------------------------------------------------------------------- // Setup the collective attribute specific administration point // ------------------------------------------------------------------- addAdministrativeRole(connection, "collectiveAttributeSpecificArea"); Entry subentry = getTestSubentry("cn=testsubentry,ou=system"); connection.add(subentry); // request the collective attribute's super type specifically Entry entry = connection.lookup("ou=interceptors,ou=configuration,ou=system", "ou"); Attribute c_ou = entry.get("c-ou"); assertNotNull("a collective c-ou attribute should be present", c_ou); assertTrue(c_ou.contains("configuration")); connection.close(); }
91. MavibotStoreTest#testRename()
Project: directory-server
File: MavibotStoreTest.java
File: MavibotStoreTest.java
@Test public void testRename() throws Exception { Dn dn = new Dn(schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co."); Entry entry = new DefaultEntry(schemaManager, dn, "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "ou: Engineering", "cn: Private Ryan", "entryCSN", new CsnFactory(1).newInstance().toString(), "entryUUID", UUID.randomUUID().toString()); AddOperationContext addContext = new AddOperationContext(null, entry); store.add(addContext); Rdn rdn = new Rdn("sn=James"); store.rename(dn, rdn, true, null); dn = new Dn(schemaManager, "sn=James,ou=Engineering,o=Good Times Co."); Entry renamed = store.lookup(new LookupOperationContext(session, dn)); assertNotNull(renamed); assertEquals("James", renamed.getDn().getRdn().getValue()); }
92. MavibotEntrySerializationTest#testEntryFullSerialization()
Project: directory-server
File: MavibotEntrySerializationTest.java
File: MavibotEntrySerializationTest.java
@Test public void testEntryFullSerialization() throws IOException, LdapException, ClassNotFoundException { Entry entry1 = new DefaultEntry(schemaManager, "dc=example", "ObjectClass: top", "ObjectClass: domain", "dc: example", "l: test"); byte[] data = serializer.serialize(entry1); Entry entry2 = serializer.deserialize(ByteBuffer.wrap(data)); assertEquals(entry1, entry2); assertTrue(entry2.contains("ObjectClass", "top", "domain")); }
93. SingleFileLdifPartitionTest#testLdifMoveSubChildEntry()
Project: directory-server
File: SingleFileLdifPartitionTest.java
File: SingleFileLdifPartitionTest.java
@Test public void testLdifMoveSubChildEntry() throws Exception { SingleFileLdifPartition partition = injectEntries(); Entry childEntry1 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "cn=grandChild11,cn=child1,ou=test,ou=system"))); Entry childEntry2 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "cn=child2,ou=test,ou=system"))); MoveOperationContext moveOpCtx = new MoveOperationContext(mockSession, childEntry1.getDn(), childEntry2.getDn()); partition.move(moveOpCtx); partition = reloadPartition(); assertExists(partition, childEntry2); assertNotExists(partition, childEntry1); assertExists(partition, "cn=child1,ou=test,ou=system"); assertExists(partition, "cn=child2,ou=test,ou=system"); assertExists(partition, "cn=grandChild11,cn=child2,ou=test,ou=system"); assertExists(partition, "cn=grandChild12,cn=child1,ou=test,ou=system"); assertExists(partition, "cn=greatGrandChild111,cn=grandChild11,cn=child2,ou=test,ou=system"); }
94. SingleFileLdifPartitionTest#testLdifMoveEntry()
Project: directory-server
File: SingleFileLdifPartitionTest.java
File: SingleFileLdifPartitionTest.java
@Test public void testLdifMoveEntry() throws Exception { SingleFileLdifPartition partition = injectEntries(); Entry childEntry1 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "cn=child1,ou=test,ou=system"))); Entry childEntry2 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "cn=child2,ou=test,ou=system"))); MoveOperationContext moveOpCtx = new MoveOperationContext(mockSession, childEntry1.getDn(), childEntry2.getDn()); partition.move(moveOpCtx); partition = reloadPartition(); assertExists(partition, childEntry2); assertNotExists(partition, childEntry1); assertExists(partition, "cn=child1,cn=child2,ou=test,ou=system"); assertExists(partition, "cn=grandChild11,cn=child1,cn=child2,ou=test,ou=system"); assertExists(partition, "cn=grandChild12,cn=child1,cn=child2,ou=test,ou=system"); assertExists(partition, "cn=greatGrandChild111,cn=grandChild11,cn=child1,cn=child2,ou=test,ou=system"); }
95. SingleFileLdifPartitionTest#getEntryLdifLen()
Project: directory-server
File: SingleFileLdifPartitionTest.java
File: SingleFileLdifPartitionTest.java
private long getEntryLdifLen(Entry entry) throws LdapException { // Remove the entryDn attribute Entry copy = entry.clone(); copy.removeAttributes("entryDn"); // while writing to the file 1 extra newline char will be added String ldif = LdifUtils.convertToLdif(copy) + "\n"; byte[] data = Strings.getBytesUtf8(ldif); return data.length; }
96. SingleFileLdifPartitionSingeValueAttribute#testLdifMoveSubChildEntry()
Project: directory-server
File: SingleFileLdifPartitionSingeValueAttribute.java
File: SingleFileLdifPartitionSingeValueAttribute.java
@Test public void testLdifMoveSubChildEntry() throws Exception { SingleFileLdifPartition partition = injectEntries(); Entry childEntry1 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "dc=grandChild11,dc=child1,ou=test,ou=system"))); Entry childEntry2 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "dc=child2,ou=test,ou=system"))); MoveOperationContext moveOpCtx = new MoveOperationContext(mockSession, childEntry1.getDn(), childEntry2.getDn()); partition.move(moveOpCtx); partition = reloadPartition(); assertExists(partition, childEntry2); assertNotExists(partition, childEntry1); assertExists(partition, "dc=child1,ou=test,ou=system"); assertExists(partition, "dc=child2,ou=test,ou=system"); assertExists(partition, "dc=grandChild11,dc=child2,ou=test,ou=system"); assertExists(partition, "dc=grandChild12,dc=child1,ou=test,ou=system"); assertExists(partition, "dc=greatGrandChild111,dc=grandChild11,dc=child2,ou=test,ou=system"); }
97. SingleFileLdifPartitionSingeValueAttribute#testLdifMoveEntry()
Project: directory-server
File: SingleFileLdifPartitionSingeValueAttribute.java
File: SingleFileLdifPartitionSingeValueAttribute.java
@Test public void testLdifMoveEntry() throws Exception { SingleFileLdifPartition partition = injectEntries(); Entry childEntry1 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "dc=child1,ou=test,ou=system"))); Entry childEntry2 = partition.fetch(partition.getEntryId(new Dn(schemaManager, "dc=child2,ou=test,ou=system"))); MoveOperationContext moveOpCtx = new MoveOperationContext(mockSession, childEntry1.getDn(), childEntry2.getDn()); partition.move(moveOpCtx); partition = reloadPartition(); assertExists(partition, childEntry2); assertNotExists(partition, childEntry1); assertExists(partition, "dc=child1,dc=child2,ou=test,ou=system"); assertExists(partition, "dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system"); assertExists(partition, "dc=grandChild12,dc=child1,dc=child2,ou=test,ou=system"); assertExists(partition, "dc=greatGrandChild111,dc=grandChild11,dc=child1,dc=child2,ou=test,ou=system"); }
98. SingleFileLdifPartitionSingeValueAttribute#getEntryLdifLen()
Project: directory-server
File: SingleFileLdifPartitionSingeValueAttribute.java
File: SingleFileLdifPartitionSingeValueAttribute.java
private long getEntryLdifLen(Entry entry) throws LdapException { // Remove the entryDn attribute Entry copy = entry.clone(); copy.removeAttributes("entryDn"); // while writing to the file 1 extra newline char will be added String ldif = LdifUtils.convertToLdif(copy) + "\n"; byte[] data = Strings.getBytesUtf8(ldif); return data.length; }
99. LdifPartitionTest#testSpecialCharacters()
Project: directory-server
File: LdifPartitionTest.java
File: LdifPartitionTest.java
/** * Test for DIRSERVER-1551 (LdifPartition file names on Unix and Windows). * Ensure that special characters (http://en.wikipedia.org/wiki/Filenames) are encoded. */ @Test public void testSpecialCharacters() throws Exception { Dn adminDn = new Dn(schemaManager, "uid=admin,ou=system"); DirectoryService directoryService = new MockDirectoryService(1); directoryService.setSchemaManager(schemaManager); CoreSession session = new MockCoreSession(new LdapPrincipal(schemaManager, adminDn, AuthenticationLevel.STRONG), directoryService); AddOperationContext addCtx = new AddOperationContext(session); String rdnWithForbiddenChars = "dc=- -\\\"-%-&-(-)-*-\\+-/-:-\\;-\\<-\\>-?-[-\\5C-]-|-"; String rdnWithEscapedChars = "dc=-%20-%22-%25-%26-%28-%29-%2a-%2b-%2f-%3a-%3b-%3c-%3e-%3f-%5b-%5c-%5d-%7c-"; Entry entry1 = createEntry(rdnWithForbiddenChars + ",ou=test,ou=system"); entry1.put("objectClass", "top", "domain"); addCtx.setEntry(entry1); partition.add(addCtx); assertTrue(new File(wkdir, "ou=test,ou=system").exists()); assertTrue(new File(wkdir, "ou=test,ou=system.ldif").exists()); assertFalse(new File(wkdir, "ou=test,ou=system/" + rdnWithEscapedChars).exists()); assertTrue(new File(wkdir, "ou=test,ou=system/" + rdnWithEscapedChars + ".ldif").exists()); }
100. ClientAddRequestTest#testAddEntryWithRdnContainingEscapedCharsExistingnEntry()
Project: directory-server
File: ClientAddRequestTest.java
File: ClientAddRequestTest.java
@Test public void testAddEntryWithRdnContainingEscapedCharsExistingnEntry() throws Exception { //test as admin first Dn dn = new Dn("cn=a\\+B,ou=system"); Entry entry = new DefaultEntry(dn, "ObjectClass: top", "ObjectClass: person", "cn: a+b", "sn: x"); connection.add(entry); Entry loadedEntry = connection.lookup(dn.getName(), "*"); assertNotNull(loadedEntry); assertTrue(loadedEntry.containsAttribute("cn")); String cn = loadedEntry.get("cn").get().getString(); assertEquals("a+b", cn); }