use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class ShadowAttributeIdSyncStoreReadTest method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
dummy = initDummyResource("id", RESOURCE_DUMMY_FILE, RESOURCE_ID, controller -> {
controller.extendSchemaPirate();
DummyObjectClass accountClazz = controller.getDummyResource().getAccountObjectClass();
accountClazz.addAttributeDefinition("familyName");
accountClazz.addAttributeDefinition("id");
}, initTask, initResult);
DummyAccount testAccount = dummy.addAccount("idTest");
// testAccount.setId(SHADOW_ID);
// testAccount.addAttributeValue("oid", SHADOW_ID);
testAccount.setEnabled(true);
testAccount.addAttributeValue("id", SHADOW_ID);
testAccount.addAttributeValue("familyName", "Snow");
List<PrismObject<ShadowType>> shadows = repositoryService.searchObjects(ShadowType.class, null, null, initResult);
for (PrismObject<ShadowType> shadow : shadows) {
repositoryService.deleteObject(ShadowType.class, shadow.getOid(), initResult);
}
// repoAddObjectFromFile(SHADOW_3_FILE, initResult);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestModelServiceContract method test190ModifyUserJackAssignAccountAndModify.
/**
* We try to both assign an account and modify that account in one operation.
* Some changes should be reflected to account (e.g. weapon) as the mapping is weak,
* other should be overridden (e.g. fullname) as the mapping is strong.
*/
@Test
public void test190ModifyUserJackAssignAccountAndModify() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(USER_JACK_OID, RESOURCE_DUMMY_OID, null, true);
ShadowCoordinatesQualifiedObjectDelta<ShadowType> accountDelta = RefineryObjectFactory.createShadowDiscriminatorModificationReplaceProperty(ShadowType.class, RESOURCE_DUMMY_OID, ShadowKindType.ACCOUNT, null, dummyResourceCtl.getAttributeFullnamePath(), prismContext, "Cpt. Jack Sparrow");
accountDelta.addModificationAddProperty(dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME), "smell");
deltas.add(accountDelta);
deltas.add(accountAssignmentUserDelta);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
when();
executeChanges(deltas, null, task, result);
then();
assertSuccess(result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Jack Sparrow");
accountJackOid = getSingleLinkOid(userJack);
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result);
assertDummyAccountShadowRepo(accountShadow, accountJackOid, USER_JACK_USERNAME);
assertEnableTimestampShadow(accountShadow, startTime, endTime);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertDummyAccountShadowModel(accountModel, accountJackOid, USER_JACK_USERNAME, "Cpt. Jack Sparrow");
assertEnableTimestampShadow(accountModel, startTime, endTime);
// Check account in dummy resource
assertDefaultDummyAccount(USER_JACK_USERNAME, "Cpt. Jack Sparrow", true);
DummyAccount dummyAccount = getDummyAccount(null, USER_JACK_USERNAME);
assertDummyAccountAttribute(null, USER_JACK_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "smell");
assertNull("Unexpected loot", dummyAccount.getAttributeValue("loot", Integer.class));
assertDummyScriptsAdd(userJack, accountModel, getDummyResourceType());
// 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.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
// Check notifications
notificationManager.setDisabled(true);
checkDummyTransportMessages(NOTIFIER_ACCOUNT_PASSWORD_NAME, 1);
checkDummyTransportMessages("userPasswordNotifier", 0);
checkDummyTransportMessages("simpleAccountNotifier-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-FAILURE", 0);
checkDummyTransportMessages("simpleAccountNotifier-ADD-SUCCESS", 1);
checkDummyTransportMessages("simpleAccountNotifier-DELETE-SUCCESS", 0);
checkDummyTransportMessages("simpleUserNotifier", 1);
checkDummyTransportMessages("simpleUserNotifier-ADD", 0);
assertCounterIncrement(InternalCounters.SCRIPT_COMPILE_COUNT, 0);
assertSteadyResources();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestPreviewChanges method test240GuybrushAssignAccountDummyRelative.
/**
* Make sure that Guybrush has an existing account and that it is properly populated.
* We will use this setup in following tests.
*/
@Test
public void test240GuybrushAssignAccountDummyRelative() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
// WHEN
when();
assignAccountToUser(USER_GUYBRUSH_OID, RESOURCE_DUMMY_RELATIVE_OID, null, task, result);
// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
DummyAccount dummyAccount = assertDummyAccount(RESOURCE_DUMMY_RELATIVE_NAME, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, true);
displayDumpable("Dummy account after", dummyAccount);
dummyAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Great Pirate");
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestMappingAdvanced method test320GiveMagnusExtraValuesAndModifyUser.
/**
* Add some extra values to the account and simply modify magnus. Ranges should throw (some of) them out.
*
* Extra values:
* - 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 test320GiveMagnusExtraValuesAndModifyUser() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
DummyAccount magnus = RESOURCE_DUMMY_RANGES_DIRECT.controller.getDummyResource().getAccountByUsername(MAGNUS);
magnus.addAttributeValue(ATTR_ORGANIZATION, "mp_garbage");
DummyGroup testers = RESOURCE_DUMMY_RANGES_DIRECT.controller.getDummyResource().getGroupByName(MP_TESTERS);
testers.addMember(MAGNUS);
ObjectDelta<UserType> delta = deltaFor(UserType.class).item(UserType.F_FULL_NAME).replace(PolyString.fromOrig("Magnus Carlsen")).asObjectDelta(USER_MAGNUS.oid);
when();
traced(() -> executeChanges(delta, null, task, result));
then();
assertSuccess(task);
assertDummyAccountByUsername(RESOURCE_DUMMY_RANGES_DIRECT.name, MAGNUS).display().assertAttribute(ATTR_ORGANIZATION, "mp_FIDE", "valid");
assertDummyGroupByName(RESOURCE_DUMMY_RANGES_DIRECT.name, MP_USERS).display().assertMembers(MAGNUS);
assertDummyGroupByName(RESOURCE_DUMMY_RANGES_DIRECT.name, VALID_GROUP).display().assertMembers(MAGNUS);
assertDummyGroupByName(RESOURCE_DUMMY_RANGES_DIRECT.name, MP_TESTERS).display().assertMembers();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestMappingAdvanced method test360GiveVladimirExtraValuesAndRecompute.
/**
* Add some extra values to the account and use recompute. Ranges should throw (some of) them out.
*
* Extra values:
* - 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 test360GiveVladimirExtraValuesAndRecompute() 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");
vladimir.addAttributeValue(ATTR_ORGANIZATION, "valid");
DummyGroup testers = RESOURCE_DUMMY_RANGES_ROLE.controller.getDummyResource().getGroupByName(MP_TESTERS);
testers.addMember(VLADIMIR);
DummyGroup validGroup = RESOURCE_DUMMY_RANGES_ROLE.controller.getDummyResource().getGroupByName(VALID_GROUP);
validGroup.addMember(VLADIMIR);
when();
traced(() -> recomputeUser(USER_VLADIMIR.oid, 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();
}
Aggregations