Search in sources :

Example 41 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractInboundSyncTest method test300AddDummyEmeraldAccountPosixUser.

@Test
public void test300AddDummyEmeraldAccountPosixUser() throws Exception {
    // GIVEN
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(7);
    DummyAccount account = new DummyAccount(ACCOUNT_POSIXUSER_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Posix User");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
    account.addAuxiliaryObjectClassName(DummyResourceContoller.DUMMY_POSIX_ACCOUNT_OBJECT_CLASS_NAME);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_UID_NUMBER, Collections.<Object>singleton(1001));
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_GID_NUMBER, Collections.<Object>singleton(10001));
    // / WHEN
    when();
    displayValue("Adding dummy account", account.debugDump());
    dummyResourceEmerald.addAccount(account);
    waitForSyncTaskNextRun(resourceDummyEmerald);
    // THEN
    then();
    PrismObject<ShadowType> accountPosixUser = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald);
    display("Account posixuser", accountPosixUser);
    assertNotNull("No posixuser account shadow", accountPosixUser);
    assertEquals("Wrong resourceRef in posixuser account", RESOURCE_DUMMY_EMERALD_OID, accountPosixUser.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountPosixUser, SynchronizationSituationType.LINKED);
    PrismObject<UserType> userPosixUser = findUserByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME);
    display("User posixuser", userPosixUser);
    assertNotNull("User posixuser was not created", userPosixUser);
    assertLiveLinks(userPosixUser, 1);
    assertAdministrativeStatusEnabled(userPosixUser);
    assertLinked(userPosixUser, accountPosixUser);
    assertUsers(8);
    // notifications
    notificationManager.setDisabled(true);
// TODO create and test inbounds for uid and gid numbers; also other attributes
// (Actually I'm not sure it will work, as even now the auxiliary object class is
// removed right during the livesync. This has to be solved somehow...)
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 42 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractInboundSyncTest method test310ModifyDummyEmeraldAccountPosixUserUidNumber.

@Test
public void test310ModifyDummyEmeraldAccountPosixUserUidNumber() throws Exception {
    // GIVEN
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(8);
    DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME);
    // / WHEN
    when();
    account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_POSIX_UID_NUMBER, 1002);
    displayValue("Modified dummy account", account.debugDump());
    waitForSyncTaskNextRun(resourceDummyEmerald);
    // THEN
    then();
    PrismObject<ShadowType> accountAfter = findAccountByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME, resourceDummyEmerald);
    display("Account posixuser", accountAfter);
    assertNotNull("No posixuser account shadow", accountAfter);
    assertEquals("Wrong resourceRef in posixuser account", RESOURCE_DUMMY_EMERALD_OID, accountAfter.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountAfter, SynchronizationSituationType.LINKED);
    PrismObject<UserType> userAfter = findUserByUsername(ACCOUNT_POSIXUSER_DUMMY_USERNAME);
    display("User posixuser", userAfter);
    assertNotNull("User posixuser was not created", userAfter);
    assertLiveLinks(userAfter, 1);
    assertAdministrativeStatusEnabled(userAfter);
    assertLinked(userAfter, accountAfter);
    assertUsers(8);
    // notifications
    notificationManager.setDisabled(true);
// TODO create and test inbounds for uid and gid numbers; also other attributes
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 43 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractInboundSyncTest method test124ModifyDummyEmeraldAccountMancombSeepevil.

