use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestRecomputeTask method test130RecomputeLight.
/**
* Light recompute. Very efficient, no resource operations, just fix the focus.
* MID-3384
*/
@Test
public void test130RecomputeLight() throws Exception {
final String TEST_NAME = "test130RecomputeLight";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// Preconditions
assertUsers(6);
PrismObject<UserType> usetJackBefore = getUser(USER_JACK_OID);
display("User jack before", usetJackBefore);
assertAssignedRole(usetJackBefore, ROLE_JUDGE_OID);
assertRoleMembershipRef(usetJackBefore, ROLE_JUDGE_OID);
assignOrg(USER_GUYBRUSH_OID, ORG_MINISTRY_OF_OFFENSE_OID, null);
PrismObject<UserType> usetGuybrushBefore = getUser(USER_GUYBRUSH_OID);
display("User guybrush before", usetGuybrushBefore);
assertAssignedRole(usetGuybrushBefore, ROLE_PIRATE_OID);
assertRoleMembershipRef(usetGuybrushBefore, ROLE_PIRATE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertAssignedOrgs(usetGuybrushBefore, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(usetGuybrushBefore, ORG_MINISTRY_OF_OFFENSE_OID);
clearUserOrgAndRoleRefs(USER_JACK_OID);
clearUserOrgAndRoleRefs(USER_GUYBRUSH_OID);
rememberShadowFetchOperationCount();
rememberConnectorOperationCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(TASK_USER_RECOMPUTE_LIGHT_FILE);
dummyAuditService.clear();
waitForTaskStart(TASK_USER_RECOMPUTE_LIGHT_OID, false);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskFinish(TASK_USER_RECOMPUTE_LIGHT_OID, true, 40000);
// THEN
TestUtil.displayThen(TEST_NAME);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after recompute", users);
assertShadowFetchOperationCountIncrement(0);
assertConnectorOperationIncrement(0);
assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
// Red resource does not delete accounts on deprovision, it disables them
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
// Herman should be recomputed now
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", false);
TaskType recomputeTask = getTask(TASK_USER_RECOMPUTE_LIGHT_OID).asObjectable();
assertEquals("Wrong success count", 6, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalSuccessCount());
assertEquals("Wrong failure count", 0, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalFailureCount());
PrismObject<UserType> usetJackAfter = getUser(USER_JACK_OID);
display("User jack after", usetJackAfter);
assertAssignedRole(usetJackAfter, ROLE_JUDGE_OID);
assertRoleMembershipRef(usetJackAfter, ROLE_JUDGE_OID);
PrismObject<UserType> usetGuybrushAfter = getUser(USER_GUYBRUSH_OID);
display("User guybrush after", usetGuybrushAfter);
assertAssignedRole(usetGuybrushAfter, ROLE_PIRATE_OID);
assertRoleMembershipRef(usetGuybrushAfter, ROLE_PIRATE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertAssignedOrgs(usetGuybrushAfter, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(usetGuybrushAfter, ORG_MINISTRY_OF_OFFENSE_OID);
assertUsers(6);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestRecomputeTask method test120RecomputeByExpression.
/**
* Here we recompute herman as well.
*/
@Test
public void test120RecomputeByExpression() throws Exception {
final String TEST_NAME = "test120RecomputeByExpression";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// Preconditions
assertUsers(6);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", true);
result.computeStatus();
TestUtil.assertSuccess(result);
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_FILE);
dummyAuditService.clear();
waitForTaskStart(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, false);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskFinish(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID, true, 40000);
// THEN
TestUtil.displayThen(TEST_NAME);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after recompute", users);
assertDummyAccount(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, "Guybrush Threepwood", true);
assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "cutlass", "dagger");
assertNoDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
// Red resource does not delete accounts on deprovision, it disables them
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", false);
// Herman should be recomputed now
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_HERMAN_USERNAME, "Herman Toothrot", false);
TaskType recomputeTask = getTask(TASK_USER_RECOMPUTE_HERMAN_BY_EXPRESSION_OID).asObjectable();
assertEquals("Wrong success count", 1, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalSuccessCount());
assertEquals("Wrong failure count", 0, recomputeTask.getOperationStats().getIterativeTaskInformation().getTotalFailureCount());
assertUsers(6);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestUuid method test210ReconcileDummyUuidAddAugustus.
@Test
public void test210ReconcileDummyUuidAddAugustus() throws Exception {
final String TEST_NAME = "test210ReconcileDummyUuidAddAugustus";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount account = new DummyAccount(ACCOUNT_AUGUSTUS_NAME);
account.setEnabled(true);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
dummyResourceUuid.addAccount(account);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
rememberShadowFetchOperationCount();
reconciliationTaskResultListener.clear();
Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
// WHEN
TestUtil.displayWhen(TEST_NAME);
restartTask(TASK_RECONCILE_DUMMY_UUID_OID);
// THEN
TestUtil.displayThen(TEST_NAME);
waitForTaskNextRunAssertSuccess(taskBefore, true);
// THEN
TestUtil.displayThen(TEST_NAME);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByUsername(ACCOUNT_AUGUSTUS_NAME, RESOURCE_DUMMY_UUID_OID);
assertDummyAccountAttribute(RESOURCE_DUMMY_UUID_NAME, ACCOUNT_AUGUSTUS_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
assertEquals("Unexpected number of users", 6, users.size());
display("Dummy resource", getDummyResource().debugDump());
assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_UUID_OID);
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_UUID_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertSuccess(reconTaskResult);
PrismObject<UserType> user = findUserByUsername(USER_AUGUSTUS_NAME);
display("Augustus after recon", user);
augustusShadowOid = getSingleLinkOid(user);
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, augustusShadowOid, null, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestUuid method test220ReconcileDummyUuidDeleteAddAugustus.
/**
* Augustus is deleted and re-added with the same username. New shadow needs to be created.
*/
@Test
public void test220ReconcileDummyUuidDeleteAddAugustus() throws Exception {
final String TEST_NAME = "test220ReconcileDummyUuidDeleteAddAugustus";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestUuid.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
DummyAccount oldAccount = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTUS_NAME);
dummyResourceUuid.deleteAccountByName(ACCOUNT_AUGUSTUS_NAME);
assertNoDummyAccount(ACCOUNT_AUGUSTUS_NAME, ACCOUNT_AUGUSTUS_NAME);
DummyAccount account = new DummyAccount(ACCOUNT_AUGUSTUS_NAME);
account.setEnabled(true);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, USER_AUGUSTUS_NAME);
dummyResourceUuid.addAccount(account);
account = dummyResourceUuid.getAccountByUsername(ACCOUNT_AUGUSTUS_NAME);
assertFalse("Account IDs not changed", oldAccount.getId().equals(account.getId()));
display("Old shadow OID", augustusShadowOid);
display("Account ID " + oldAccount.getId() + " -> " + account.getId());
Task taskBefore = taskManager.getTask(TASK_RECONCILE_DUMMY_UUID_OID, result);
getDummyResource().purgeScriptHistory();
dummyAuditService.clear();
rememberShadowFetchOperationCount();
reconciliationTaskResultListener.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
restartTask(TASK_RECONCILE_DUMMY_UUID_OID);
// THEN
TestUtil.displayThen(TEST_NAME);
waitForTaskNextRunAssertSuccess(taskBefore, true);
// THEN
TestUtil.displayThen(TEST_NAME);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_UUID_OID, 0, 1, 0, 0);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after import", users);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByUsername(ACCOUNT_AUGUSTUS_NAME, RESOURCE_DUMMY_UUID_OID);
assertDummyAccountAttribute(RESOURCE_DUMMY_UUID_NAME, ACCOUNT_AUGUSTUS_NAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, ACCOUNT_AUGUSTUS_FULLNAME);
assertEquals("Unexpected number of users", 6, users.size());
display("Dummy resource", getDummyResource().debugDump());
assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_UUID_OID);
// Task result
PrismObject<TaskType> reconTaskAfter = getTask(TASK_RECONCILE_DUMMY_UUID_OID);
OperationResultType reconTaskResult = reconTaskAfter.asObjectable().getResult();
display("Recon task result", reconTaskResult);
TestUtil.assertSuccess(reconTaskResult);
PrismObject<UserType> user = findUserByUsername(USER_AUGUSTUS_NAME);
display("Augustus after recon", user);
String newAugustusShadowOid = getSingleLinkOid(user);
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, newAugustusShadowOid, null, result);
assertFalse("Shadow OID is not changed", augustusShadowOid.equals(newAugustusShadowOid));
augustusShadowOid = newAugustusShadowOid;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TestImportRecon method test900DeleteDummyShadows.
@Test
public void test900DeleteDummyShadows() throws Exception {
final String TEST_NAME = "test900DeleteDummyShadows";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// Preconditions
assertUsers(18);
dummyAuditService.clear();
rememberShadowFetchOperationCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
importObjectFromFile(TASK_DELETE_DUMMY_SHADOWS_FILE);
// THEN
TestUtil.displayThen(TEST_NAME);
waitForTaskFinish(TASK_DELETE_DUMMY_SHADOWS_OID, true, 20000);
// THEN
TestUtil.displayThen(TEST_NAME);
assertShadowFetchOperationCountIncrement(0);
PrismObject<TaskType> deleteTask = getTask(TASK_DELETE_DUMMY_SHADOWS_OID);
OperationResultType deleteTaskResultType = deleteTask.asObjectable().getResult();
display("Final delete task result", deleteTaskResultType);
TestUtil.assertSuccess(deleteTaskResultType);
OperationResult deleteTaskResult = OperationResult.createOperationResult(deleteTaskResultType);
TestUtil.assertSuccess(deleteTaskResult);
List<OperationResult> opExecResults = deleteTaskResult.findSubresults(ModelService.EXECUTE_CHANGES);
assertEquals(1, opExecResults.size());
OperationResult opExecResult = opExecResults.get(0);
TestUtil.assertSuccess(opExecResult);
assertEquals("Wrong exec operation count", 17, opExecResult.getCount());
assertTrue("Too many subresults: " + deleteTaskResult.getSubresults().size(), deleteTaskResult.getSubresults().size() < 10);
assertUsers(18);
assertDummyAccountShadows(0, true, task, result);
assertDummyAccountShadows(17, false, task, result);
}
Aggregations