Skip to content

Commit

Permalink
Add test for approval bypass (MID-5827)
Browse files Browse the repository at this point in the history
The test is currently disabled because it works. :)
It is separated from the fix to make fix backporting to 3.7.x easier.
  • Loading branch information
mederly committed Nov 9, 2019
1 parent 8a9fe86 commit 426d506
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 147 deletions.
Expand Up @@ -81,7 +81,8 @@ public boolean canSkip(AssignmentPathSegmentImpl segment, PlusMinusZero mode) {
return false;
}
if (idempotence == IdempotenceType.CONSERVATIVE && !segment.isMatchingOrder()) {
// LOGGER.trace("Conservative idempotent and order is not matching: {}", target);
// this is quite important (and perhaps not too frequent) message, so let's keep it here
LOGGER.trace("Conservative idempotent and order is not matching: {}", target);
return false;
}
if (idempotence == IdempotenceType.AGGRESSIVE) {
Expand All @@ -92,7 +93,8 @@ public boolean canSkip(AssignmentPathSegmentImpl segment, PlusMinusZero mode) {
// be remembered as evaluation and it will not be re-evaluated
// in non-meta context.
if (!segment.getEvaluationOrder().isOrderOne()) {
// LOGGER.trace("Aggressive idempotent and non-one order: {}: {}", segment.getEvaluationOrder(), target);
// this is quite important (and perhaps not too frequent) message, so let's keep it here
LOGGER.trace("Aggressive idempotent and non-one order: {}: {}", segment.getEvaluationOrder(), target);
return true;
}
return processedKeys.get(mode).contains(new Key(segment));
Expand Down
Expand Up @@ -21,10 +21,7 @@
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResourceShadowDiscriminator;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.schema.util.ShadowUtil;
Expand Down Expand Up @@ -351,4 +348,5 @@ protected List<CaseWorkItemType> getWorkItemsForCase(String caseOid,
options, result);

}

}
Expand Up @@ -6,6 +6,7 @@
*/
package com.evolveum.midpoint.model.test;

import static com.evolveum.midpoint.prism.PrismObject.asObjectableList;
import static com.evolveum.midpoint.schema.constants.SchemaConstants.*;
import static java.util.Collections.singleton;
import static org.testng.AssertJUnit.assertEquals;
Expand Down Expand Up @@ -919,7 +920,7 @@ protected void unassignAllRoles(String userOid) throws ObjectNotFoundException,
protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException,
SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException,
PolicyViolationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".unassignAllRoles");
Task task = getOrCreateSimpleTask("unassignAllRoles");
OperationResult result = task.getResult();
PrismObject<UserType> user = modelService.getObject(UserType.class, userOid, null, task, result);
Collection<ItemDelta<?,?>> modifications = new ArrayList<>();
Expand Down Expand Up @@ -1642,7 +1643,7 @@ protected PrismObject<UserType> getUserFromRepo(String userOid) throws ObjectNot
}

protected <O extends ObjectType> PrismObject<O> findObjectByName(Class<O> type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = getOrCreateTask("findObjectByName");
Task task = getOrCreateSimpleTask("findObjectByName");
OperationResult result = task.getResult();
List<PrismObject<O>> objects = modelService.searchObjects(type, createNameQuery(name), null, task, result);
if (objects.isEmpty()) {
Expand Down Expand Up @@ -3143,6 +3144,22 @@ protected OperationStatsType getTaskTreeOperationStatistics(String rootTaskOid)
.orElse(null);
}

protected List<CaseType> getSubcases(String parentCaseOid, Collection<SelectorOptions<GetOperationOptions>> options,
OperationResult result) throws SchemaException {
return asObjectableList(
repositoryService.searchObjects(CaseType.class,
prismContext.queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(parentCaseOid).build(),
options, result));
}

protected void deleteCaseTree(String rootCaseOid, OperationResult result) throws SchemaException, ObjectNotFoundException {
List<CaseType> subcases = getSubcases(rootCaseOid, null, result);
for (CaseType subcase : subcases) {
deleteCaseTree(subcase.getOid(), result);
}
repositoryService.deleteObject(CaseType.class, rootCaseOid, result);
}

private class TaskFinishChecker implements Checker {
private final String taskOid;
private final OperationResult waitResult;
Expand Down
Expand Up @@ -133,7 +133,7 @@ protected <F extends FocusType> OperationResult executeTest(String testName, Tes
prepareNotifications();
dummyAuditService.clear();

Task opTask = createTask(AbstractWfTestPolicy.class.getName() + "." + testName);
Task opTask = getOrCreateTestTask(testName);

boolean USE_FULL_TRACING = false;
//noinspection ConstantConditions
Expand Down

0 comments on commit 426d506

Please sign in to comment.