Search in sources :

Example 6 with DummyAccount

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

the class TestMapping method test100ModifyUserAssignAccountDummyBlue.

/**
	 * Blue dummy has WEAK mappings. Let's play a bit with that.
	 */
@Test
public void test100ModifyUserAssignAccountDummyBlue() throws Exception {
    final String TEST_NAME = "test100ModifyUserJackAssignAccountDummyBlue";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assignAccount(USER_JACK_OID, RESOURCE_DUMMY_BLUE_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack);
    String accountOid = getSingleLinkOid(userJack);
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    assertAccountShadowRepo(accountShadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyBlueType);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertAccountShadowModel(accountModel, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyBlueType);
    // Check account in dummy resource
    assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, ACCOUNT_JACK_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "SystemConfiguration");
    DummyAccount accountJackBlue = dummyResourceBlue.getAccountByUsername(ACCOUNT_JACK_DUMMY_USERNAME);
    String drinkBlue = accountJackBlue.getAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME);
    assertNotNull("No blue drink", drinkBlue);
    UUID drinkUuidBlue = UUID.fromString(drinkBlue);
    assertNotNull("No drink UUID", drinkUuidBlue);
    display("Drink UUID", drinkUuidBlue.toString());
    assertAccountShip(userJack, ACCOUNT_JACK_DUMMY_FULLNAME, null, dummyResourceCtlBlue, task);
    assertDummyAccountAttribute(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "Where's the rum? -- Jack Sparrow");
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(3);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UUID(java.util.UUID) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 7 with DummyAccount

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

the class TestMapping method test200ModifyUserAssignAccountDummyCrimson.

@Test
public void test200ModifyUserAssignAccountDummyCrimson() throws Exception {
    final String TEST_NAME = "test200ModifyUserAssignAccountDummyCrimson";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assignAccount(USER_GUYBRUSH_OID, RESOURCE_DUMMY_CRIMSON_OID, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
    // Check account in dummy resource
    DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    display("Dummy account", dummyAccount);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, ACCOUNT_GUYBRUSH_DUMMY_LOCATION);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 8 with DummyAccount

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

the class TestMapping method test202NativeModifyDummyCrimsonThenReconcile.

/**
	 * MID-3661
	 */
@Test
public void test202NativeModifyDummyCrimsonThenReconcile() throws Exception {
    final String TEST_NAME = "test202NativeModifyDummyCrimsonThenReconcile";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "vodka", "whisky");
    display("Dummy account before", dummyAccountBefore);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    reconcileUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess("executeChanges result", result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
    // Check account in dummy resource
    DummyAccount dummyAccountAfter = assertDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    display("Dummy account after", dummyAccountAfter);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, ACCOUNT_GUYBRUSH_DUMMY_LOCATION);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "vodka", "whisky", "rum from Melee Island");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 9 with DummyAccount

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

the class TestMappingInbound method test110AddDummyTeaGreenAccountMancomb.

@Test
public void test110AddDummyTeaGreenAccountMancomb() throws Exception {
    final String TEST_NAME = "test110AddDummyTeaGreenAccountMancomb";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestMappingInbound.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Preconditions
    //assertUsers(5);
    DummyAccount account = new DummyAccount(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Mancomb Seepgood");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
    /// WHEN
    TestUtil.displayWhen(TEST_NAME);
    dummyResourceTeaGreen.addAccount(account);
    waitForSyncTaskNextRun();
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<ShadowType> accountMancomb = findAccountByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME, resourceDummyTeaGreen);
    display("Account mancomb", accountMancomb);
    assertNotNull("No mancomb account shadow", accountMancomb);
    assertEquals("Wrong resourceRef in mancomb account", RESOURCE_DUMMY_TEA_GREEN_OID, accountMancomb.asObjectable().getResourceRef().getOid());
    assertShadowOperationalData(accountMancomb, SynchronizationSituationType.LINKED, null);
    PrismObject<UserType> userMancomb = findUserByUsername(ACCOUNT_MANCOMB_DUMMY_USERNAME);
    display("User mancomb", userMancomb);
    assertNotNull("User mancomb was not created", userMancomb);
    assertLinks(userMancomb, 1);
    assertAdministrativeStatusEnabled(userMancomb);
    assertLinked(userMancomb, accountMancomb);
    //        assertUsers(6);
    // notifications
    notificationManager.setDisabled(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 10 with DummyAccount

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

the class AbstractBasicDummyTest method test106GetModifiedAccount.

/**
	 * Make a native modification to an account and read it again. Make sure that
	 * fresh data are returned - even though caching may be in effect.
	 * MID-3481
	 */
@Test
public void test106GetModifiedAccount() throws Exception {
    final String TEST_NAME = "test106GetModifiedAccount";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    rememberShadowFetchOperationCount();
    DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    accountWill.setEnabled(false);
    XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    assertShadowFetchOperationCountIncrement(1);
    XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
    display("Retrieved account shadow", shadow);
    assertNotNull("No dummy account", shadow);
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "Sword", "LOVE");
    assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
    Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow);
    assertEquals("Unexpected number of attributes", 7, attributes.size());
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
    checkRepoAccountShadowWillBasic(shadowRepo, startTs, endTs, null);
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
    assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
    assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.DISABLED);
    checkConsistency(shadow);
    assertCachingMetadata(shadow, false, startTs, endTs);
    assertSteadyResource();
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

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