Search in sources :

Example 26 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testSpecWithSpecificExclusions.

/**
 * Tests the parser with a valid specification with some specific exclusions
 * set.
 */
@Test
public void testSpecWithSpecificExclusions() throws Exception {
    SubtreeSpecification ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
    assertFalse(ss.getChopBeforeExclusions().isEmpty());
    assertFalse(ss.getChopAfterExclusions().isEmpty());
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
    // try a second time
    ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
    assertFalse(ss.getChopBeforeExclusions().isEmpty());
    assertFalse(ss.getChopAfterExclusions().isEmpty());
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
    // try a third time
    ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
    assertFalse(ss.getChopBeforeExclusions().isEmpty());
    assertFalse(ss.getChopAfterExclusions().isEmpty());
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 27 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testReusabiltiy.

/**
 * Test reusability, especially if the state is resetted.
 */
@Test
public void testReusabiltiy() throws Exception {
    Dn firstDn = new Dn(schemaManager, "cn=l");
    String firstExclusion = "{ specificExclusions { chopAfter:\"cn=l\" } }";
    SubtreeSpecification firstSpec = parser.parse(firstExclusion);
    assertEquals(1, firstSpec.getChopAfterExclusions().size());
    assertEquals(firstDn, firstSpec.getChopAfterExclusions().iterator().next());
    Dn secondDn = new Dn(schemaManager, "l=y");
    String secondExclusion = "{ specificExclusions { chopAfter:\"l=y\" } }";
    SubtreeSpecification secondSpec = parser.parse(secondExclusion);
    assertEquals(1, secondSpec.getChopAfterExclusions().size());
    assertEquals(secondDn, secondSpec.getChopAfterExclusions().iterator().next());
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 28 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method testSpecWithBaseAndSpecificExclusionsAndMinimumAndMaximum.

/**
 * Tests the parser with a valid specification with base and specific
 * exclusions and minimum and maximum set.
 */
@Test
public void testSpecWithBaseAndSpecificExclusionsAndMinimumAndMaximum() throws Exception {
    SubtreeSpecification ss = parser.parse(SPEC_WITH_BASE_AND_SPECIFICEXCLUSIONS_AND_MINIMUM_AND_MAXIMUM);
    assertNotNull(ss);
    assertEquals("ou=people", ss.getBase().toString());
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=y")));
    assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "c=z")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "sn=l")));
    assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "l=m")));
    assertEquals(7, ss.getMinBaseDistance());
    assertEquals(77, ss.getMaxBaseDistance());
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) SubtreeSpecification(org.apache.directory.api.ldap.model.subtree.SubtreeSpecification) Test(org.junit.Test)

Example 29 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class ApiLdapExtrasCodecApiOsgiTest method useBundleClasses.

@Override
protected void useBundleClasses() throws Exception {
    SynchronizationModeEnum.REFRESH_AND_PERSIST.getValue();
    new AdDirSyncImpl().getOid();
    new AdShowDeletedImpl().getOid();
    new AdPolicyHintsImpl().getOid();
    new ChangeNotificationsImpl().getOid();
    new PermissiveModifyImpl().getOid();
    new PasswordPolicyImpl().getOid();
    new PasswordPolicyResponseImpl().getGraceAuthNRemaining();
    new SyncDoneValueImpl().getOid();
    new SyncRequestValueImpl().getOid();
    new SyncStateValueImpl(true).getCookie();
    new VirtualListViewRequestImpl().getOid();
    new VirtualListViewResponseImpl().getOid();
    new PasswordModifyRequestImpl().getUserIdentity();
    new PasswordModifyResponseImpl(5).setResponseName("foo");
    new WhoAmIRequestImpl();
    new WhoAmIResponseImpl().setDn(new Dn("uid=admin,ou=system"));
    new StartTlsRequestImpl();
    new StartTlsResponseImpl();
    new StartTransactionRequestImpl();
    new StartTransactionResponseImpl();
}
Also used : PasswordPolicyImpl(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyImpl) AdPolicyHintsImpl(org.apache.directory.api.ldap.extras.controls.ad.AdPolicyHintsImpl) SyncStateValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncState.SyncStateValueImpl) WhoAmIRequestImpl(org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIRequestImpl) AdDirSyncImpl(org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncImpl) AdShowDeletedImpl(org.apache.directory.api.ldap.extras.controls.ad.AdShowDeletedImpl) WhoAmIResponseImpl(org.apache.directory.api.ldap.extras.extended.whoAmI.WhoAmIResponseImpl) SyncRequestValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncRequest.SyncRequestValueImpl) Dn(org.apache.directory.api.ldap.model.name.Dn) VirtualListViewRequestImpl(org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewRequestImpl) PermissiveModifyImpl(org.apache.directory.api.ldap.extras.controls.permissiveModify.PermissiveModifyImpl) StartTlsResponseImpl(org.apache.directory.api.ldap.extras.extended.startTls.StartTlsResponseImpl) VirtualListViewResponseImpl(org.apache.directory.api.ldap.extras.controls.vlv.VirtualListViewResponseImpl) PasswordModifyRequestImpl(org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyRequestImpl) StartTlsRequestImpl(org.apache.directory.api.ldap.extras.extended.startTls.StartTlsRequestImpl) PasswordPolicyResponseImpl(org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyResponseImpl) SyncDoneValueImpl(org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValueImpl) ChangeNotificationsImpl(org.apache.directory.api.ldap.extras.controls.changeNotifications.ChangeNotificationsImpl) StartTransactionRequestImpl(org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionRequestImpl) PasswordModifyResponseImpl(org.apache.directory.api.ldap.extras.extended.pwdModify.PasswordModifyResponseImpl) StartTransactionResponseImpl(org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponseImpl)

