[SYNCOPE-1807] Propagate status changes coming from SCIM extension (#633)
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 dc332f8..41feaaa 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 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 @@
statusR = new StatusR.Builder(
before.getKey(),
after.isActive() ? StatusRType.REACTIVATE : StatusRType.SUSPEND).
+ resources(resources).
build();
}
@@ -822,6 +827,7 @@
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 9a92bc3..c3f378c 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.provider.MethodSource;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class SCIMDataBinderTest {
+class SCIMDataBinderTest {
private SCIMDataBinder dataBinder;
@@ -61,6 +61,6 @@
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 8694b99..c85aa38 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 @@
}
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));
});