use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestTrafo method test210Smith222Add.
/**
* Attempt to add two employees that are boh "John Smith". This is the second user. There should be a naming conflict.
* Note: this is a different case than jack-angelica. Jack and Angelica are "externists". Smithes are employees (type "T")
*/
@Test
public void test210Smith222Add() throws Exception {
final String TEST_NAME = "test210Smith222Add";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
addObject(USER_SMITH222_FILE);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userSmith = getUser(USER_SMITH222_OID);
display("User smith222 after change execution", userSmith);
assertUser(userSmith, USER_SMITH222_OID, USER_SMITH222_USERNAME, "John Smith", "John", "Smith");
assertLinks(userSmith, 2);
String accountAdOid = getLinkRefOid(userSmith, RESOURCE_DUMMY_AD_OID);
String accountMailOid = getLinkRefOid(userSmith, RESOURCE_DUMMY_MAIL_OID);
// AD ACCOUNT
// Check shadow
PrismObject<ShadowType> accountAdShadow = repositoryService.getObject(ShadowType.class, accountAdOid, null, result);
assertAccountShadowRepo(accountAdShadow, accountAdOid, ACCOUNT_SMITH222_AD_DN, resourceDummyAdType, caseIgnoreMatchingRule);
// Check account
PrismObject<ShadowType> accountAdModel = modelService.getObject(ShadowType.class, accountAdOid, null, task, result);
display("AD shadow", accountAdModel);
assertAccountShadowModel(accountAdModel, accountAdOid, ACCOUNT_SMITH222_AD_DN, resourceDummyAdType, caseIgnoreMatchingRule);
assertAdministrativeStatusEnabled(accountAdModel);
smith222AdIcfUid = getIcfUid(accountAdModel);
// Check account in dummy resource
assertDummyAccountById(RESOURCE_DUMMY_AD_ID, smith222AdIcfUid);
assertDummyAccount(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN);
assertDummyAccountActivation(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, true);
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_SAM_ACCOUNT_NAME_NAME, ACCOUNT_SMITH222_AD_SAM_NAME);
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_USER_PRINCIPAL_NAME_NAME, ACCOUNT_SMITH222_AD_SAM_NAME + "@" + TRAFO_MAIL_DOMAIN);
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_GIVEN_NAME_NAME, "John");
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_SN_NAME, "Smith");
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_MAIL_NAME, "John.Smith2@" + TRAFO_MAIL_DOMAIN);
assertDummyAccountNoAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_TELEPHONE_NUMBER_NAME);
assertDummyAccountAttribute(RESOURCE_DUMMY_AD_ID, ACCOUNT_SMITH222_AD_DN, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_AD_USER_SHARED_FOLDER_OTHER_NAME, "\\\\medusa\\User\\Smith_smith222");
// MAIL ACCOUNT
// Check shadow
PrismObject<ShadowType> accountMailShadow = repositoryService.getObject(ShadowType.class, accountMailOid, null, result);
assertAccountShadowRepo(accountMailShadow, accountMailOid, ACCOUNT_SMITH222_MAIL_USERNAME, resourceDummyMailType, caseIgnoreMatchingRule);
// Check account
PrismObject<ShadowType> accountMailModel = modelService.getObject(ShadowType.class, accountMailOid, null, task, result);
display("Mail shadow", accountMailModel);
assertAccountShadowModel(accountMailModel, accountMailOid, ACCOUNT_SMITH222_MAIL_USERNAME, resourceDummyMailType, caseIgnoreMatchingRule);
assertAdministrativeStatusEnabled(accountMailModel);
smith222MailIcfUid = getIcfUid(accountMailModel);
// Check account in dummy resource
assertDummyAccountById(RESOURCE_DUMMY_MAIL_ID, smith222MailIcfUid);
assertDummyAccount(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME);
assertDummyAccountActivation(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, true);
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_INTERNET_ADDRESS_NAME, "John.Smith2@" + TRAFO_MAIL_DOMAIN);
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_FIRST_NAME_NAME, "John");
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_LAST_NAME_NAME, "Smith2");
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_ID_FILE_NAME, "c:\\install\\test-id-folder\\jsmith2.id");
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_SHORT_NAME_NAME, "PS222", "jsmith2");
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_MAIL_FILE_NAME_NAME, "mail\\js222");
assertDummyAccountAttribute(RESOURCE_DUMMY_MAIL_ID, ACCOUNT_SMITH222_MAIL_USERNAME, DUMMY_ACCOUNT_ATTRIBUTE_MAIL_MAIL_DOMAIN_NAME, "TRAFO");
// Set by inbound mappings
PrismAsserts.assertPropertyValue(userSmith, UserType.F_EMAIL_ADDRESS, "John.Smith2@" + TRAFO_MAIL_DOMAIN);
PrismAsserts.assertPropertyValue(userSmith, new ItemPath(UserType.F_EXTENSION, TRAFO_EXTENSION_HOMEDIR_QNAME), "\\\\medusa\\User\\Smith_smith222");
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(5);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0, 3);
// primary
dummyAuditService.assertHasDelta(0, ChangeType.ADD, UserType.class);
// link
dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class);
// AD account
dummyAuditService.assertHasDelta(0, ChangeType.ADD, ShadowType.class);
dummyAuditService.assertExecutionDeltas(1, 3);
// link, inbound (2 deltas)
dummyAuditService.assertHasDelta(1, ChangeType.MODIFY, UserType.class);
// Mail account
dummyAuditService.assertHasDelta(1, ChangeType.ADD, ShadowType.class);
dummyAuditService.assertExecutionDeltas(2, 2);
// inbound
dummyAuditService.assertHasDelta(2, ChangeType.MODIFY, UserType.class);
// AD account
dummyAuditService.assertHasDelta(2, ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionDeltas(3, 1);
// inbound - SHOULD THIS BE HERE?? FIXME
dummyAuditService.assertHasDelta(3, ChangeType.MODIFY, UserType.class);
dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestConsistencySimple method executeTest.
private void executeTest(final String TEST_NAME, FocusOperation focusOperation, ShadowOperation shadowOperation, ResourceObjectOperation resourceObjectOperation) throws Exception {
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestConsistencySimple.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
cleanUpBeforeTest(task, result);
assignAccount(USER_JACK_OID, RESOURCE_DUMMY_OID, SchemaConstants.INTENT_DEFAULT, task, result);
PrismObject<UserType> jack = getUser(USER_JACK_OID);
display("Jack with account", jack);
assertEquals("Unexpected # of accounts for jack", 1, jack.asObjectable().getLinkRef().size());
ShadowType shadow = getObject(ShadowType.class, jack.asObjectable().getLinkRef().get(0).getOid()).asObjectable();
display("Shadow", shadow);
if (shadowOperation != ShadowOperation.KEEP) {
@SuppressWarnings("unchecked") ObjectDelta<UserType> removeLinkRefDelta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_LINK_REF).replace().asObjectDelta(USER_JACK_OID);
executeChanges(removeLinkRefDelta, ModelExecuteOptions.createRaw(), task, result);
jack = getUser(USER_JACK_OID);
assertEquals("Unexpected # of accounts for jack after linkRef removal", 0, jack.asObjectable().getLinkRef().size());
if (shadowOperation == ShadowOperation.DELETE) {
deleteObjectRaw(ShadowType.class, shadow.getOid(), task, result);
assertNoObject(ShadowType.class, shadow.getOid());
} else {
if (shadowOperation == ShadowOperation.UNLINK_AND_TOMBSTONE) {
@SuppressWarnings("unchecked") ObjectDelta<ShadowType> markAsDead = (ObjectDelta<ShadowType>) DeltaBuilder.deltaFor(ShadowType.class, prismContext).item(ShadowType.F_DEAD).replace(Boolean.TRUE).asObjectDelta(shadow.getOid());
executeChanges(markAsDead, ModelExecuteOptions.createRaw(), task, result);
}
assertNotNull("jack's shadow does not exist", getObject(ShadowType.class, shadow.getOid()));
}
}
if (resourceObjectOperation == ResourceObjectOperation.DELETE) {
getDummyResource().deleteAccountByName("jack");
assertNoDummyAccount(null, "jack");
} else {
assertDummyAccount(null, "jack");
}
// WHEN
switch(focusOperation) {
case RECOMPUTE:
recomputeUser(USER_JACK_OID, task, result);
break;
case RECONCILE:
ObjectDelta<UserType> emptyDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(emptyDelta), ModelExecuteOptions.createReconcile(), task, result);
break;
default:
throw new IllegalArgumentException("focusOperation: " + focusOperation);
}
// THEN
result.computeStatus();
if (ASSERT_SUCCESS) {
TestUtil.assertSuccess(result);
}
jack = getUser(USER_JACK_OID);
display("Jack after " + focusOperation, jack);
assertEquals("Unexpected # of accounts for jack", 1, jack.asObjectable().getLinkRef().size());
String shadowOidAfter = jack.asObjectable().getLinkRef().get(0).getOid();
// check the shadow really exists
assertNotNull("jack's shadow does not exist after " + focusOperation, getObject(ShadowType.class, shadowOidAfter));
// check number of jack's shadows
List<PrismObject<ShadowType>> shadows = getJacksShadows(result);
display("Shadows for 'jack' on dummy resource", shadows);
// TODO some of them may be marked as dead (solve if this occurs)
assertEquals("Unexpected # of dummy shadows for 'jack'", 1, shadows.size());
// other checks
assertDummyAccount(null, "jack");
cleanUpAfterTest(task, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestIteration method cleanUpJupiter.
protected void cleanUpJupiter(String TEST_NAME) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException, SchemaViolationException, ConflictException {
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestIteration.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
deltas.add(createAccountAssignmentUserDelta(jupiterUserOid, RESOURCE_DUMMY_FUCHSIA_OID, "default", false));
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
// jupiter
PrismObject<UserType> userJupiterAfter = findUserByUsername(USER_JUPITER_NAME);
display("User after change execution", userJupiterAfter);
assertUserJupiter(userJupiterAfter);
assertEquals("Unexpected number of linkRefs", 0, userJupiterAfter.asObjectable().getLinkRef().size());
assertNull("Unexpected account for jupiter", getDummyAccount(RESOURCE_DUMMY_FUCHSIA_NAME, ACCOUNT_JUPITER_DUMMY_FUCHSIA_USERNAME));
// TODO Check audit
display("Audit", dummyAuditService);
// dummyAuditService.assertRecords(3);
// dummyAuditService.assertSimpleRecordSanity();
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertExecutionDeltas(2);
// dummyAuditService.asserHasDelta(ChangeType.MODIFY, UserType.class);
// dummyAuditService.asserHasDelta(ChangeType.ADD, ShadowType.class);
// dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestMapping method test214ModifyUserLocalityIOError.
/**
* MID-3661
*/
@Test
public void test214ModifyUserLocalityIOError() throws Exception {
final String TEST_NAME = "test214ModifyUserLocalityIOError";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode();
DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
display("Dummy account before", dummyAccountBefore);
// Make sure that only get is broken and not modify. We want to give the test
// a chance to destroy data.
getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).setGetBreakMode(BreakMode.IO);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyUserReplace(USER_GUYBRUSH_OID, UserType.F_LOCALITY, task, result, createPolyString("Booty Island"));
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode();
PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
display("User after", userAfter);
assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
String accountOid = getSingleLinkOid(userAfter);
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
display("Repo shadow after", repoShadow);
assertNoPostponedOperation(repoShadow);
// Check account in dummy resource
DummyAccount dummyAccountAfter = assertDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
display("Dummy account after", dummyAccountAfter);
// TODO: How? Why?
assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Booty Island");
assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "vodka", "whisky", "rum from Scabb Island");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.UserType in project midpoint by Evolveum.
the class TestMapping method test142ModifyUserLocality.
/**
* location mapping is STRONG
*/
@Test
public void test142ModifyUserLocality() throws Exception {
final String TEST_NAME = "test142ModifyUserLocality";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestMapping.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
// WHEN
modifyUserReplace(USER_JACK_OID, UserType.F_LOCALITY, task, result, PrismTestUtil.createPolyString("Fountain of Youth"));
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Captain Jack Sparrow", "Jack", "Sparrow", "Fountain of Youth");
assertAccountLocation(userJack, "Captain Jack Sparrow", "Fountain of Youth", dummyResourceCtl, task);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionSuccess();
}
Aggregations