Skip to content

Commit

Permalink
Possible fix for MID-4110 (+more tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Aug 9, 2017
1 parent 30d005d commit 405a6ec
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 6 deletions.
Expand Up @@ -684,9 +684,11 @@ private void evaluateSegmentTarget(AssignmentPathSegmentImpl segment, PlusMinusZ
LOGGER.debug("Evaluating RBAC [{}]", ctx.assignmentPath.shortDumpLazily());
InternalMonitor.recordRoleEvaluation(targetType, true);

// Cache it immediately, even before evaluation. So if there is a cycle in the role path
// then we can detect it and skip re-evaluation of aggressively idempotent roles.
evaluatedAssignmentTargetCache.recordProcessing(segment, ctx.primaryAssignmentMode);
if (isValid) {
// Cache it immediately, even before evaluation. So if there is a cycle in the role path
// then we can detect it and skip re-evaluation of aggressively idempotent roles.
evaluatedAssignmentTargetCache.recordProcessing(segment, ctx.primaryAssignmentMode);
}

if (isTargetValid && targetType instanceof AbstractRoleType) {
MappingType roleCondition = ((AbstractRoleType)targetType).getCondition();
Expand Down
Expand Up @@ -1202,8 +1202,8 @@ public void test173Forward15min() throws Exception {
* MID-4110
*/
@Test
public void test174JackAssignRoleSailorAgain() throws Exception {
final String TEST_NAME = "test174JackAssignRoleSailorAgain";
public void test174JackAssignRoleSingerAgain() throws Exception {
final String TEST_NAME = "test174JackAssignRoleSingerAgain";
displayTestTile(TEST_NAME);

Task task = createTask(TEST_NAME);
Expand Down Expand Up @@ -1236,6 +1236,113 @@ public void test174JackAssignRoleSailorAgain() throws Exception {
public void test179JackUnassignAll() throws Exception {
unassignAll("test179JackUnassignAll");
}

/**
* This time do both assigns as raw. And do NOT recompute until everything is set up.
* MID-4110
*/
@Test
public void test180JackAssignRoleSailorValidToRaw() throws Exception {
final String TEST_NAME = "test180JackAssignRoleSailorValidToRaw";
displayTestTile(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

ActivationType activationType = new ActivationType();
jackPirateValidTo = getTimestamp("PT10M");
activationType.setValidTo(jackPirateValidTo);

// WHEN
displayWhen(TEST_NAME);
modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null,
task, null, activationType, true, ModelExecuteOptions.createRaw(), result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignments(userAfter, 1);
AssignmentType assignmentTypeAfter = assertAssignedRole(userAfter, ROLE_STRONG_SAILOR_OID);
assertEffectiveActivation(assignmentTypeAfter, null);
assertRoleMembershipRef(userAfter);
assertDelegatedRef(userAfter);

assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

/**
* MID-4110
*/
@Test
public void test182Forward15minAndAssignRaw() throws Exception {
final String TEST_NAME = "test142Forward15min";
displayTestTile(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

clockForward("PT15M");

// WHEN
displayWhen(TEST_NAME);
modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null,
task, null, null, true, ModelExecuteOptions.createRaw(), result);

// THEN
displayThen(TEST_NAME);

PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignments(userAfter, 2);
assertRoleMembershipRef(userAfter);

assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}

/**
* MID-4110
*/
@Test
public void test184RecomputeJack() throws Exception {
final String TEST_NAME = "test184RecomputeJack";
displayTestTile(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);

// WHEN
displayWhen(TEST_NAME);
recomputeUser(USER_JACK_OID, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignments(userAfter, 2);
assertRoleMembershipRef(userAfter, ROLE_STRONG_SAILOR_OID);
assertDelegatedRef(userAfter);

assertJackDummySailorAccount();
}

/**
* MID-4110
*/
@Test
public void test189JackUnassignAll() throws Exception {
unassignAll("test189JackUnassignAll");
}


private void assertJackDummyPirateAccount() throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -62,7 +62,7 @@
<logger name="com.evolveum.midpoint.model.impl.lens.projector.OutboundProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ConsolidationProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ReconciliationProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ActivationProcessor" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.ActivationProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.MappingEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.credentials.CredentialsProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.credentials.ProjectionCredentialsProcessor" level="DEBUG" />
Expand Down

0 comments on commit 405a6ec

Please sign in to comment.