Search in sources :

Example 6 with CredentialsType

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

the class TestAssignmentErrors method test210UserSharptoothAssignAccountBrokenGeneric.

// PARTIAL_ERROR: Unable to get object from the resource. Probably it has not been created yet because of previous unavailability of the resource.
// TODO: timeout or explicit retry
//	@Test
//    public void test205UserLemonheadRecovery() throws Exception {
//		final String TEST_NAME = "test205UserLemonheadRecovery";
//        TestUtil.displayTestTile(this, TEST_NAME);
//
//        // GIVEN
//        Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
//        OperationResult result = task.getResult();
//        assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
//                
//        dummyResource.setBreakMode(BreakMode.NONE);
//        dummyAuditService.clear();
//                
//		// WHEN
//		//not expected that it fails, instead the error in the result is expected
//        modelService.recompute(UserType.class, userLemonheadOid, task, result);
//        
//        result.computeStatus();
//        
//        display(result);
//        // This has to be a partial error as some changes were executed (user) and others were not (account)
//        TestUtil.assertSuccess(result);
//        
//        // Check audit
//        display("Audit", dummyAuditService);
//        dummyAuditService.assertSimpleRecordSanity();
//        dummyAuditService.assertRecords(2);
//        dummyAuditService.assertAnyRequestDeltas();
//        dummyAuditService.assertTarget(userLemonheadOid);
//        dummyAuditService.assertExecutionOutcome(OperationResultStatus.HANDLED_ERROR);
//        dummyAuditService.assertExecutionMessage();
//		
//	}
@Test
public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception {
    final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    PrismObject<UserType> user = createUser(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME);
    CredentialsType credentialsType = new CredentialsType();
    PasswordType passwordType = new PasswordType();
    ProtectedStringType passwordPs = new ProtectedStringType();
    passwordPs.setClearValue(USER_SHARPTOOTH_PASSWORD_1_CLEAR);
    passwordType.setValue(passwordPs);
    credentialsType.setPassword(passwordType);
    user.asObjectable().setCredentials(credentialsType);
    addObject(user);
    userSharptoothOid = user.getOid();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(user.getOid(), RESOURCE_DUMMY_OID, null, true);
    deltas.add(accountAssignmentUserDelta);
    getDummyResource().setBreakMode(BreakMode.GENERIC);
    dummyAuditService.clear();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    //not expected that it fails, instead the error in the result is expected
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    display(result);
    // This has to be a partial error as some changes were executed (user) and others were not (account)
    TestUtil.assertPartialError(result);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(2);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class, OperationResultStatus.FATAL_ERROR);
    dummyAuditService.assertTarget(user.getOid());
    dummyAuditService.assertExecutionOutcome(OperationResultStatus.PARTIAL_ERROR);
    dummyAuditService.assertExecutionMessage();
    LensContext<UserType> lastLensContext = lensDebugListener.getLastLensContext();
    Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = lastLensContext.getExecutedDeltas();
    display("Executed deltas", executedDeltas);
    assertEquals("Unexpected number of execution deltas in context", 2, executedDeltas.size());
    Iterator<ObjectDeltaOperation<? extends ObjectType>> i = executedDeltas.iterator();
    ObjectDeltaOperation<? extends ObjectType> deltaop1 = i.next();
    assertEquals("Unexpected result of first executed deltas", OperationResultStatus.SUCCESS, deltaop1.getExecutionResult().getStatus());
    ObjectDeltaOperation<? extends ObjectType> deltaop2 = i.next();
    assertEquals("Unexpected result of second executed deltas", OperationResultStatus.FATAL_ERROR, deltaop2.getExecutionResult().getStatus());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 7 with CredentialsType

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

the class AbstractModelIntegrationTest method assertUserLdapPassword.

protected void assertUserLdapPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
    CredentialsType credentialsType = user.asObjectable().getCredentials();
    assertNotNull("No credentials in " + user, credentialsType);
    PasswordType passwordType = credentialsType.getPassword();
    assertNotNull("No password in " + user, passwordType);
    ProtectedStringType protectedStringType = passwordType.getValue();
    assertLdapPassword(protectedStringType, expectedPassword, user);
}
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 8 with CredentialsType

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

the class AbstractModelIntegrationTest method assertPassword.

protected void assertPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
    CredentialsType credentialsType = user.asObjectable().getCredentials();
    assertNotNull("No credentials in " + user, credentialsType);
    PasswordType passwordType = credentialsType.getPassword();
    assertNotNull("No password in " + user, passwordType);
    ProtectedStringType protectedStringType = passwordType.getValue();
    assertNotNull("No password value in " + user, protectedStringType);
    String decryptedUserPassword = protector.decryptString(protectedStringType);
    assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword);
}
Also used : CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)

Example 9 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType 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();
}
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 10 with CredentialsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType 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());
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) CredentialsType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) 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)

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