Search in sources :

Example 11 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType 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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) 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) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 12 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method test203modifyUserJackPasswordNoPasswordHistory.

@Test
public void test203modifyUserJackPasswordNoPasswordHistory() throws Exception {
    final String TEST_NAME = "test203modifyUserJackPasswordNoPasswordHistory";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    ProtectedStringType newValue = new ProtectedStringType();
    newValue.setClearValue("n0Hist0ryEntr7");
    modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), task, result, newValue);
    // 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 : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 13 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class TestPasswordPolicyProcessor method test101ModifyUserPassword.

@Test
public void test101ModifyUserPassword() throws Exception {
    final String TEST_NAME = "test101ModifyUserPassword";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    modifyUserChangePassword(USER_JACK_OID, PASSWORD1, 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", PASSWORD1, protector.decryptString(passwordAfterChange));
    assertPasswordHistoryEntries(passwordType, USER_JACK_PASSWORD);
}
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 14 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method assertShadowLdapPassword.

protected void assertShadowLdapPassword(PrismObject<ShadowType> shadow, String expectedPassword) throws EncryptionException {
    CredentialsType credentialsType = shadow.asObjectable().getCredentials();
    assertNotNull("No credentials in " + shadow, credentialsType);
    PasswordType passwordType = credentialsType.getPassword();
    assertNotNull("No password in " + shadow, passwordType);
    ProtectedStringType protectedStringType = passwordType.getValue();
    assertLdapPassword(protectedStringType, expectedPassword, shadow);
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 15 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.

the class TestOpenDj method assertShadowPassword.

protected void assertShadowPassword(ShadowType provisioningShadow) throws Exception {
    CredentialsType credentials = provisioningShadow.getCredentials();
    if (credentials == null) {
        return;
    }
    PasswordType passwordType = credentials.getPassword();
    if (passwordType == null) {
        return;
    }
    ProtectedStringType passwordValue = passwordType.getValue();
    assertNull("Unexpected password value in " + provisioningShadow + ": " + passwordValue, passwordValue);
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

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