Search in sources :

Example 21 with CredentialsType

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 22 with CredentialsType

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 23 with CredentialsType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

Example 24 with CredentialsType

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());
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) Test(org.testng.annotations.Test)

Example 25 with CredentialsType

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

Aggregations

CredentialsType (com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType)25 PasswordType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)15 Test (org.testng.annotations.Test)11 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 PasswordHistoryEntryType (com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType)2