Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATCH add/remove/replace extensions using path to extension but not to exact attribute #694

Conversation

jasonfagerberg-toast
Copy link

When you attempt to replace an entire extension schema (using EnterpriseSchema as an example here), scimple throws a Null Pointer exception

java.lang.NullPointerException
	at org.apache.directory.scim.core.repository.DefaultPatchHandler.apply(DefaultPatchHandler.java:135)
	at org.apache.directory.scim.core.repository.DefaultPatchHandler.apply(DefaultPatchHandler.java:118)
	at org.apache.directory.scim.core.repository.PatchHandlerTest.applyReplaceEntireEnterpriseExtension(PatchHandlerTest.java:327)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

This is because it is not treating it as an entire resource replacement but an exact path

image

- Removes special checks for operation types, moves logic to specfic PatchOperationHandlers
- Adds test case for removal of full extension
@bdemers bdemers marked this pull request as ready for review December 6, 2024 03:14
@bdemers
Copy link
Member

bdemers commented Dec 6, 2024

@jasonfagerberg-toast I added a fix to this PR.
It's late, and there are a lot of edge cases in this PatchHandler, this is one more.

I think you are right, and this is valid patch request, although there are a quark with how the Attribute's are parsed (see comments)

I also added a test case for a "REMOVE" of a full Extension. I'm not sure if that one is a valid 🤔
(the containing extension object doesn't have a mutability flag, but it's attributes might, which could make it an illegal operation, I'll have to check with the SCIM working group on that). As is I feel it's better to this code path defined and tested, so it's easier to make changes in the future.

Please take a quick pass through the code and let me know if you think something is missing or it's confusing. I'll try to take another look when i'm more awake 😴

@jasonfagerberg-toast
Copy link
Author

jasonfagerberg-toast commented Dec 6, 2024

@jasonfagerberg-toast I added a fix to this PR. It's late, and there are a lot of edge cases in this PatchHandler, this is one more.

Wow this is awesome! Wasn't expecting such a quick turn around! From my initial pass this looks good, I found another example online of a PATCH body doing the same thing in a slightly different way: https://is.docs.wso2.com/en/latest/references/extend/user-mgt/provisioning/extend-scim2-user-schemas/

{
   "schemas":[
      "urn:ietf:params:scim:api:messages:2.0:PatchOp"
   ],
   "Operations":[
      {
         "op":"replace",
         "value":{
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User":{
               "customAttribute":"new value"
            }
         }
      }
   ]
}

So I added a test for that as well, and looks like it is passing 😄

@jasonfagerberg-toast
Copy link
Author

Please take a quick pass through the code and let me know if you think something is missing or it's confusing. I'll try to take another look when i'm more awake 😴

I think for being sleepy this is an excellent PR 😅 I pushed a few small things to the tests but overall LGTM

@bdemers
Copy link
Member

bdemers commented Dec 6, 2024

Thanks for taking a look at the updates!

@jasonfagerberg-toast jasonfagerberg-toast changed the title Write failing test attempting to replace entire enterprise schema PATCH add/remove/replace extensions using path to extension but not to exact attribute Dec 9, 2024
@bdemers
Copy link
Member

bdemers commented Dec 20, 2024

Sorry about the delay on this one, I though we had already merged it!

Thanks again @jasonfagerberg-toast

@bdemers bdemers closed this Dec 20, 2024
@jasonfagerberg-toast
Copy link
Author

Thanks again @jasonfagerberg-toast

Happy holidays :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants