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;
}
}
});
}
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;
}
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);
}
}
Aggregations