use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestEditSchema method test800OtisEditSchemaUser.
/**
* Login as Otis. Otis has a restricted authorizations. Check that schema is presented accordingly to
* these limitations.
*/
@Test
public void test800OtisEditSchemaUser() throws Exception {
final String TEST_NAME = "test800OtisEditSchemaUser";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
login(USER_OTIS_USERNAME);
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObjectDefinition<UserType> userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
PrismObject<UserType> user = userDef.instantiate();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObjectDefinition<UserType> editDef = getEditObjectDefinition(user);
IntegrationTestTools.display("Otis edit schema", editDef);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismPropertyDefinition<PolyString> nameDef = editDef.findPropertyDefinition(UserType.F_NAME);
assertNotNull("No definition for name in user", nameDef);
assertEquals("Wrong name displayName", "ObjectType.name", nameDef.getDisplayName());
assertTrue("name not readable", nameDef.canRead());
assertTrue("name is creatable", !nameDef.canAdd());
assertTrue("name is modifiable", !nameDef.canModify());
PrismPropertyDefinition<PolyString> additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME);
assertNotNull("No definition for additionalName in user", additionalNameDef);
assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName());
assertTrue("additionalName is readable", !additionalNameDef.canRead());
assertTrue("additionalName is creatable", !additionalNameDef.canAdd());
assertTrue("additionalName not modifiable", additionalNameDef.canModify());
PrismPropertyDefinition<String> costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER);
assertNotNull("No definition for costCenter in user", costCenterDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, costCenterDef.getDisplayOrder());
assertTrue("costCenter is readable", !costCenterDef.canRead());
assertTrue("costCenter is creatable", !costCenterDef.canAdd());
assertTrue("costCenter is modifiable", !costCenterDef.canModify());
PrismPropertyDefinition<String> preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef);
assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName());
PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
assertTrue("preferredLanguage is readable", !preferredLanguageDef.canRead());
assertTrue("preferredLanguage is creatable", !preferredLanguageDef.canAdd());
assertTrue("preferredLanguage is modifiable", !preferredLanguageDef.canModify());
PrismContainerDefinition<CredentialsType> credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS);
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials is readable", !credentialsDef.canRead());
assertTrue("Credentials is creatable", !credentialsDef.canAdd());
assertTrue("Credentials is modifiable", !credentialsDef.canModify());
ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
PrismPropertyDefinition<ProtectedStringType> passwdValDef = editDef.findPropertyDefinition(passwdValPath);
assertNotNull("No definition for " + passwdValPath + " in user", passwdValDef);
assertTrue("Password is readable", !passwdValDef.canRead());
assertTrue("Password is creatable", !passwdValDef.canAdd());
assertTrue("Password is modifiable", !passwdValDef.canModify());
assertUntouchedUserDefinition();
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestEditSchema method test200EditSchemaUser.
@Test
public void test200EditSchemaUser() throws Exception {
final String TEST_NAME = "test200EditSchemaUser";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObjectDefinition<UserType> userDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
PrismObject<UserType> user = userDef.instantiate();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObjectDefinition<UserType> editDef = getEditObjectDefinition(user);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismAsserts.assertEmphasized(editDef, UserType.F_NAME, true);
PrismAsserts.assertEmphasized(editDef, UserType.F_GIVEN_NAME, false);
PrismAsserts.assertEmphasized(editDef, UserType.F_FAMILY_NAME, true);
PrismAsserts.assertEmphasized(editDef, UserType.F_FULL_NAME, true);
PrismAsserts.assertEmphasized(editDef, UserType.F_DESCRIPTION, false);
PrismPropertyDefinition<PolyString> additionalNameDef = editDef.findPropertyDefinition(UserType.F_ADDITIONAL_NAME);
assertNotNull("No definition for additionalName in user", additionalNameDef);
assertEquals("Wrong additionalName displayName", "Middle Name", additionalNameDef.getDisplayName());
assertTrue("additionalName not readable", additionalNameDef.canRead());
PrismAsserts.assertEmphasized(additionalNameDef, false);
PrismPropertyDefinition<String> costCenterDef = editDef.findPropertyDefinition(UserType.F_COST_CENTER);
assertNotNull("No definition for costCenter in user", costCenterDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, costCenterDef.getDisplayOrder());
assertTrue("costCenter not readable", costCenterDef.canRead());
PrismAsserts.assertEmphasized(costCenterDef, true);
// This has overridden lookup def in object template
PrismPropertyDefinition<String> preferredLanguageDef = editDef.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef);
assertEquals("Wrong preferredLanguage displayName", "Language", preferredLanguageDef.getDisplayName());
assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead());
PrismReferenceValue valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
// This has default lookup def in schema
PrismPropertyDefinition<String> timezoneDef = editDef.findPropertyDefinition(UserType.F_TIMEZONE);
assertNotNull("No definition for timezone in user", timezoneDef);
assertEquals("Wrong timezone displayName", "UserType.timezone", timezoneDef.getDisplayName());
assertTrue("timezone not readable", timezoneDef.canRead());
valueEnumerationRef = timezoneDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for timezone", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for timezone", SystemObjectsType.LOOKUP_TIMEZONES.value(), valueEnumerationRef.getOid());
PrismContainerDefinition<CredentialsType> credentialsDef = editDef.findContainerDefinition(UserType.F_CREDENTIALS);
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
PrismPropertyDefinition<ProtectedStringType> passwdValDef = editDef.findPropertyDefinition(passwdValPath);
assertNotNull("No definition for " + passwdValPath + " in user", passwdValDef);
assertTrue("Password not readable", passwdValDef.canRead());
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestPasswordPolicyProcessor method test103ModifyUserPasswordAgain.
@Test
public void test103ModifyUserPasswordAgain() throws Exception {
final String TEST_NAME = "test103ModifyUserPasswordAgain";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
modifyUserChangePassword(USER_JACK_OID, PASSWORD3, task, result);
// THEN
PrismObject<UserType> jackAfterSecondChange = getObject(UserType.class, USER_JACK_OID);
assertNotNull("User Jack was not found.", jackAfterSecondChange);
UserType jackTypeAfterSecondChange = jackAfterSecondChange.asObjectable();
CredentialsType credentialsTypeAfterSecondChange = jackTypeAfterSecondChange.getCredentials();
assertNotNull("No credentials set for user Jack", credentialsTypeAfterSecondChange);
PasswordType passwordTypeAfterSecondChnage = credentialsTypeAfterSecondChange.getPassword();
assertNotNull("No password set for user Jack", passwordTypeAfterSecondChnage);
ProtectedStringType passwordAfterSecondChange = passwordTypeAfterSecondChnage.getValue();
assertNotNull("Password musn't be null", passwordAfterSecondChange);
assertEquals("Password doesn't match", PASSWORD3, protector.decryptString(passwordAfterSecondChange));
assertPasswordHistoryEntries(passwordTypeAfterSecondChnage, PASSWORD1, PASSWORD2);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestPasswordPolicyProcessor method test202createUserJackNoPasswordHistory.
@Test
public void test202createUserJackNoPasswordHistory() throws Exception {
final String TEST_NAME = "test202createUserJackNoPasswordHistory";
TestUtil.displayTestTile(TEST_NAME);
// WHEN
addObject(USER_JACK_FILE);
// THEN
PrismObject<UserType> userJack = getObject(UserType.class, USER_JACK_OID);
assertNotNull("Expected to find user Jack, but no one exists here", userJack);
UserType userJackType = userJack.asObjectable();
CredentialsType credentials = userJackType.getCredentials();
assertNotNull("User Jack has no credentials", credentials);
PasswordType password = credentials.getPassword();
assertNotNull("User Jack has no password", password);
List<PasswordHistoryEntryType> historyEntries = password.getHistoryEntry();
assertEquals("Expected no history entries, but found: " + historyEntries.size(), 0, historyEntries.size());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestPasswordPolicyProcessor method test102ModifyUserPassword.
@Test
public void test102ModifyUserPassword() throws Exception {
final String TEST_NAME = "test102ModifyUserPassword";
TestUtil.displayTestTile(TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
modifyUserChangePassword(USER_JACK_OID, PASSWORD2, task, result);
// THEN
PrismObject<UserType> jack = getObject(UserType.class, USER_JACK_OID);
assertNotNull("User Jack was not found.", jack);
UserType jackType = jack.asObjectable();
CredentialsType credentialsType = jackType.getCredentials();
assertNotNull("No credentials set for user Jack", credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password set for user Jack", passwordType);
ProtectedStringType passwordAfterChange = passwordType.getValue();
assertNotNull("Password musn't be null", passwordAfterChange);
assertEquals("Password doesn't match", PASSWORD2, protector.decryptString(passwordAfterChange));
assertPasswordHistoryEntries(passwordType, USER_JACK_PASSWORD, PASSWORD1);
}
Aggregations