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

Fix hscim serialization #1714

Merged
merged 9 commits into from
Aug 24, 2021
Merged

Fix hscim serialization #1714

merged 9 commits into from
Aug 24, 2021

Conversation

fisx
Copy link
Contributor

@fisx fisx commented Aug 23, 2021

The SCIM requires json attribute keys to be case-insensitive, and hscim mostly implements this, but not quite, until now. This fixes this: stack test --fast hscim --test-arguments='--match "/Test.Schema.User/JSON serialization/allows casing variations in field names/"' fails on 7fbe431, but passes on 8e2ef77.

This is done by turning all keys in a JSON object to lowercase recursively

Failing tests on 7fbe431 for reference
  test-integration/Test/Spar/Scim/UserSpec.hs:330:5: 
  1) Spar.Scim.User, POST /Users, team has no SAML IdP, creates a user with PendingInvitation, and user can follow usual invitation process
       uncaught exception: ErrorCall
       responseJsonUnsafeWithMsg: ListResponse (WithMeta (WithId (Id * U) (User SparTag))) Error in $.resources[0].fields[0]: key "type" not found
       CallStack (from HasCallStack):
         error, called at src/Bilge/Response.hs:143:7 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafeWithMsg, called at src/Bilge/Response.hs:132:22 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafe, called at test-integration/Util/Scim.hs:260:12 in main:Util.Scim
         listUsers, called at test-integration/Test/Spar/Scim/UserSpec.hs:330:5 in main:Test.Spar.Scim.UserSpec

  To rerun use: --match "/Spar.Scim.User/POST /Users/team has no SAML IdP/creates a user with PendingInvitation, and user can follow usual invitation process/"

  test-integration/Test/Spar/Scim/UserSpec.hs:725:3: 
  2) Spar.Scim.User, POST /Users, team has no SAML IdP, doesn't list users that exceed their invitation period, and allows recreating them
       uncaught exception: ErrorCall
       responseJsonUnsafeWithMsg: ListResponse (WithMeta (WithId (Id * U) (User SparTag))) Error in $.resources[0].fields[0]: key "type" not found
       CallStack (from HasCallStack):
         error, called at src/Bilge/Response.hs:143:7 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafeWithMsg, called at src/Bilge/Response.hs:132:22 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafe, called at test-integration/Util/Scim.hs:260:12 in main:Util.Scim
         listUsers, called at test-integration/Test/Spar/Scim/UserSpec.hs:743:27 in main:Test.Spar.Scim.UserSpec
         searchUser, called at test-integration/Test/Spar/Scim/UserSpec.hs:725:3 in main:Test.Spar.Scim.UserSpec

  To rerun use: --match "/Spar.Scim.User/POST /Users/team has no SAML IdP/doesn't list users that exceed their invitation period, and allows recreating them/"

  test-integration/Test/Spar/Scim/UserSpec.hs:791:12: 
  3) Spar.Scim.User, GET /Users, 1 SAML IdP, finds a SCIM-provisioned user by userName or externalId
       uncaught exception: ErrorCall
       responseJsonUnsafeWithMsg: ListResponse (WithMeta (WithId (Id * U) (User SparTag))) Error in $.resources[0].fields[0]: key "type" not found
       CallStack (from HasCallStack):
         error, called at src/Bilge/Response.hs:143:7 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafeWithMsg, called at src/Bilge/Response.hs:132:22 in bilge-0.22.0-2K7mJKDUfGc17BkrPwuOOW:Bilge.Response
         responseJsonUnsafe, called at test-integration/Util/Scim.hs:260:12 in main:Util.Scim
         listUsers, called at test-integration/Test/Spar/Scim/UserSpec.hs:791:12 in main:Test.Spar.Scim.UserSpec

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.
  • If end-points have been added or changed: the endpoint / config-flag checklist (see Wire-employee only backend wiki page) has been followed.
  • If a schema migration has been added, I ran make git-add-cassandra-schema to update the cassandra schema documentation.
  • Section Unreleased of CHANGELOG-draft.md contains the following bits of information:
    • A line with the title and number of the PR in one or more suitable sub-sections.
    • If /a: measures to be taken by instance operators.
    • If /a: list of cassandra migrations.
    • If public end-points have been changed or added: does nginz need upgrade?
    • If internal end-points have been added or changed: which services have to be deployed in a specific order?

@fisx fisx changed the title Fix hscim serializatoin Fix hscim serialization Aug 23, 2021
(This is a good example for why you should always write your test and
make it fail first, and only then implement the fix.)
@fisx fisx requested a review from jmatsushita August 23, 2021 21:02
@fisx fisx marked this pull request as ready for review August 23, 2021 21:03
Copy link
Contributor

@jmatsushita jmatsushita left a comment

Choose a reason for hiding this comment

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

Did a few changes to the PR description (added failing test log and what this PR does -- apart from the issue it solves). LGTM!

@fisx fisx merged commit 247b44f into develop Aug 24, 2021
@fisx fisx deleted the fix-hscim-client branch August 24, 2021 09:34
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.

None yet

2 participants