Search in sources :

Example 71 with DummyAccount

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

the class TestInbounds method test264ModifyAccountOrangeQuoteWoodchuckRecon.

/**
 * Similar to test214ModifyAccountOrangeQuoteWoodchuck, but uses direct account modification
 * and reconciliation.
 * MID-2421
 */
@Test
public void test264ModifyAccountOrangeQuoteWoodchuckRecon() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
    display("User before", userBefore);
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME);
    dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "How much wood could a woodchuck chuck if a woodchuck could chuck wood?");
    displayDumpable("Account orange before", dummyAccountBefore);
    // WHEN
    when();
    reconcileUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    then();
    assertSuccess(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);
    assertNull("Wrong description", userAfter.asObjectable().getDescription());
    assertAssignedAccount(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    assertAssignedRole(userAfter, ROLE_THIEF_OID);
    assertAssignments(userAfter, 2);
    assertUser(userAfter, "after").assertLinks(1, 0);
    DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true);
    displayDumpable("Orange account", dummyAccount);
    guybrushShadowOrangeOid = getLiveLinkRefOid(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    PrismObject<ShadowType> shadowOrange = getShadowModel(guybrushShadowOrangeOid);
    display("Orange shadow", shadowOrange);
}
Also used : 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)

Example 72 with DummyAccount

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

the class TestInbounds method test252ModifyAccountOrangeGossipRecon.

/**
 * Similar to test202ModifyAccountOrangeGossip, but uses direct account modification
 * and reconciliation.
 * MID-2689
 */
@Test
public void test252ModifyAccountOrangeGossipRecon() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
    display("User before", userBefore);
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME);
    dummyAccountBefore.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, ROLE_THIEF_OID);
    displayDumpable("Account orange before", dummyAccountBefore);
    // WHEN
    reconcileUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    assertSuccess(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);
    assertAssignedAccount(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    assertAssignedRole(userAfter, ROLE_THIEF_OID);
    assertAssignments(userAfter, 2);
    assertUser(userAfter, "after").assertLinks(1, 0);
    DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true);
    displayDumpable("Orange account", dummyAccount);
    guybrushShadowOrangeOid = getLiveLinkRefOid(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    PrismObject<ShadowType> shadowOrange = getShadowModel(guybrushShadowOrangeOid);
    display("Orange shadow", shadowOrange);
}
Also used : 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)

Example 73 with DummyAccount

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

the class TestInbounds method test261ModifyAccountOrangeQuotePirateRecon.

/**
 * Similar to test211ModifyAccountOrangeQuotePirate, but uses direct account modification
 * and reconciliation.
 * MID-2421
 */
@Test
public void test261ModifyAccountOrangeQuotePirateRecon() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
    display("User before", userBefore);
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME);
    dummyAccountBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME, "I wanna be a pirrrrrrate!");
    displayDumpable("Account orange before", dummyAccountBefore);
    // WHEN
    reconcileUser(USER_GUYBRUSH_OID, task, result);
    // THEN
    assertSuccess(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);
    assertEquals("Wrong description", "I wanna be a pirrrrrrate!", userAfter.asObjectable().getDescription());
    assertAssignedAccount(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    assertAssignedRole(userAfter, ROLE_THIEF_OID);
    assertAssignments(userAfter, 2);
    assertUser(userAfter, "after").assertLinks(1, 0);
    DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_ORANGE_NAME, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true);
    displayDumpable("Account orange after", dummyAccount);
    displayDumpable("Orange account", dummyAccount);
    guybrushShadowOrangeOid = getLiveLinkRefOid(userAfter, RESOURCE_DUMMY_ORANGE_OID);
    PrismObject<ShadowType> shadowOrange = getShadowModel(guybrushShadowOrangeOid);
    display("Orange shadow", shadowOrange);
}
Also used : 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)

Example 74 with DummyAccount

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

the class TestModelServiceContract method test200AddUserBlackbeardWithAccount.

