Search in sources :

Example 56 with DummyAccount

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

the class TestIteration method test280RenameBobNoShadow.

/**
 * Same as test240 (conflict with no shadow), but including rename operation.
 */
@Test
public void test280RenameBobNoShadow() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBob = createUser(USER_BOB_NAME, "Bob Andrews", true);
    addObject(userBob);
    String userBobOid = userBob.getOid();
    // Make sure there is a conflicting account and NO shadow for it
    DummyAccount account = new DummyAccount("bobby");
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Bobby Pinky");
    getDummyResource(RESOURCE_DUMMY_PINK_NAME).addAccount(account);
    // preconditions
    assertNoDummyAccount(RESOURCE_DUMMY_PINK_NAME, USER_BOB_NAME);
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, "bobby", "Bobby Pinky", true);
    // prepare change
    ObjectDelta<UserType> objectDelta = createAccountAssignmentUserDelta(userBobOid, RESOURCE_DUMMY_PINK_OID, "default", true);
    // will conflict with Bobby Pinky
    objectDelta.addModification(createUserPropertyReplaceModification(UserType.F_NAME, new PolyString("bobby")));
    objectDelta.addModification(createUserPropertyReplaceModification(UserType.F_FULL_NAME, new PolyString("Bobby Andrews")));
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
    deltas.add(objectDelta);
    // WHEN
    when();
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    then();
    PrismObject<UserType> userBobAfter = getUser(userBobOid);
    display("User after change execution", userBobAfter);
    assertUser(userBobAfter, userBobOid, "bobby", "Bobby Andrews", null, null, null);
    String accountOid = getSingleLinkOid(userBobAfter);
    // Check shadow & account
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    display("Account shadow from repo", accountShadow);
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    display("Account shadow from model", accountModel);
    assertAccountShadowRepo(accountShadow, accountOid, "bobby1", getDummyResourceType(RESOURCE_DUMMY_PINK_NAME));
    assertAccountShadowModel(accountModel, accountOid, "bobby1", getDummyResourceType(RESOURCE_DUMMY_PINK_NAME));
    // THEN
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, "bobby", "Bobby Pinky", true);
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, "bobby1", "Bobby Andrews", true);
    assertNoDummyAccount(RESOURCE_DUMMY_PINK_NAME, "bob");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 57 with DummyAccount

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

the class TestIteration method test100JackAssignAccountDummyConflicting.

/**
 * The default dummy instance will not iterate. It has correlation rule which will link the account instead.
 */
@Test
public void test100JackAssignAccountDummyConflicting() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // Make sure there is a conflicting account and also a shadow for it
    DummyAccount account = new DummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sparrow");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Tortuga");
    getDummyResource().addAccount(account);
    repoAddObject(createShadow(getDummyResourceObject(), ACCOUNT_JACK_DUMMY_USERNAME), result);
    ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true);
    // WHEN
    when();
    executeChanges(accountAssignmentUserDelta, null, task, result);
    // THEN
    then();
    assertSuccess(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);
    assertDummyAccountShadowRepo(accountShadow, accountOid, ACCOUNT_JACK_DUMMY_USERNAME);
    // Check account
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    assertDummyAccountShadowModel(accountModel, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow");
    // Check account in dummy resource
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
    // Check audit
    displayDumpable("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(3);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
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)

Example 58 with DummyAccount

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

the class TestIteration method test730DarkVioletAddBarbossa.

/*
     * Create account with fullname barbossa. But user barbossa already exists.
     *  User with name barbossa.1 should be created (conflict).
     */
@Test
public void test730DarkVioletAddBarbossa() throws Exception {
    // GIVEN
    dummyAuditService.clear();
    DummyAccount account = new DummyAccount(USER_BARBOSSA_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_BARBOSSA_USERNAME);
    // WHEN
    when();
    displayValue("Adding dummy account", account.debugDump());
    getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account);
    waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true);
    // THEN
    then();
    assertUserNick(USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_USERNAME + ".1");
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 59 with DummyAccount

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

