Search in sources :

Example 1 with LightweightObjectRef

use of com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method test050UserModifyAddRoleAndPasswordChange.

@Test(enabled = true)
public void test050UserModifyAddRoleAndPasswordChange() throws Exception {
    TestUtil.displayTestTile(this, "test050UserModifyAddRoleAndPasswordChange");
    login(userAdministrator);
    PrismObject<UserType> jack = getUser(USER_JACK_OID);
    final ProtectedStringType originalPasswordValue = jack.asObjectable().getCredentials().getPassword().getValue();
    LOGGER.trace("password before test = " + originalPasswordValue);
    executeTest("test050UserModifyAddRoleAndPasswordChange", USER_JACK_OID, new TestDetails() {

        @Override
        int subtaskCount() {
            return 2;
        }

        @Override
        boolean immediate() {
            return false;
        }

        @Override
        boolean checkObjectOnSubtasks() {
            return true;
        }

        @Override
        public LensContext createModelContext(Task task, OperationResult result) throws Exception {
            LensContext<UserType> context = createUserLensContext();
            fillContextWithUser(context, USER_JACK_OID, result);
            encryptAndAddFocusModificationToContext(context, REQ_USER_JACK_MODIFY_CHANGE_PASSWORD_2);
            addFocusModificationToContext(context, REQ_USER_JACK_MODIFY_ADD_ASSIGNMENT_ROLE1);
            //context.setOptions(ModelExecuteOptions.createNoCrypt());
            return context;
        }

        @Override
        public void assertsAfterClockworkRun(Task rootTask, List<Task> wfSubtasks, OperationResult result) throws Exception {
            ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result);
            assertEquals("There are modifications left in primary focus delta", 0, taskModelContext.getFocusContext().getPrimaryDelta().getModifications().size());
        }

        @Override
        void assertsRootTaskFinishes(Task task, List<Task> subtasks, OperationResult result) throws Exception {
            PrismObject<UserType> jack = getUser(USER_JACK_OID);
            ProtectedStringType afterTestPasswordValue = jack.asObjectable().getCredentials().getPassword().getValue();
            LOGGER.trace("password after test = " + afterTestPasswordValue);
            // todo why is password value not set?
            //assertNotNull("password was not set", afterTestPasswordValue.getEncryptedData());
            //assertFalse("password was not changed", originalPasswordValue.getEncryptedData().equals(afterTestPasswordValue.getEncryptedData()));
            assertAssignedRole(jack, ROLE_R1_OID);
            checkDummyTransportMessages("simpleUserNotifier", 1);
        }

        @Override
        boolean decideOnApproval(String executionId) throws Exception {
            LightweightObjectRef targetRef = (LightweightObjectRef) activitiEngine.getRuntimeService().getVariable(executionId, CommonProcessVariableNames.VARIABLE_TARGET_REF);
            if (targetRef != null && RoleType.COMPLEX_TYPE.equals(targetRef.toObjectReferenceType().getType())) {
                return decideOnRoleApproval(executionId);
            } else {
                login(getUser(USER_ADMINISTRATOR_OID));
                return true;
            }
        }
    });
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) JAXBException(javax.xml.bind.JAXBException) LightweightObjectRef(com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef) ModelContext(com.evolveum.midpoint.model.api.context.ModelContext) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

Example 2 with LightweightObjectRef

use of com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef in project midpoint by Evolveum.

the class AbstractWfTestPolicy method getTargetOid.

protected String getTargetOid(String executionId) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException {
    LightweightObjectRef targetRef = (LightweightObjectRef) activitiEngine.getRuntimeService().getVariable(executionId, CommonProcessVariableNames.VARIABLE_TARGET_REF);
    assertNotNull("targetRef not found", targetRef);
    String roleOid = targetRef.getOid();
    assertNotNull("requested role OID not found", roleOid);
    return roleOid;
}
Also used : LightweightObjectRef(com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef)

Example 3 with LightweightObjectRef

use of com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef in project midpoint by Evolveum.

the class AbstractWfTestLegacy method decideOnRoleApproval.

protected boolean decideOnRoleApproval(String executionId) throws ConfigurationException, ObjectNotFoundException, SchemaException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
    LightweightObjectRef targetRef = (LightweightObjectRef) activitiEngine.getRuntimeService().getVariable(executionId, CommonProcessVariableNames.VARIABLE_TARGET_REF);
    assertNotNull("targetRef not found", targetRef);
    String roleOid = targetRef.getOid();
    assertNotNull("requested role OID not found", roleOid);
    if (ROLE_R1_OID.equals(roleOid)) {
        login(getUser(R1BOSS_OID));
        return true;
    } else if (ROLE_R2_OID.equals(roleOid)) {
        login(getUser(R2BOSS_OID));
        return false;
    } else if (ROLE_R3_OID.equals(roleOid)) {
        login(getUser(R3BOSS_OID));
        return true;
    } else {
        throw new AssertionError("Unknown role OID in assignment to be approved: " + roleOid);
    }
}
Also used : LightweightObjectRef(com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef)

Aggregations

LightweightObjectRef (com.evolveum.midpoint.wf.impl.processes.common.LightweightObjectRef)3 ModelContext (com.evolveum.midpoint.model.api.context.ModelContext)1 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)1 JAXBException (javax.xml.bind.JAXBException)1 Test (org.testng.annotations.Test)1