use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestImportRecon method test402ReconcileDummyLimeKateOnlyGrog.
@Test
public void test402ReconcileDummyLimeKateOnlyGrog() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount accountKate = dummyResourceLime.getAccountByUsername(ACCOUNT_CAPSIZE_NAME);
accountKate.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "grog");
PrismObject<UserType> userBefore = findUserByUsername(ACCOUNT_CAPSIZE_NAME);
dummyResourceLime.purgeScriptHistory();
dummyAuditService.clear();
reconciliationResultListener.clear();
// WHEN
when();
reconcileUser(userBefore.getOid(), task, result);
// THEN
then();
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = findUserByUsername(ACCOUNT_CAPSIZE_NAME);
display("User after reconcile", userAfter);
PrismAsserts.assertPropertyValue(userAfter, UserType.F_COST_CENTER, "grog");
// MID-7110
// displayDumpable("Audit", dummyAuditService);
// dummyAuditService.assertRecords(2);
// dummyAuditService.assertSimpleRecordSanity();
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertExecutionDeltas(1);
// dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
// PrismAsserts.assertModifications(dummyAuditService.getExecutionDelta(0).getObjectDelta(), 7);
// dummyAuditService.assertTarget(userBefore.getOid());
// dummyAuditService.assertExecutionSuccess();
assertUsers(getNumberOfUsers() + 6);
displayValue("Dummy resource (lime)", dummyResourceLime.debugDump());
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestImportRecon method test164ImportFromResourceDummyLimeRappOrganizationNull.
/**
* MID-2427
*/
@Test
public void test164ImportFromResourceDummyLimeRappOrganizationNull() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount accountRappLimeBefore = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
accountRappLimeBefore.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME);
displayDumpable("Rapp lime account before", accountRappLimeBefore);
// Preconditions
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT, createPolyString("The crew of The Elaine"));
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATION, createPolyString(ORG_SCUMM_BAR_NAME));
assertAssignedOrg(userRappBefore, ORG_SCUMM_BAR_OID);
assertAssignments(userRappBefore, 1);
assertUsers(getNumberOfUsers() + 4);
loginImportUser();
dummyAuditService.clear();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
modelService.importFromResource(RESOURCE_DUMMY_LIME_OID, DUMMY_LIME_ACCOUNT_OBJECT_CLASS, task, result);
// THEN
then();
OperationResult subresult = result.getLastSubresult();
TestUtil.assertInProgress("importAccountsFromResource result", subresult);
loginAdministrator();
waitForTaskFinish(task, false, 40000);
// THEN
then();
assertSuccess(task.getResult());
dumpStatistics(task);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_RUM_NAME, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_MURRAY_NAME, RESOURCE_DUMMY_LIME_OID);
PrismObject<UserType> userRappAfter = getUser(USER_RAPP_OID);
display("User rapp after", userRappAfter);
PrismAsserts.assertPropertyValue(userRappAfter, UserType.F_ORGANIZATIONAL_UNIT, createPolyString("The crew of The Elaine"));
PrismAsserts.assertNoItem(userRappAfter, UserType.F_ORGANIZATION);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
DummyAccount accountRappLimeAfter = dummyResourceLime.getAccountByUsername(USER_RAPP_USERNAME);
displayDumpable("Rapp lime account after", accountRappLimeAfter);
assertNoAssignments(userRappAfter);
assertUsers(getNumberOfUsers() + 4);
// Check audit
assertImportAuditModifications(1);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestImportRecon method test220ReconcileDummyBrokenGuybrush.
/**
* The resource itself works, just the guybrush account is broken.
*/
@Test
public void test220ReconcileDummyBrokenGuybrush() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
// Lets do some local changes on dummy resource ...
DummyAccount guybrushDummyAccount = getDummyResource().getAccountByUsername(ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
// location has strong outbound mapping, this change should be corrected
guybrushDummyAccount.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Forbidden Dodecahedron");
// BREAK it!
getDummyResource().setBreakMode(BreakMode.NONE);
guybrushDummyAccount.setModifyBreakMode(BreakMode.NETWORK);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
reconciliationResultListener.clear();
// WHEN
when();
restartTask(TASK_RECONCILE_DUMMY_OID);
Task taskAfter = waitForTaskFinish(TASK_RECONCILE_DUMMY_OID, false, DEFAULT_TASK_WAIT_TIMEOUT, true);
// THEN
then();
dumpStatistics(taskAfter);
assertTask(taskAfter, "task after").display().activityState(RECONCILIATION_RESOURCE_OBJECTS_PATH).display().synchronizationStatistics().assertTransition(LINKED, LINKED, LINKED, null, 4, 1, // error is guybrush
0).assertTransition(null, null, null, PROTECTED, 0, 0, 2).assertTransitions(2).end().itemProcessingStatistics().display().assertTotalCounts(6, 1).end().progress().display().end();
// .assertProgress(7); // TODO - specify meaning of progress for reconciliation tasks
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after reconciliation (broken resource account)", users);
reconciliationResultListener.assertResult(RESOURCE_DUMMY_OID, 0, 7, 1, 2);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME, RESOURCE_DUMMY_OID);
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
assertEquals("Unexpected number of users", getNumberOfUsers() + 4, users.size());
displayValue("Dummy resource", getDummyResource().debugDump());
display("Script history", getDummyResource().getScriptHistory());
ArrayList<ProvisioningScriptSpec> scripts = new ArrayList<>();
addReconScripts(scripts, ACCOUNT_HERMAN_DUMMY_USERNAME, "Herman Toothrot", false);
// Guybrush is broken.
addReconScripts(scripts, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true, false);
addReconScripts(scripts, ACCOUNT_ELAINE_DUMMY_USERNAME, "Elaine Marley", false);
addReconScripts(scripts, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, false);
addReconScripts(scripts, ACCOUNT_STAN_NAME, ACCOUNT_STAN_FULLNAME, false);
IntegrationTestTools.assertScripts(getDummyResource().getScriptHistory(), scripts.toArray(new ProvisioningScriptSpec[0]));
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertStatus(reconTaskResult, OperationResultStatusType.PARTIAL_ERROR);
// OperationResult reconTaskOpResult = OperationResult.createOperationResult(reconTaskResult);
// // TODO reconsider this
// OperationResult statistics = reconTaskOpResult
// .findSubResultStrictly("com.evolveum.midpoint.common.operation.reconciliation.part2")
// .findSubResultStrictly("com.evolveum.midpoint.common.operation.reconciliation.statistics");
// assertTrue("Errors not mentioned in the task message", statistics.getMessage().contains("got 1 error"));
// Check audit
// MID-7110
// displayDumpable("Audit", dummyAuditService);
// assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_OID);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestSyncStoryUsingLiveSync method test999DeletingNotUpdatedShadowDummyGreen.
@Test
public void test999DeletingNotUpdatedShadowDummyGreen() throws Exception {
String ACCOUNT_JACK_DUMMY_USERNAME = "jack";
String ACCOUNT_CAROL_DUMMY_USERNAME = "carol";
// GIVEN
rememberTimeBeforeSync();
prepareNotifications();
DummyAccount accountCarol = new DummyAccount(ACCOUNT_CAROL_DUMMY_USERNAME);
accountCarol.setEnabled(true);
accountCarol.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Carol Seepgood");
accountCarol.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Melee Island");
DummyAccount accountJack = new DummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
accountJack.setEnabled(true);
accountJack.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Sevenseas");
accountJack.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "The Seven Seas");
// / WHEN
when();
getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(accountJack);
waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME));
importObjectFromFile(TASK_DELETE_NOT_UPDATED_SHADOWS);
TimeUnit.SECONDS.sleep(6);
getDummyResource(RESOURCE_DUMMY_GREEN_NAME).addAccount(accountCarol);
waitForSyncTaskNextRunAssertSuccess(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME));
suspendTask(getSyncTaskOid(getDummyResourceObject(RESOURCE_DUMMY_GREEN_NAME)));
rerunTask(TASK_DELETE_NOT_UPDATED_SHADOWS_OID);
// THEN
then();
PrismObject<UserType> userCarol = findUserByUsername(ACCOUNT_CAROL_DUMMY_USERNAME);
display("User carol", userCarol);
assertNotNull("No carol user", userCarol);
PrismObject<UserType> userJack = findUserByUsername(ACCOUNT_JACK_DUMMY_USERNAME);
display("User jack", userJack);
assertNull("User jack is not null", userJack);
// notifications
displayAllNotifications();
notificationManager.setDisabled(true);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestExpressionCorrelator method test100NoOwner.
/**
* The correlation code returns no owner.
*/
@Test
public void test100NoOwner() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
String accountName = getTestNameShort();
DummyAccount account = DUMMY_RESOURCE_SOURCE.controller.addAccount(accountName);
account.addAttributeValue(ATTR_CORRELATION_CODE, "[]");
when();
CorrelationResult correlationResult = correlateAccount(accountName, task, result);
then();
assertCorrelationResult(correlationResult, NO_OWNER, null);
assertNoCorrelationCase(accountName, task, result);
}
Aggregations