Search in sources :

Example 36 with DummyAccount

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

the class TestMappingAdvanced method test370GiveVladimirExtraValuesAndModifyUser.

/**
 * Add some extra values to the account and simply modify magnus. Ranges should throw (some of) them out.
 *
 * - attribute/organization: mp_garbage (should be thrown out)
 * - attribute/organization: valid (should be kept as it does not belong to mapping range)
 * - association/group: mp_testers (should be thrown out)
 * - association/group: validGroup (should be kept)
 */
@Test
public void test370GiveVladimirExtraValuesAndModifyUser() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyAccount vladimir = RESOURCE_DUMMY_RANGES_ROLE.controller.getDummyResource().getAccountByUsername(VLADIMIR);
    vladimir.addAttributeValue(ATTR_ORGANIZATION, "mp_garbage");
    DummyGroup testers = RESOURCE_DUMMY_RANGES_ROLE.controller.getDummyResource().getGroupByName(MP_TESTERS);
    testers.addMember(VLADIMIR);
    ObjectDelta<UserType> delta = deltaFor(UserType.class).item(UserType.F_FULL_NAME).replace(PolyString.fromOrig("Vladimir Kramnik")).asObjectDelta(USER_VLADIMIR.oid);
    when();
    traced(() -> executeChanges(delta, null, task, result));
    then();
    assertSuccess(task);
    assertDummyAccountByUsername(RESOURCE_DUMMY_RANGES_ROLE.name, VLADIMIR).display().assertAttribute(ATTR_ORGANIZATION, "mp_FIDE", "valid");
    assertDummyGroupByName(RESOURCE_DUMMY_RANGES_ROLE.name, MP_USERS).display().assertMembers(VLADIMIR);
    assertDummyGroupByName(RESOURCE_DUMMY_RANGES_ROLE.name, VALID_GROUP).display().assertMembers(VLADIMIR);
    assertDummyGroupByName(RESOURCE_DUMMY_RANGES_ROLE.name, MP_TESTERS).display().assertMembers();
}
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) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test) AbstractEmptyModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractEmptyModelIntegrationTest)

Example 37 with DummyAccount

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

the class TestMappingAutoInbound method test403removeAllAssignments.

@Test
public void test403removeAllAssignments() throws Exception {
    DummyGroup testersGroup = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getGroupByName(GROUP_DUMMY_TESTERS_NAME);
    testersGroup.removeMember(USER_HERMAN_USERNAME);
    DummyAccount hermanAccount = getDummyAccount(RESOURCE_DUMMY_AUTOGREEN_NAME, USER_HERMAN_USERNAME);
    hermanAccount.removeAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, Arrays.asList("graphic", "cratic"));
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    // WHEN
    when();
    unassignRole(userHermanOid, ROLE_ADMINS_OID);
    // THEN
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(userHermanOid);
    display("User after", userAfter);
    assertAssignedRole(userAfter, ROLE_AUTOCRATIC_OID);
    assertAssignments(userAfter, 1);
}
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) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 38 with DummyAccount

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

the class TestMappingAutoInbound method test100ImportFromResource.

/**
 * MID-2104
 */
@Test
public void test100ImportFromResource() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    DummyAccount accountHerman = new DummyAccount(USER_HERMAN_USERNAME);
    accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, USER_HERMAN_FULL_NAME);
    accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "matic");
    getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).addAccount(accountHerman);
    // Preconditions
    assertUsers(getNumberOfUsers());
    // WHEN
    when();
    modelService.importFromResource(RESOURCE_DUMMY_AUTOGREEN_OID, new QName(MidPointConstants.NS_RI, SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), task, result);
    // THEN
    then();
    OperationResult subresult = result.getLastSubresult();
    TestUtil.assertInProgress("importAccountsFromResource result", subresult);
    waitForTaskFinish(task, true, 40000);
    // THEN
    then();
    assertSuccess(task.getResult());
    SearchResultList<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
    display("Users after import", users);
    PrismObject<UserType> userHermanAfter = findUserByUsername(USER_HERMAN_USERNAME);
    display("User after", userHermanAfter);
    userHermanOid = userHermanAfter.getOid();
    assertUser(userHermanAfter, userHermanAfter.getOid(), USER_HERMAN_USERNAME, USER_HERMAN_FULL_NAME, null, null);
    assertAssignedRole(userHermanAfter, ROLE_AUTOMATIC_OID);
    assertAssignments(userHermanAfter, 1);
    assertEquals("Unexpected number of users", getNumberOfUsers() + 1, users.size());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) 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 39 with DummyAccount

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

the class TestOrgStruct method assertJackOrgtarget.

private void assertJackOrgtarget(String expectedShip, String... expectedTitleValues) throws Exception {
    DummyAccount account = assertDummyAccount(RESOURCE_DUMMY_ORGTARGET_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_FULL_NAME, true);
    displayDumpable("orgtarget account", account);
    String shipAccountValue = account.getAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME);
    assertEquals("Jack's ship is wrong", expectedShip, shipAccountValue);
    Set<String> titleAccountValues = account.getAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, String.class);
    if (titleAccountValues == null && expectedTitleValues.length == 0) {
        return;
    }
    PrismAsserts.assertEqualsCollectionUnordered("Jack's titles are wrong", titleAccountValues, expectedTitleValues);
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 40 with DummyAccount

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

the class AbstractInboundSyncTest method test122ModifyDummyEmeraldAccountMancombSeepNULL.

@Test
public void test122ModifyDummyEmeraldAccountMancombSeepNULL() 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 SeepNULL");
    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 SeepNULL");
    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.assertNoItem(userAfter, UserType.F_FULL_NAME);
    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)

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