SCIMReferenceCode
SCIMReferenceCode copied to clipboard
Postman GET User Filters in Users test has problematic URI
The following request in the postman test exists in the User Tests:
{{Protocol}}://{{Server}}{{Port}}/{{Api}}/Users/?filter=DisplayName+eq+%22BobIsAmazing%22
The extra /
after the resource is causing issues. Is this extra /
something our application should be expected to ignore?
The supported filter attributes for resource Users in this sample are userName and externalId. This is defined in the Microsoft.SCIM.WebHostSample/Provider/InMemoryUserProvider.cs method QueryAsync. The extra /
does not cause issues if the attribute is supported.
The sample may benefit from returning a 400 error here instead of a 500 indicating that the attribute filtered is not supported, in addition to the PostMan collection modified to accommodate for this. @ArvindHarinder1 I don't see comments in the SCIM spec giving an answer here one or the other, however, the closest text states that invalid filters found in the query should result in a 400 response. [rfc7644 section 3.4.2.2]
Providers MAY support additional filter operations if they choose. Providers MUST decline to filter results if the specified filter operation is not recognized and return an HTTP 400 error with a "scimType" error of "invalidFilter" and an appropriate human-readable response as per Section 3.12.
In the meantime, you can add the following query to the code to make the displayName test work.
if (queryFilter.AttributePath.Equals(AttributeNames.DisplayName))
{
IEnumerable<Core2EnterpriseUser> allUsers = this.storage.Users.Values;
results =
allUsers.Where(
(Core2EnterpriseUser item) =>
string.Equals(
item.DisplayName,
parameters.AlternateFilters.Single().ComparisonValue,
StringComparison.OrdinalIgnoreCase))
.Select((Core2EnterpriseUser user) => user as Resource).ToArray();
return Task.FromResult(results);
}