math-dojo / user-account-service

Microservice for managing the users of the math-dojo platform
1 stars 0 forks source link

Fix failing Integration Tests for Permission Modifications #30

Closed noce2 closed 4 years ago

noce2 commented 4 years ago

Background

Integration tests to the permissions modification endpoints fail with 400 instead of the expected error codes. For example here (console output also included below).

This failure is caused by the use of lowercase permission names in the tests: https://github.com/math-dojo/user-account-service/blob/8184e95b2ccde8216742418659ea5cdb61dd8fbb/integration-tests/features/support/payloads.js#L38

The serializer that converts the enum to a json string capitalises the value and so expects the same on deserialization. The expected fix was tested via postman and gave the correct response: image

Acceptance Criteria:

Additional Detail

Failures:

1) Scenario: PUT to /permissions with pre-conditioned knownUserId and valid body returns 204 # features\User.feature:68
   √ Given I generate a json payload called 'userPermissionsModificationRequest' # features\step_definitions\request_steps.js:7
   √ When I make a PUT to the function at '/organisations/knownOrgId/users/knownUserId/permissions' # features\step_definitions\request_steps.js:15
   × Then I should get a status code 204 # features\step_definitions\response_steps.js:11
       AssertionError
           + expected - actual

           -400
           +204

           at D:\a\1\s\integration-tests\node_modules\chai-as-promised\lib\chai-as-promised.js:302:22
           at processTicksAndRejections (internal/process/task_queues.js:97:5)
           at async Promise.all (index 0)
   - And the response should have no body # features\step_definitions\response_steps.js:28

2) Scenario: PUT to /permissions with pre-conditioned unknownOrganisationId returns 404 # features\User.feature:81
   √ Given I generate a json payload called 'userPermissionsModificationRequest' # features\step_definitions\request_steps.js:7
   √ When I make a PUT to the function at '/organisations/unknownOrganisationId/users/knownUserId/permissions' # features\step_definitions\request_steps.js:15
   × Then I should get a status code 404 # features\step_definitions\response_steps.js:11
       AssertionError
           + expected - actual

           -400
           +404

           at D:\a\1\s\integration-tests\node_modules\chai-as-promised\lib\chai-as-promised.js:302:22
           at processTicksAndRejections (internal/process/task_queues.js:97:5)
           at async Promise.all (index 0)

3) Scenario: PUT to /permissions with pre-conditioned unknownUserId returns 404 # features\User.feature:87
   √ Given I generate a json payload called 'userPermissionsModificationRequest' # features\step_definitions\request_steps.js:7
   √ When I make a PUT to the function at '/organisations/knownOrganisationId/users/unknownUserId/permissions' # features\step_definitions\request_steps.js:15
   × Then I should get a status code 404 # features\step_definitions\response_steps.js:11
       AssertionError
           + expected - actual

           -400
           +404

           at D:\a\1\s\integration-tests\node_modules\chai-as-promised\lib\chai-as-promised.js:302:22
           at processTicksAndRejections (internal/process/task_queues.js:97:5)
           at async Promise.all (index 0)

24 scenarios (3 failed, 21 passed)
69 steps (3 failed, 1 skipped, 65 passed)