Skip to content

Commit

Permalink
Fix NPE for partial processing without focus ctx
Browse files Browse the repository at this point in the history
This resolves MID-9477.
  • Loading branch information
mederly committed Apr 29, 2024
1 parent 4b73c08 commit e402402
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,15 @@ private void authorizeExecutionStart(
PartialProcessingOptionsType partialProcessing = ModelExecuteOptions.getPartialProcessing(options);
if (partialProcessing != null) {
// TODO Note that the information about the object may be incomplete (orgs, tenants, roles) or even missing.
// See MID-9454.
PrismObject<? extends ObjectType> object = context.getFocusContext().getObjectAny();
// See MID-9454, MID-9477.
LensFocusContext<? extends ObjectType> focusContext = context.getFocusContext();
var autzParams =
focusContext != null ?
AuthorizationParameters.Builder.buildObject(focusContext.getObjectAny()) :
AuthorizationParameters.EMPTY;
securityEnforcer.authorize(
ModelAuthorizationAction.PARTIAL_EXECUTION.getUrl(),
phase, AuthorizationParameters.Builder.buildObject(object), task, result);
phase, autzParams, task, result);
}
} catch (Throwable t) {
result.recordException(t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,10 @@ public void test360ModifyAccountJackDummy() throws Exception {
preTestCleanup(AssignmentPolicyEnforcementType.FULL);

when();
executeChanges(createJacksAccountModifyDelta(), null, task, result);
// Creating empty partial processing option is the same as having none. This code is here just to test MID-9477.
var options = ModelExecuteOptions.create()
.partialProcessing(new PartialProcessingOptionsType());
executeChanges(createJacksAccountModifyDelta(), options, task, result);

then();
assertSuccess(result);
Expand Down

0 comments on commit e402402

Please sign in to comment.