Skip to content

Commit

Permalink
Fixing intests
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Nov 3, 2016
1 parent d95afb6 commit 55e1e29
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
Expand Up @@ -630,6 +630,19 @@ private <F extends ObjectType> void recordEffectiveStatusDelta(LensFocusContext<
throws SchemaException {
PrismContainerDefinition<ActivationType> activationDefinition = getActivationDefinition();

// We always want explicit delta for effective status even if there is no real change
// we want to propagate enable/disable events to all the resources, even if we are enabling
// already enabled user (some resources may be disabled)
// This may produce duplicate delta, but that does not matter too much. The duplicate delta
// will be filtered out later.
PrismPropertyDefinition<ActivationStatusType> effectiveStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_EFFECTIVE_STATUS);
PropertyDelta<ActivationStatusType> effectiveStatusDelta
= effectiveStatusDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS));
effectiveStatusDelta.setValueToReplace(new PrismPropertyValue<ActivationStatusType>(effectiveStatusNew, OriginType.USER_POLICY, null));
if (!focusContext.alreadyHasDelta(effectiveStatusDelta)){
focusContext.swallowToProjectionWaveSecondaryDelta(effectiveStatusDelta);
}

// It is not enough to check alreadyHasDelta(). The change may happen in previous waves
// and the secondary delta may no longer be here. When it comes to disableTimestamp we even
// cannot rely on natural filtering of already executed deltas as the timestamp here may
Expand All @@ -638,19 +651,11 @@ private <F extends ObjectType> void recordEffectiveStatusDelta(LensFocusContext<
if (objectCurrent != null) {
PrismProperty<ActivationStatusType> effectiveStatusPropCurrent = objectCurrent.findProperty(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS);
if (effectiveStatusPropCurrent != null && effectiveStatusNew.equals(effectiveStatusPropCurrent.getRealValue())) {
LOGGER.trace("Skipping setting of effective status and disableTimestamp because there was no change");
LOGGER.trace("Skipping setting disableTimestamp because there was no change");
return;
}
}

PrismPropertyDefinition<ActivationStatusType> effectiveStatusDef = activationDefinition.findPropertyDefinition(ActivationType.F_EFFECTIVE_STATUS);
PropertyDelta<ActivationStatusType> effectiveStatusDelta
= effectiveStatusDef.createEmptyDelta(new ItemPath(UserType.F_ACTIVATION, ActivationType.F_EFFECTIVE_STATUS));
effectiveStatusDelta.setValueToReplace(new PrismPropertyValue<ActivationStatusType>(effectiveStatusNew, OriginType.USER_POLICY, null));
if (!focusContext.alreadyHasDelta(effectiveStatusDelta)){
focusContext.swallowToProjectionWaveSecondaryDelta(effectiveStatusDelta);
}


PropertyDelta<XMLGregorianCalendar> timestampDelta = LensUtil.createActivationTimestampDelta(effectiveStatusNew, now, activationDefinition, OriginType.USER_POLICY);
if (!focusContext.alreadyHasDelta(timestampDelta)) {
focusContext.swallowToProjectionWaveSecondaryDelta(timestampDelta);
Expand Down
Expand Up @@ -256,7 +256,7 @@ public void test055ModifyUserJackEnable() throws Exception {
assertAdministrativeStatusEnabled(userJack);
assertValidity(userJack, null);
assertEffectiveStatus(userJack, ActivationStatusType.ENABLED);
assertEnableTimestampFocus(userJack, start, end);
assertEnableTimestampFocus(userJack, null, start);

TestUtil.assertModifyTimestamp(userJack, start, end);
}
Expand Down Expand Up @@ -658,7 +658,8 @@ public void test114ModifyUserJackEnable() throws Exception {

assertAdministrativeStatusEnabled(userJack);
assertDummyEnabled(ACCOUNT_JACK_DUMMY_USERNAME);
assertEnableTimestampFocus(userJack, startTime, endTime);
// No real change in effective status, therefore the enableTimestamp should be unchanged
assertEnableTimestampFocus(userJack, null, startTime);

assertAccounts(USER_JACK_OID, 1);
PrismObject<ShadowType> account = getShadowModel(accountOid);
Expand Down Expand Up @@ -708,7 +709,7 @@ public void test115ModifyUserJackAdministrativeStatusNull() throws Exception {
}

/**
* Modify both user and account activation. As password outbound mapping is weak the user should have its own state
* Modify both user and account activation. As outbound mapping is weak the user should have its own state
* and account should have its own state.
*/
@Test
Expand Down Expand Up @@ -740,7 +741,8 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception {
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, "Jack Sparrow");
assertEnableTimestampFocus(userJack, startTime, endTime);
// No real change in effective status, therefore the enableTimestamp should be unchanged
assertEnableTimestampFocus(userJack, null, startTime);
assertAdministrativeStatusEnabled(userJack);

assertDummyDisabled("jack");
Expand All @@ -753,7 +755,7 @@ public void test118ModifyJackActivationUserAndAccount() throws Exception {
}

/**
* Add red dummy resource to the mix. This would be fun.
* Add red dummy resource to the mix. This will be fun.
*/
@Test
public void test120ModifyUserJackAssignAccountDummyRed() throws Exception {
Expand Down
Expand Up @@ -469,7 +469,7 @@ public void test101EnableBasicAudit() throws Exception {
// THEN

tailer.tail();
tailer.assertAudit(3);
tailer.assertAudit(2);
tailer.assertAuditRequest();
tailer.assertAuditExecution();

Expand Down
Expand Up @@ -2875,7 +2875,7 @@ public void test210AddUserMorganWithAssignment() throws Exception {

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(3);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
Expand Down Expand Up @@ -3120,7 +3120,7 @@ public void test300AddUserJackWithAssignmentBlue() throws Exception {

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(3);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(3);
Expand Down
Expand Up @@ -1773,13 +1773,13 @@ public void test403DavidAndGoliathDisableUser() throws Exception {

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(5); // last one is duplicate
dummyAuditService.assertRecords(3); // last one is duplicate
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0,2);
dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionDeltas(1,2); // user is again disabled here
dummyAuditService.assertExecutionDeltas(1,1); // user is again disabled here
dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionSuccess();
}
Expand Down Expand Up @@ -1811,13 +1811,13 @@ public void test404DavidAndGoliathEnableUser() throws Exception {

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(5); // last one is duplicate
dummyAuditService.assertRecords(3); // last one is duplicate
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(0,2);
dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(0,ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionDeltas(1,2); // user is again disabled here
dummyAuditService.assertExecutionDeltas(1,1); // user is again disabled here
dummyAuditService.assertHasDelta(1,ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertExecutionSuccess();
}
Expand Down
Expand Up @@ -1252,7 +1252,7 @@ public void test230ReconcileDummyRename() throws Exception {
addReconScripts(scripts, ACCOUNT_HTM_NAME, ACCOUNT_HTM_FULL_NAME, true);
IntegrationTestTools.assertScripts(dummyResource.getScriptHistory(), scripts.toArray(new ProvisioningScriptSpec[0]));

assertReconAuditModifications(3, TASK_RECONCILE_DUMMY_OID); // the second modification is unlink
assertReconAuditModifications(2, TASK_RECONCILE_DUMMY_OID); // the second modification is unlink

assertShadows(14);

Expand Down

0 comments on commit 55e1e29

Please sign in to comment.