use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestEditSchema method test210UserDefinition.
@Test
public void test210UserDefinition() throws Exception {
final String TEST_NAME = "test210UserDefinition";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {
@Override
public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
assertNotNull("No definition for additionalName in user", propDef);
assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
assertTrue("additionalName not readable", propDef.canRead());
}
}, PrismTestUtil.createPolyString("Jackie"));
assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for costCenter in user", propDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
assertTrue("costCenter not readable", propDef.canRead());
}
});
assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for preferredLanguage in user", propDef);
assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
assertTrue("preferredLanguage not readable", propDef.canRead());
PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
}
});
assertContainer(user, UserType.F_CREDENTIALS, new Validator<PrismContainerDefinition<CredentialsType>>() {
@Override
public void validate(PrismContainerDefinition<CredentialsType> credentialsDef, String name) throws Exception {
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
}
}, true);
assertProperty(user, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertTrue("Password not readable", propDef.canRead());
}
});
assertSteadyResources();
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestRoleEntitlement method test128ModifyRoleUnlinkEntitlement.
@Test
public void test128ModifyRoleUnlinkEntitlement() throws Exception {
final String TEST_NAME = "test128ModifyRoleUnlinkEntitlement";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestRoleEntitlement.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE);
dummyAuditService.clear();
prepareNotifications();
PrismObject<ShadowType> group = PrismTestUtil.parseObject(GROUP_PIRATE_DUMMY_FILE);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createEmptyModifyDelta(RoleType.class, ROLE_PIRATE_OID, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setObject(group);
ReferenceDelta linkDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), groupOid);
roleDelta.addModification(linkDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(roleDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
PrismObject<RoleType> role = getRole(ROLE_PIRATE_OID);
assertLinks(role, 0);
// Check shadow (should be unchanged)
PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, groupOid, null, result);
assertDummyGroupShadowRepo(shadowRepo, groupOid, GROUP_PIRATE_DUMMY_NAME);
// Check group (should be unchanged)
PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, groupOid, null, task, result);
assertDummyGroupShadowModel(shadowModel, groupOid, GROUP_PIRATE_DUMMY_NAME);
// Check group in dummy resource
assertDummyGroup(GROUP_PIRATE_DUMMY_NAME, "Scurvy pirates");
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, RoleType.class);
dummyAuditService.assertTarget(ROLE_PIRATE_OID);
dummyAuditService.assertExecutionSuccess();
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestEditSchema method assertUntouchedUserDefinition.
private void assertUntouchedUserDefinition() {
// WHEN
PrismObjectDefinition<UserType> userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
// THEN
PrismPropertyDefinition<PolyString> descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION);
assertNotNull("No definition for description in user", descriptionDef);
assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName());
assertTrue("description not readable", descriptionDef.canRead());
assertTrue("description not creatable", descriptionDef.canAdd());
assertTrue("description not modifiable", descriptionDef.canModify());
PrismPropertyDefinition<PolyString> additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME);
assertNotNull("No definition for additionalName in user", additionalNameDef);
assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName());
assertTrue("additionalName not readable", additionalNameDef.canRead());
assertTrue("additionalName not creatable", additionalNameDef.canAdd());
assertTrue("additionalName not modifiable", additionalNameDef.canModify());
PrismPropertyDefinition<String> costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER);
assertNotNull("No definition for costCenter in user", costCenterDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 420, costCenterDef.getDisplayOrder());
assertTrue("costCenter not readable", costCenterDef.canRead());
assertTrue("costCenter not creatable", costCenterDef.canAdd());
assertTrue("costCenter not modifiable", costCenterDef.canModify());
PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef();
assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef);
PrismPropertyDefinition<String> preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef);
assertEquals("Wrong preferredLanguage displayName", "UserType.preferredLanguage", preferredLanguageDef.getDisplayName());
assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead());
assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd());
assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify());
valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef);
assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid());
PrismContainerDefinition<CredentialsType> credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS);
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
assertTrue("Credentials not creatable", credentialsDef.canAdd());
assertTrue("Credentials not modifiable", credentialsDef.canModify());
ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
PrismPropertyDefinition<ProtectedStringType> passwdValDef = userDefinition.findPropertyDefinition(passwdValPath);
assertNotNull("No definition for " + passwdValPath + " in user", passwdValDef);
assertTrue("Password not readable", passwdValDef.canRead());
assertTrue("Password not creatable", passwdValDef.canAdd());
assertTrue("Password not modifiable", passwdValDef.canModify());
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestEditSchema method test810OtisGetJack.
@Test
public void test810OtisGetJack() throws Exception {
final String TEST_NAME = "test810OtisGetJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
login(USER_OTIS_USERNAME);
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertPropertyValues(user, UserType.F_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {
@Override
public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
assertNotNull("No definition for name in user", propDef);
assertEquals("Wrong name displayName", "ObjectType.name", propDef.getDisplayName());
assertTrue(name + " not readable", propDef.canRead());
assertTrue(name + " is creatable", !propDef.canAdd());
assertTrue(name + " is modifiable", !propDef.canModify());
}
}, PrismTestUtil.createPolyString("jack"));
assertPropertyValues(user, UserType.F_DESCRIPTION, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for description in user", propDef);
assertEquals("Wrong description displayName", "Comment", propDef.getDisplayName());
assertTrue(name + " not readable", propDef.canRead());
assertTrue(name + " is creatable", !propDef.canAdd());
assertTrue(name + " not modifiable", propDef.canModify());
}
}, "Where's the rum?");
assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {
@Override
public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
assertNotNull("No definition for additionalName in user", propDef);
assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
assertTrue(name + " is readable", !propDef.canRead());
assertTrue(name + " is creatable", !propDef.canAdd());
assertTrue(name + " not modifiable", propDef.canModify());
}
});
assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for costCenter in user", propDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
assertTrue(name + " is readable", !propDef.canRead());
assertTrue(name + " is creatable", !propDef.canAdd());
assertTrue(name + " is modifiable", !propDef.canModify());
}
});
assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for preferredLanguage in user", propDef);
assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
assertTrue(name + " is readable", !propDef.canRead());
assertTrue(name + " is creatable", !propDef.canAdd());
assertTrue(name + " is modifiable", !propDef.canModify());
}
});
PrismAsserts.assertNoItem(user, UserType.F_CREDENTIALS);
assertUntouchedUserDefinition();
assertSteadyResources();
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestEditSchema method test213ModifiedUserJack.
/**
* Modify jack, see if the schema still applies.
*/
@Test
public void test213ModifiedUserJack() throws Exception {
final String TEST_NAME = "test213ModifiedUserJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_PREFERRED_LANGUAGE, task, result, "en_PR");
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {
@Override
public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
assertNotNull("No definition for additionalName in user", propDef);
assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
assertTrue("additionalName not readable", propDef.canRead());
}
}, PrismTestUtil.createPolyString("Jackie"));
assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for costCenter in user", propDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
assertTrue("costCenter not readable", propDef.canRead());
}
}, // This is set by user template
"G001");
assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for preferredLanguage in user", propDef);
assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
assertTrue("preferredLanguage not readable", propDef.canRead());
PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
}
}, "en_PR");
assertContainer(user, UserType.F_CREDENTIALS, new Validator<PrismContainerDefinition<CredentialsType>>() {
@Override
public void validate(PrismContainerDefinition<CredentialsType> credentialsDef, String name) throws Exception {
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
}
}, true);
assertProperty(user, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertTrue("Password not readable", propDef.canRead());
}
});
assertUntouchedUserDefinition();
assertSteadyResources();
}
Aggregations