the class TestIteration method test710DarkVioletAddLeChuck.

/*
     * Create account with fullname LeChuck. User with name LeChuck should be created (no conflict yet).
     */
@Test
public void test710DarkVioletAddLeChuck() throws Exception {
    // GIVEN
    dummyAuditService.clear();
    DummyAccount account = new DummyAccount(ACCOUNT_LECHUCK_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, LECHUCK_FULLNAME);
    // WHEN
    when();
    displayValue("Adding dummy account", account.debugDump());
    getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).addAccount(account);
    waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true);
    // THEN
    then();
    assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME);
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 60 with DummyAccount

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

the class TestIteration method test200JackAssignAccountDummyPinkConflicting.

@Test
public void test200JackAssignAccountDummyPinkConflicting() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // Make sure there is a conflicting account and also a shadow for it
    DummyAccount account = new DummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Pinky");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Red Sea");
    getDummyResource(RESOURCE_DUMMY_PINK_NAME).addAccount(account);
    repoAddObject(createShadow(getDummyResourceObject(RESOURCE_DUMMY_PINK_NAME), ACCOUNT_JACK_DUMMY_USERNAME), result);
    // assignment with weapon := 'pistol' (test for
    Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
    AssignmentType assignmentType = createConstructionAssignment(RESOURCE_DUMMY_PINK_OID, ShadowKindType.ACCOUNT, null);
    ConstructionType constructionType = assignmentType.getConstruction();
    ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType();
    attributeDefinitionType.setRef(new ItemPathType(ItemPath.create(getDummyResourceController(RESOURCE_DUMMY_PINK_NAME).getAttributeWeaponQName())));
    MappingType mappingType = new MappingType();
    mappingType.setStrength(MappingStrengthType.STRONG);
    ExpressionType expressionType = new ExpressionType();
    expressionType.getExpressionEvaluator().add(new ObjectFactory().createValue(RawType.create("pistol", prismContext)));
    mappingType.setExpression(expressionType);
    attributeDefinitionType.setOutbound(mappingType);
    constructionType.getAttribute().add(attributeDefinitionType);
    modifications.add(createAssignmentModification(assignmentType, true));
    ObjectDelta<UserType> accountAssignmentUserDelta = prismContext.deltaFactory().object().createModifyDelta(USER_JACK_OID, modifications, UserType.class);
    // WHEN
    when();
    executeChanges(accountAssignmentUserDelta, null, task, result);
    // THEN
    then();
    assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack);
    assertLiveLinks(userJack, 2);
    assertAccount(userJack, RESOURCE_DUMMY_OID);
    assertAccount(userJack, RESOURCE_DUMMY_PINK_OID);
    String accountPinkOid = getLiveLinkRefOid(userJack, RESOURCE_DUMMY_PINK_OID);
    // Check shadow
    PrismObject<ShadowType> accountPinkShadow = repositoryService.getObject(ShadowType.class, accountPinkOid, null, result);
    assertAccountShadowRepo(accountPinkShadow, accountPinkOid, "jack1", getDummyResourceType(RESOURCE_DUMMY_PINK_NAME));
    // Check account
    PrismObject<ShadowType> accountPinkModel = modelService.getObject(ShadowType.class, accountPinkOid, null, task, result);
    assertAccountShadowModel(accountPinkModel, accountPinkOid, "jack1", getDummyResourceType(RESOURCE_DUMMY_PINK_NAME));
    display("accountPinkModel", accountPinkModel);
    PrismAsserts.assertPropertyValue(accountPinkModel, getDummyResourceController(RESOURCE_DUMMY_PINK_NAME).getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME), "pistol");
    // Check account in dummy resource
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
    // The original conflicting account should still remain
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Pinky", true);
    // The new account
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, "jack1", "Jack Sparrow", true);
    // Check audit
    displayDumpable("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) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) 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