Skip to content

Commit

Permalink
Consistency update: Fixing TestMultiResource, testing dead shadow exp…
Browse files Browse the repository at this point in the history
…iration (MID-3891)
  • Loading branch information
semancik committed Aug 1, 2018
1 parent 70da208 commit d29a2bf
Showing 1 changed file with 60 additions and 14 deletions.
Expand Up @@ -147,6 +147,8 @@ public class TestMultiResource extends AbstractInitializedModelIntegrationTest {

private static final String USER_PASSWORD_A_CLEAR = "A"; // too short

private String deadShadowOid;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
Expand Down Expand Up @@ -2198,8 +2200,8 @@ public void test423DavidAndGoliathAssignRoleGoliathUpReconcile() throws Exceptio
}

@Test
public void test429DavidAndGoliathUnassignRole() throws Exception {
final String TEST_NAME = "test429DavidAndGoliathUnassignRole";
public void test428DavidAndGoliathUnassignRole() throws Exception {
final String TEST_NAME = "test428DavidAndGoliathUnassignRole";
displayTestTitle(TEST_NAME);

// GIVEN
Expand All @@ -2220,13 +2222,14 @@ public void test429DavidAndGoliathUnassignRole() throws Exception {
displayThen(TEST_NAME);
assertSuccess(result);

assertUserAfter(userBefore.getOid())
deadShadowOid = assertUserAfter(userBefore.getOid())
.assertName(USER_FIELD_NAME)
.assertFullName(USER_WORLD_FULL_NAME)
.singleLink()
.resolveTarget()
.display()
.assertDead();
.assertDead()
.getObject().getOid();

assertNoDummyAccount(RESOURCE_DUMMY_DAVID_NAME, USER_FIELD_NAME);
assertNoDummyAccount(RESOURCE_DUMMY_GOLIATH_NAME, USER_FIELD_NAME);
Expand All @@ -2244,6 +2247,47 @@ public void test429DavidAndGoliathUnassignRole() throws Exception {
dummyAuditService.assertHasDelta(1,ChangeType.DELETE, ShadowType.class);
dummyAuditService.assertExecutionSuccess();
}

/**
* Let the dead shadow expire. Let's check that it is gone and that it is
* also properly unlinked. It also cleans the slate for next tests.
*/
@Test
public void test429ExpireDeadShadow() throws Exception {
final String TEST_NAME = "test429ExpireDeadShadow";
displayTestTitle(TEST_NAME);

// GIVEN
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode();
getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode();
dummyAuditService.clear();

PrismObject<UserType> userBefore = findUserByUsername(USER_FIELD_NAME);

clockForward("P10D");

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

// WHEN
displayWhen(TEST_NAME);
reconcileUser(userBefore.getOid(), task, result);

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

assertUserAfter(userBefore.getOid())
.assertName(USER_FIELD_NAME)
.assertFullName(USER_WORLD_FULL_NAME)
.assertLinks(0);

assertNoRepoShadow(deadShadowOid);

assertNoDummyAccount(RESOURCE_DUMMY_DAVID_NAME, USER_FIELD_NAME);
assertNoDummyAccount(RESOURCE_DUMMY_GOLIATH_NAME, USER_FIELD_NAME);
}

@Test
public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception {
Expand Down Expand Up @@ -2277,19 +2321,21 @@ public void test430DavidAndGoliathAssignRoleDavidDown() throws Exception {

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

PrismObject<UserType> userAfter = getUser(userBefore.getOid());
display("User after fight", userAfter);
assertUser(userAfter, userBefore.getOid(), USER_FIELD_NAME, USER_WORLD_FULL_NAME, null, null);
assertAccount(userAfter, RESOURCE_DUMMY_DAVID_OID); // This is unfinished shadow
// No goliath account, not even tried, the dependency stopped it
assertLinks(userAfter, 1);
assertUserAfter(userBefore.getOid())
.assertName(USER_FIELD_NAME)
.assertFullName(USER_WORLD_FULL_NAME)
.assertLinks(1)
.projectionOnResource(RESOURCE_DUMMY_DAVID_OID)
.hasUnfinishedPendingOperations(); // This is unfinished shadow

getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode();

// David is down. No account.
assertNoDummyAccount(RESOURCE_DUMMY_DAVID_NAME, USER_FIELD_NAME);

// Goliath depends on David, no account.

assertNoDummyAccount(RESOURCE_DUMMY_GOLIATH_NAME, USER_FIELD_NAME);

// Check audit
Expand All @@ -2312,8 +2358,8 @@ public void test440DavidAndGoliathAssignRoleAndCreateUserInOneStep() throws Exce
final String TEST_NAME = "test440DavidAndGoliathAssignRoleAndCreateUserInOneStep";
displayTestTitle(TEST_NAME);

getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).setBreakMode(BreakMode.NONE);
getDummyResource(RESOURCE_DUMMY_DAVID_NAME).setBreakMode(BreakMode.NONE);
getDummyResource(RESOURCE_DUMMY_GOLIATH_NAME).resetBreakMode();
getDummyResource(RESOURCE_DUMMY_DAVID_NAME).resetBreakMode();
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// delete user and his roles which were added before
Expand Down

0 comments on commit d29a2bf

Please sign in to comment.