Search in sources :

Example 1 with ModifyDnRequestImpl

use of org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test817RenameAccount.

@Test
public void test817RenameAccount() throws Exception {
    final String TEST_NAME = "test817RenameAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long tsStart = System.currentTimeMillis();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    LdapNetworkConnection connection = ldapConnect();
    ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
    modDnRequest.setName(new Dn(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)));
    modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN));
    modDnRequest.setDeleteOldRdn(true);
    ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest);
    display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse);
    doAdditionalRenameModifications(connection);
    ldapDisconnect(connection);
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<UserType> user = findUserByUsername(ACCOUNT_HTM_UID);
    assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user);
    assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
    assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID));
    assertStepSyncToken(getSyncTaskOid(), 4, tsStart, tsEnd);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) ModifyDnResponse(org.apache.directory.api.ldap.model.message.ModifyDnResponse) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModifyDnRequestImpl(org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 2 with ModifyDnRequestImpl

use of org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test837RenameAccount.

@Test
public void test837RenameAccount() throws Exception {
    final String TEST_NAME = "test837RenameAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long tsStart = System.currentTimeMillis();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    LdapNetworkConnection connection = ldapConnect();
    ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
    modDnRequest.setName(new Dn(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)));
    modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN));
    modDnRequest.setDeleteOldRdn(true);
    ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest);
    display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse);
    doAdditionalRenameModifications(connection);
    ldapDisconnect(connection);
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<UserType> user = findUserByUsername(ACCOUNT_HTM_UID);
    assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user);
    assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
    assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID));
    assertStepSyncToken(getSyncTaskOid(), 9, tsStart, tsEnd);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) ModifyDnResponse(org.apache.directory.api.ldap.model.message.ModifyDnResponse) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModifyDnRequestImpl(org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 ModifyDnRequest (org.apache.directory.api.ldap.model.message.ModifyDnRequest)2 ModifyDnRequestImpl (org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl)2 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)2 Dn (org.apache.directory.api.ldap.model.name.Dn)2 LdapNetworkConnection (org.apache.directory.ldap.client.api.LdapNetworkConnection)2 Test (org.testng.annotations.Test)2