Example 30 with Dn

use of org.apache.directory.api.ldap.model.name.Dn in project directory-ldap-api by apache.

the class LdifRevertorTest method test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry.

/**
 * Test a reversed rename ModifyDN, where the initial Rdn is composite,
 * the new Rdn is composite, they don't overlap, with deleteOldRdn = false, and
 * some of the new values exists in the entry.
 *
 * Covers case 10.2 of http://cwiki.apache.org/confluence/display/DIRxSRVx11/Reverse+LDIF
 *
 * Initial entry
 * dn: sn=small+cn=test,ou=system
 * objectclass: top
 * objectclass: person
 * cn: test
 * cn: big
 * sn: small
 * sn: This is a test
 *
 * new Rdn : sn=joe+cn=big
 *
 * @throws LdapException on error
 */
@Test
public void test102ReverseRenameCompositeCompositeNotOverlappingKeepOldRdnExistInEntry() throws LdapException {
    Dn dn = new Dn("sn=small+cn=test,ou=system");
    Rdn oldRdn = new Rdn("sn=small+cn=test");
    Rdn newRdn = new Rdn("sn=joe+cn=big");
    Entry entry = new DefaultEntry(dn, "objectClass: top", "objectClass: person", "cn: test", "cn: big", "sn: small", "sn: this is a test");
    List<LdifEntry> reverseds = LdifRevertor.reverseRename(entry, newRdn, LdifRevertor.KEEP_OLD_RDN);
    assertNotNull(reverseds);
    assertEquals(2, reverseds.size());
    LdifEntry reversed = reverseds.get(0);
    assertEquals("sn=joe+cn=big,ou=system", reversed.getDn().getName());
    assertEquals(ChangeType.ModRdn, reversed.getChangeType());
    assertFalse(reversed.isDeleteOldRdn());
    assertEquals(oldRdn.getName(), reversed.getNewRdn());
    assertNull(reversed.getNewSuperior());
    reversed = reverseds.get(1);
    assertEquals("sn=small+cn=test,ou=system", reversed.getDn().getName());
    assertEquals(ChangeType.Modify, reversed.getChangeType());
    Modification[] mods = reversed.getModificationArray();
    assertNotNull(mods);
    assertEquals(1, mods.length);
    assertEquals(ModificationOperation.REMOVE_ATTRIBUTE, mods[0].getOperation());
    assertNotNull(mods[0].getAttribute());
    assertEquals("sn", mods[0].getAttribute().getId());
    assertEquals("joe", mods[0].getAttribute().getString());
}
Also used : LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) Dn(org.apache.directory.api.ldap.model.name.Dn) Rdn(org.apache.directory.api.ldap.model.name.Rdn) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) Test(org.junit.Test)

Aggregations

Dn (org.apache.directory.api.ldap.model.name.Dn)307 Test (org.junit.Test)183 Rdn (org.apache.directory.api.ldap.model.name.Rdn)63 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)50 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)39 Entry (org.apache.directory.api.ldap.model.entry.Entry)34 DnNode (org.apache.directory.api.ldap.util.tree.DnNode)30 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)20 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)19 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)17 Modification (org.apache.directory.api.ldap.model.entry.Modification)17 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)16 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)10 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)10 ModifyRequest (org.apache.directory.api.ldap.model.message.ModifyRequest)10 Referral (org.apache.directory.api.ldap.model.message.Referral)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 ResponseCarryingException (org.apache.directory.api.ldap.codec.api.ResponseCarryingException)8 Value (org.apache.directory.api.ldap.model.entry.Value)8