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();
}
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);
}
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());
}
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);
}
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);
}
Aggregations