Add support for filtering of complex multi-value attributes in coerce
method of SCIMMY.Types.SchemaDefinition
#56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the
SCIMMY.Types.Filter
class does not parse comparators for complex filter expressions unless they are followed by a trailing attribute name (i.e.emails[type eq "work"].value pr
as opposed toemails[type eq "work"] pr
). When the trailing attribute name is missing, the comparator is ignored and the resulting filter is incomplete. This has flow on effects for thecoerce
method of theSCIMMY.Types.SchemaDefinition
class, which is no longer instructed to include theemails
attribute on the coerced value. Additional issues identified include thecoerce
method not evaluating all entries in a supplied filter (or even verifying the filter is an instance of theFilter
class), and not omitting extension namespaces not explicitly included in a list of expected attribute inclusions.Whilst technically defined in RFC7644§3.10 without reference to complex value filters, there is benefit in being capable of parsing and handling these expressions in the
attributes
parameter. Specifically, one would reasonably expect that anattributes
parameter value ofemails[type eq "work"]
is a request to include only thoseemails
that have atype
value ofwork
in the response.This change adds support in the
Filter
class for parsing comparators of complex filter expressions not followed by trailing attribute names, updating relevant internal methods to account for this scenario. Test fixtures for theFilter
class have been updated to verify correct parsing and matching of complex filter expressions not followed by trailing attribute names. Leveraging this change, thecoerce
method of theSchemaDefinition
class has been updated to add support for filtering complex multi-value attributes, only including items that match the given expression in the attribute value (fixes #55). Thecoerce
method has also been updated to verify the supplied filter (if any) is an instance of theFilter
class, evaluate all expressions in a filter, and omit extension namespaces not explicitly included in a list of expected attribute inclusions.