@Test
public void test124ModifyDummyEmeraldAccountMancombSeepevil() throws Exception {
    // GIVEN
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(7);
    DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    // / WHEN
    when();
    account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepevil");
    displayValue("Modified dummy account", account.debugDump());
    waitForSyncTaskNextRun(resourceDummyEmerald);
    // THEN
    then();
    PrismObject<ShadowType> accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald);
    display("Account mancomb", accountAfter);
    assertNotNull("No mancomb account shadow", accountAfter);
    assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_EMERALD_OID, accountAfter.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountAfter, SynchronizationSituationType.LINKED);
    assertDummyAccountAttribute(RESOURCE_DUMMY_EMERALD_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepevil");
    PrismObject<UserType> userAfter = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    display("User mancomb", userAfter);
    assertNotNull("User mancomb was not created", userAfter);
    assertLiveLinks(userAfter, 1);
    assertAdministrativeStatusEnabled(userAfter);
    assertValidFrom(userAfter, ACCOUNT_MANCOMB_VALID_FROM_DATE);
    assertValidTo(userAfter, ACCOUNT_MANCOMB_VALID_TO_DATE);
    assertLinked(userAfter, accountAfter);
    PrismAsserts.assertPropertyValue(userAfter, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Mancomb Seepevil"));
    assertUsers(7);
    // notifications
    notificationManager.setDisabled(true);
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 44 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class AbstractInboundSyncTest method test120ModifyDummyEmeraldAccountMancombSeepbad.

@Test
public void test120ModifyDummyEmeraldAccountMancombSeepbad() throws Exception {
    // GIVEN
    rememberTimeBeforeSync();
    prepareNotifications();
    // Preconditions
    assertUsers(7);
    DummyAccount account = dummyResourceEmerald.getAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    // / WHEN
    when();
    account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepbad");
    displayValue("Modified dummy account", account.debugDump());
    waitForSyncTaskNextRun(resourceDummyEmerald);
    // THEN
    then();
    PrismObject<ShadowType> accountAfter = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyEmerald);
    display("Account mancomb", accountAfter);
    assertNotNull("No mancomb account shadow", accountAfter);
    assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_EMERALD_OID, accountAfter.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountAfter, SynchronizationSituationType.LINKED);
    assertDummyAccountAttribute(RESOURCE_DUMMY_EMERALD_NAME, ACCOUNT_MANCOMB_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepbad");
    PrismObject<UserType> userAfter = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    display("User mancomb", userAfter);
    assertNotNull("User mancomb was not created", userAfter);
    assertLiveLinks(userAfter, 1);
    assertAdministrativeStatusEnabled(userAfter);
    assertValidFrom(userAfter, ACCOUNT_MANCOMB_VALID_FROM_DATE);
    assertValidTo(userAfter, ACCOUNT_MANCOMB_VALID_TO_DATE);
    assertLinked(userAfter, accountAfter);
    PrismAsserts.assertPropertyValue(userAfter, UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Mancomb Seepbad"));
    assertUsers(7);
    // notifications
    notificationManager.setDisabled(true);
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 45 with DummyAccount

use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.

the class TestUuid method test230ReconcileDummyUuidDeleteAugustusAddAugustina.

/**
 * Augustus is deleted and Augustina re-added. They correlate to the same user.
 * New shadow needs to be created.
 */
@Test
public void test230ReconcileDummyUuidDeleteAugustusAddAugustina() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
    DummyAccount oldAccount = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTUS_NAME);
    dummyResourceUuid.deleteAccountByName(ACCOUNT_AUGUSTUS_NAME);
    assertNoDummyAccount(ACCOUNT_AUGUSTUS_NAME, ACCOUNT_AUGUSTUS_NAME);
    DummyAccount account = new DummyAccount(ACCOUNT_AUGUSTINA_NAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTINA_FULLNAME);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, USER_AUGUSTUS_NAME);
    dummyResourceUuid.addAccount(account);
    account = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTINA_NAME);
    assertThat(oldAccount.getId()).withFailMessage("Account IDs not changed").isNotEqualTo(account.getId());
    displayValue("Old shadow OID", augustusShadowOid);
    display("Account ID " + oldAccount.getId() + " -> " + account.getId());
    Task taskBefore = taskManager.getTaskPlain(TASK_RECONCILE_DUMMY_UUID_OID, result);
    getDummyResource().purgeScriptHistory();
    dummyAuditService.clear();
    rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
    reconciliationTaskResultListener.clear();
    when();
    restartTask(TASK_RECONCILE_DUMMY_UUID_OID);
    then();
    waitForTaskNextRunAssertSuccess(taskBefore, true);
    reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 2);
    List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after import", users);
    assertImportedUserByOid(USER_ADMINISTRATOR_OID);
    assertImportedUserByOid(USER_JACK_OID);
    assertImportedUserByOid(USER_BARBOSSA_OID);
    assertImportedUserByUsername(USER_AUGUSTUS_NAME, RESOURCE_DUMMY_UUID_OID);
    assertDummyAccountAttribute(RESOURCE_DUMMY_UUID_NAME, ACCOUNT_AUGUSTINA_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTINA_FULLNAME);
    assertEquals("Unexpected number of users", 7, users.size());
    displayValue("Dummy resource", getDummyResource().debugDump());
    // MID-7110
    // assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_UUID_OID);
    // Task result
    PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_UUID_OID);
    OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
    display("Recon task result", reconTaskResult);
    // there is an error deep inside (that is expected)
    TestUtil.assertSuccess(reconTaskResult.getOperation(), reconTaskResult, 4);
    // @formatter:off
    assertUserAfterByUsername(USER_AUGUSTUS_NAME).displayWithProjections().links().assertLinks(1, 2).by().dead(true).assertCount(2).by().dead(false).find().assertOidDifferentThan(augustusShadowOid);
// @formatter:on
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)261 Test (org.testng.annotations.Test)211 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)158 Task (com.evolveum.midpoint.task.api.Task)152 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)40 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)24 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 ArrayList (java.util.ArrayList)19 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)18 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)10 QName (javax.xml.namespace.QName)10 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)9 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)9