imulab / go-scim

Building blocks for servers implementing Simple Cloud Identity Management v2
MIT License
145 stars 56 forks source link

fix(pkg): fix replace patch behavior on root property #58

Closed imulab closed 4 years ago

imulab commented 4 years ago

Fix issue 57 where a replace patch operation on the root property would erase all other un-mentioned properties. The issue was identified to be that ComplexProperty.Raw() returns nil properties for all sub properties, regardless of whether they are dirty or not, which leads to the patch operation payload contains lots of nil-valued fields which should not be present; in addition, ComplexProperty.Replace deletes all sub properties before adding to them, effectively replacing the original sub properties with nil value unless they are present in the new value payload.

The fix is two part: first, ComplexProperty.Raw() now only returns sub properties if they are dirty (untouched sub properties are no longer returned), this would break some tests (fixed also in this commit) but the overall behaviour is not changed; second, ComplexProperty.Replace no longer eraises entire property before adding the new value, this also will break some tests (fixed also in this commit) but we will be fine since only the patch operations and tests will actually use ComplexProperty.Replace feature. As a result, this fix will not be considered breaking.

Closes 57