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

Improve Patch Generation logic and add tests #435

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Conversation

bdemers
Copy link
Member

@bdemers bdemers commented Dec 7, 2023

Adding tests and thoughts for: #427

@joshuapsteele sorry, I thought I pushed this up the other day. this branch has problems, but hopefully it results in some thinking out loud

Add new diff implementation without the dependency on zjsonpatch

@bdemers bdemers changed the title Draft: Adding tests for Patch Generation Improve Patch Generation logic and add tests Dec 14, 2023
@@ -201,6 +202,7 @@ private static List<Schema.Attribute> createAttributes(String urn, List<Field> f
log.debug("Attempting to set the attribute type, raw value = " + typeName);
switch (typeName) {
case STRING_TYPE_IDENTIFIER:
case STRING_TYPE:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to add an issue to make coverage is good here.
These issues likely only affect Extensions, but that is still important.

The issue I was seeing is one of the Test object Extensions has a list of strings. Without this fix that list was, the list was showing up as a complex type, and would not diff correctly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but there was a similar issue in #425
Added more robust fix and tests in #452

@bdemers bdemers marked this pull request as ready for review December 14, 2023 05:42
@bdemers
Copy link
Member Author

bdemers commented Dec 15, 2023

Before merging, i'll break this up into more isolated changes

@bdemers
Copy link
Member Author

bdemers commented Dec 15, 2023

splitting this PR up, see: ##451

The json patch solution required seralizing objects, then processing them with zjsonpatch, and finally some heavy post processing.

This new solution walks the tree schema attributes to calculate the diff directly.
Class was moved to scim-tools, as it's not directly used by scim-server or scim-client.
PatchGenerator could be used by a SCIM client to calculate diffs to send to a server
Or to generate patch requests when testing a server.

NOTE: There are some limitations, this implementation assumes any changes to an object in a collection modifies the whole object,
this will alwasy trigger a REMOVE and ADD operation (instead of a REPLACE).
@bdemers bdemers merged commit 03d4314 into develop Dec 15, 2023
2 checks passed
@bdemers bdemers deleted the patch-gen-tests branch December 15, 2023 22:00
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.

1 participant