This is an automated email from the ASF dual-hosted git repository.
sgarofalo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 3710ebda66 [SYNCOPE-1807] Propagate status changes coming from SCIM
extension (#633)
3710ebda66 is described below
commit 3710ebda667b05bbdacd1b4edf1a5bf84f5043ce
Author: Samuel Garofalo <[email protected]>
AuthorDate: Mon Feb 26 12:04:18 2024 +0100
[SYNCOPE-1807] Propagate status changes coming from SCIM extension (#633)
---
.../main/java/org/apache/syncope/core/logic/SCIMDataBinder.java | 8 +++++++-
.../java/org/apache/syncope/core/logic/SCIMDataBinderTest.java | 4 ++--
.../syncope/ext/scimv2/cxf/service/SCIMUserServiceImpl.java | 5 ++++-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git
a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
index dc332f8703..41feaaafd2 100644
---
a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
+++
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/SCIMDataBinder.java
@@ -19,6 +19,7 @@
package org.apache.syncope.core.logic;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -766,7 +767,10 @@ public class SCIMDataBinder {
}
}
- public Pair<UserUR, StatusR> toUserUpdate(final UserTO before, final
SCIMPatchOperation op) {
+ public Pair<UserUR, StatusR> toUserUpdate(
+ final UserTO before,
+ final Collection<String> resources,
+ final SCIMPatchOperation op) {
StatusR statusR = null;
if (op.getPath() == null && op.getOp() != PatchOp.remove
@@ -778,6 +782,7 @@ public class SCIMDataBinder {
statusR = new StatusR.Builder(
before.getKey(),
after.isActive() ? StatusRType.REACTIVATE :
StatusRType.SUSPEND).
+ resources(resources).
build();
}
@@ -822,6 +827,7 @@ public class SCIMDataBinder {
statusR = new StatusR.Builder(
before.getKey(),
(boolean) op.getValue().get(0) ?
StatusRType.REACTIVATE : StatusRType.SUSPEND).
+ resources(resources).
build();
}
}
diff --git
a/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/SCIMDataBinderTest.java
b/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/SCIMDataBinderTest.java
index 9a92bc3584..c3f378c147 100644
---
a/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/SCIMDataBinderTest.java
+++
b/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/SCIMDataBinderTest.java
@@ -36,7 +36,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class SCIMDataBinderTest {
+class SCIMDataBinderTest {
private SCIMDataBinder dataBinder;
@@ -61,6 +61,6 @@ public class SCIMDataBinderTest {
scimPatchPath.setAttribute("active");
operation.setPath(scimPatchPath);
operation.setValue(List.of(value));
- assertDoesNotThrow(() -> dataBinder.toUserUpdate(new UserTO(),
operation));
+ assertDoesNotThrow(() -> dataBinder.toUserUpdate(new UserTO(),
List.of(), operation));
}
}
diff --git
a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/SCIMUserServiceImpl.java
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/SCIMUserServiceImpl.java
index 8694b99b8e..c85aa3840a 100644
---
a/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/SCIMUserServiceImpl.java
+++
b/ext/scimv2/scim-rest-cxf/src/main/java/org/apache/syncope/ext/scimv2/cxf/service/SCIMUserServiceImpl.java
@@ -92,7 +92,10 @@ public class SCIMUserServiceImpl extends
AbstractSCIMService<SCIMUser> implement
}
patch.getOperations().forEach(op -> {
- Pair<UserUR, StatusR> update =
binder.toUserUpdate(userLogic.read(id), op);
+ Pair<UserUR, StatusR> update = binder.toUserUpdate(
+ userLogic.read(id),
+ userDAO.findAllResourceKeys(id),
+ op);
userLogic.update(update.getLeft(), false);
Optional.ofNullable(update.getRight()).ifPresent(statusR ->
userLogic.status(statusR, false));
});