From b7430835d8f50b6c2db38859736dbbdfc0c233e5 Mon Sep 17 00:00:00 2001 From: davidsarosap <147051848+davidsarosap@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:16:21 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Passing=20filter=20query=20param=20to=20the?= =?UTF-8?q?=20callbacks=20for=20Users/=20and=20Groups=E2=80=A6=20(#232?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing filter query param to the callbacks for Users/ and Groups/ --- .../main/java/com/sap/scimono/api/Groups.java | 3 ++- .../main/java/com/sap/scimono/api/Users.java | 3 ++- .../scimono/callback/groups/GroupsCallback.java | 17 ++++++++++++++++- .../scimono/callback/users/UsersCallback.java | 9 +++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/api/Groups.java b/scimono-server/src/main/java/com/sap/scimono/api/Groups.java index a785d1c..424a2d0 100644 --- a/scimono-server/src/main/java/com/sap/scimono/api/Groups.java +++ b/scimono-server/src/main/java/com/sap/scimono/api/Groups.java @@ -89,10 +89,11 @@ public Groups(@Context Application appContext, @Context UriInfo uriInfo) { // @formatter:off public Response getGroup(@PathParam("id") final String groupId, @QueryParam(ATTRIBUTES_PARAM) final String attributes, + @QueryParam(FILTER_PARAM) final String filter, @QueryParam(EXCLUDED_ATTRIBUTES_PARAM) final String excludedAttributes) { // @formatter:on logger.trace("Reading group {}", groupId); - Group groupFromDb = groupAPI.getGroup(groupId, RequestedResourceAttributesParser.parse(attributes, excludedAttributes)); + Group groupFromDb = groupAPI.getGroup(groupId, RequestedResourceAttributesParser.parse(attributes, excludedAttributes), filter); if (groupFromDb == null) { throw new ResourceNotFoundException(RESOURCE_TYPE_GROUP, groupId); diff --git a/scimono-server/src/main/java/com/sap/scimono/api/Users.java b/scimono-server/src/main/java/com/sap/scimono/api/Users.java index 84c03e7..05aa3a0 100644 --- a/scimono-server/src/main/java/com/sap/scimono/api/Users.java +++ b/scimono-server/src/main/java/com/sap/scimono/api/Users.java @@ -118,11 +118,12 @@ public Response getMe(@Context final SecurityContext sec) { @Path("{id}") // @formatter:off public Response getUser(@PathParam("id") final String userId, + @QueryParam(FILTER_PARAM) final String filter, @QueryParam(ATTRIBUTES_PARAM) final String attributes, @QueryParam(EXCLUDED_ATTRIBUTES_PARAM) final String excludedAttributes) { // @formatter:on logger.trace("Reading user {}", userId); - User userFromDb = usersAPI.getUser(userId, RequestedResourceAttributesParser.parse(attributes, excludedAttributes)); + User userFromDb = usersAPI.getUser(userId, RequestedResourceAttributesParser.parse(attributes, excludedAttributes), filter); if (userFromDb == null) { throw new ResourceNotFoundException(RESOURCE_TYPE_USER, userId); diff --git a/scimono-server/src/main/java/com/sap/scimono/callback/groups/GroupsCallback.java b/scimono-server/src/main/java/com/sap/scimono/callback/groups/GroupsCallback.java index f6ced2d..9a9672f 100644 --- a/scimono-server/src/main/java/com/sap/scimono/callback/groups/GroupsCallback.java +++ b/scimono-server/src/main/java/com/sap/scimono/callback/groups/GroupsCallback.java @@ -16,15 +16,30 @@ public interface GroupsCallback { /** - * @param groupId, unique group id + * @param groupId unique group id of the requested group * @return the group with the specified groupId or null if no such group exists */ Group getGroup(final String groupId); + /** + * @param groupId unique group id of the requested group + * @param additionalAttributes additional attributes to be returned or excluded from the response + * @return the group with the specified groupId or null if no such group exists + */ default Group getGroup(String groupId, RequestedResourceAttributes additionalAttributes) { return getGroup(groupId); } + /** + * @param groupId unique group id of the requested group + * @param additionalAttributes additional attributes to be returned or excluded from the response + * @param filter value of the filter query parameter + * @return the group with the specified groupId or null if no such group exists + */ + default Group getGroup(String groupId, RequestedResourceAttributes additionalAttributes, String filter) { + return getGroup(groupId, additionalAttributes); + } + /** * Returns a page of groups (limited by {@link SCIMConfigurationCallback#getMaxResourcesPerPage()}), * taking into account the specified filter and paging parameters. diff --git a/scimono-server/src/main/java/com/sap/scimono/callback/users/UsersCallback.java b/scimono-server/src/main/java/com/sap/scimono/callback/users/UsersCallback.java index 1d7e04a..7832876 100644 --- a/scimono-server/src/main/java/com/sap/scimono/callback/users/UsersCallback.java +++ b/scimono-server/src/main/java/com/sap/scimono/callback/users/UsersCallback.java @@ -36,6 +36,15 @@ default User getUser(String userId, RequestedResourceAttributes additionalAttrib return getUser(userId); } + /** + * @param additionalAttributes additional attributes to be returned of excluded from the response + * @param filter value of the filter query parameter + * @return the user with the specified userId or null if no such user exists + */ + default User getUser(String userId, RequestedResourceAttributes additionalAttributes, final String filter) { + return getUser(userId, additionalAttributes); + } + /** * Returns a page of users (limited by {@link SCIMConfigurationCallback#getMaxResourcesPerPage()}), * taking into account the specified filter and paging parameters. From 81fd5ffbaa85d2cfc704121a15dce299abfc3848 Mon Sep 17 00:00:00 2001 From: davidsarosap <147051848+davidsarosap@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:18:29 +0100 Subject: [PATCH 2/3] Removing override of a method with a default implementation. (#227) The word "Default" in the "DefaultSchemasCallback.java" let me assume that I can derive classes from it to implement some method which are needed in my use case. The fact that getAttribute is overridden in the DefaultSchemasCallback.java leads to confusion and makes it even harder to make it work with a derived class. I think it is better to just let the default method in the interface shining through. Co-authored-by: Hristo Borisov --- .../scimono/callback/schemas/DefaultSchemasCallback.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scimono-server/src/main/java/com/sap/scimono/callback/schemas/DefaultSchemasCallback.java b/scimono-server/src/main/java/com/sap/scimono/callback/schemas/DefaultSchemasCallback.java index 24b1fd8..b1c20e2 100644 --- a/scimono-server/src/main/java/com/sap/scimono/callback/schemas/DefaultSchemasCallback.java +++ b/scimono-server/src/main/java/com/sap/scimono/callback/schemas/DefaultSchemasCallback.java @@ -4,7 +4,6 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; -import com.sap.scimono.entity.schema.Attribute; import com.sap.scimono.entity.schema.Schema; import java.util.List; @@ -37,9 +36,4 @@ public boolean isValidSchemaName(String schemaName) { throw new WebApplicationException(Response.Status.NOT_IMPLEMENTED); } - @Override - public Attribute getAttribute(String path) { - throw new WebApplicationException(Response.Status.NOT_IMPLEMENTED); - } - } From d2d2f61dffa13d58b06c1fd25bb4feaf3fe28459 Mon Sep 17 00:00:00 2001 From: davidsarosap <147051848+davidsarosap@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:22:03 +0100 Subject: [PATCH 3/3] Changing scope of test deps (#226) I think there are some deps which are only needed in test context. Co-authored-by: Hristo Borisov --- scimono-server/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scimono-server/pom.xml b/scimono-server/pom.xml index 99752a3..a17a401 100644 --- a/scimono-server/pom.xml +++ b/scimono-server/pom.xml @@ -84,18 +84,22 @@ org.mockito mockito-core + test org.mockito mockito-junit-jupiter + test org.junit.jupiter junit-jupiter-engine + test org.junit.jupiter junit-jupiter-params + test