@Test
public void test200AddUserBlackbeardWithAccount() throws Exception {
    given();
    Task task = getTestTask();
    // Use custom channel to trigger a special outbound mapping
    task.setChannel("http://pirates.net/avast");
    OperationResult result = task.getResult();
    preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
    PrismObject<UserType> user = PrismTestUtil.parseObject(new File(TEST_DIR, "user-blackbeard-account-dummy.xml"));
    addAccountLinkRef(user, new File(TEST_DIR, "account-blackbeard-dummy.xml"));
    ObjectDelta<UserType> userDelta = DeltaFactory.Object.createAddDelta(user);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
    XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
    when();
    modelService.executeChanges(deltas, null, task, result);
    then();
    assertSuccess(result);
    XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
    assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
    PrismObject<UserType> userBlackbeard = modelService.getObject(UserType.class, USER_BLACKBEARD_OID, null, task, result);
    UserType userBlackbeardType = userBlackbeard.asObjectable();
    assertEquals("Unexpected number of accountRefs", 1, userBlackbeardType.getLinkRef().size());
    ObjectReferenceType accountRefType = userBlackbeardType.getLinkRef().get(0);
    String accountOid = accountRefType.getOid();
    assertFalse("No accountRef oid", StringUtils.isBlank(accountOid));
    assertEncryptedUserPassword(userBlackbeard, "QueenAnne");
    assertPasswordMetadata(userBlackbeard, CredentialsType.F_PASSWORD, true, startTime, endTime, USER_ADMINISTRATOR_OID, "http://pirates.net/avast");
    // Check shadow
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result);
    assertDummyAccountShadowRepo(accountShadow, accountOid, "blackbeard");
    assertEnableTimestampShadow(accountShadow, startTime, endTime);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertDummyAccountShadowModel(accountModel, accountOid, "blackbeard", "Edward Teach");
    assertEnableTimestampShadow(accountModel, startTime, endTime);
    // Check account in dummy resource
    assertDefaultDummyAccount("blackbeard", "Edward Teach", true);
    DummyAccount dummyAccount = getDummyAccount(null, "blackbeard");
    assertEquals("Wrong loot", (Integer) 10000, dummyAccount.getAttributeValue("loot", Integer.class));
    assertDummyScriptsAdd(userBlackbeard, accountModel, getDummyResourceType());
    // Check audit
    displayDumpable("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(0, 3);
    dummyAuditService.assertHasDelta(0, ChangeType.ADD, UserType.class);
    dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(0, ChangeType.ADD, ShadowType.class);
    // this one was redundant
    // dummyAuditService.assertExecutionDeltas(1, 1);
    // dummyAuditService.assertHasDelta(1, ChangeType.MODIFY, UserType.class);
    // raw operation, no target
    // dummyAuditService.assertTarget(USER_JACK_OID);
    dummyAuditService.assertExecutionSuccess();
    // Check notifications
    notificationManager.setDisabled(true);
    checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 1);
    checkDummyTransportMessages("userPasswordNotifier", 1);
    checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
    checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
    checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
    checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
    checkDummyTransportMessages("simpleUserNotifier", 1);
    checkDummyTransportMessages("simpleUserNotifier-ADD", 1);
    checkDummyTransportMessages("simpleUserNotifier-DELETE", 0);
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) File(java.io.File) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 75 with DummyAccount

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

the class TestModelServiceContract method test101GetAccount.

@Test
public void test101GetAccount() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
    // Let's do some evil things. Like changing some of the attribute on a resource and see if they will be
    // fetched after get.
    // Also set a value for ignored "water" attribute. The system should cope with that.
    DummyAccount jackDummyAccount = getDummyAccount(null, ACCOUNT_JACK_DUMMY_USERNAME);
    jackDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "The best pirate captain ever");
    jackDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WATER_NAME, "cold");
    rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
    when();
    PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
    then();
    display("Account", account);
    displayDumpable("Account def", account.getDefinition());
    assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
    PrismContainer<Containerable> accountContainer = account.findContainer(ShadowType.F_ATTRIBUTES);
    displayDumpable("Account attributes def", accountContainer.getDefinition());
    displayDumpable("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition());
    assertDummyAccountShadowModel(account, accountJackOid, "jack", "Jack Sparrow");
    assertSuccess("getObject result", result);
    account.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH);
    IntegrationTestTools.assertAttribute(account, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME), "The best pirate captain ever");
    // This one should still be here, even if ignored
    IntegrationTestTools.assertAttribute(account, getDummyResourceController().getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WATER_NAME), "cold");
    ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(account);
    assertNotNull("No attribute container from " + account, attributesContainer);
    Collection<ResourceAttribute<?>> identifiers = attributesContainer.getPrimaryIdentifiers();
    assertNotNull("No identifiers (null) in attributes container in " + accountJackOid, identifiers);
    assertFalse("No identifiers (empty) in attributes container in " + accountJackOid, identifiers.isEmpty());
    ResourceAttribute<String> fullNameAttr = attributesContainer.findAttribute(dummyResourceCtl.getAttributeFullnameQName());
    PrismAsserts.assertPropertyValue(fullNameAttr, ACCOUNT_JACK_DUMMY_FULLNAME);
    ResourceAttributeDefinition<String> fullNameAttrDef = fullNameAttr.getDefinition();
    displayDumpable("attribute fullname definition", fullNameAttrDef);
    PrismAsserts.assertDefinition(fullNameAttrDef, dummyResourceCtl.getAttributeFullnameQName(), DOMUtil.XSD_STRING, 1, 1);
    // MID-3144
    if (fullNameAttrDef.getDisplayOrder() == null || fullNameAttrDef.getDisplayOrder() < 100 || fullNameAttrDef.getDisplayOrder() > 400) {
        AssertJUnit.fail("Wrong fullname displayOrder: " + fullNameAttrDef.getDisplayOrder());
    }
    assertEquals("Wrong fullname displayName", "Full Name", fullNameAttrDef.getDisplayName());
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) 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