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

Jt/create user api validation #35448

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Conversation

Jtang-1
Copy link
Contributor

@Jtang-1 Jtang-1 commented Nov 26, 2024

Product Description

Technical Summary

USH-4757

The main change in this PR is the addition of an API validation file. This will support the upcoming API for creating Invitations and updating Web Users. The remaining changes involve refactoring to consolidate validations used when bulk uploading Web Users or creating Invitations via the AdminInvitesUserForm.

I reused relevant validations already defined for bulk user import (in user_importer.validation) since the same checks are needed. Some validations previously implemented via the clean method in Django forms were consolidated, while built-in form validations were left as-is.

The key distinction between Invitation creation via the API and via bulk user import is how existing Web Users are handled. Bulk user import checks if the Web User exists and updates it if so. In contrast, the API will have a dedicated POST endpoint for creation. This endpoint will require validating whether the Invitation or Web User already exists and returning an error if it does, mirroring the behavior of the AdminInvitesUserForm.

Feature Flag

No feature flag

Safety Assurance

Safety story

The main changes (addition of validation for Web User creation API) will not be used yet. The changes to the existing validation code are solely refactors and I tested locally that those areas still work as expected.

Automated test coverage

There exists extensive testing on bulk user imports and surrounding validation. test_importer checks that web user and mobile workers can be successfully uploaded/updated. test_validators test that Location, Profile, Custom Data, etc.. validation catches invalid or unauthorized changes. I will add missing Tableau Group and Role validation.

QA Plan

no QA.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@dimagimon dimagimon added Risk: High Change affects files that have been flagged as high risk. Risk: Medium Change affects files that have been flagged as medium risk. labels Nov 26, 2024
@Jtang-1 Jtang-1 force-pushed the jt/create-user-api-validation branch 4 times, most recently from 6568200 to 1a81553 Compare November 28, 2024 05:02
…to make it easier to tell what values are needed
…assigned locations or that primary location is defined if assigned locations is defined
… of the spec format in preparation for reuse
…for web user API. However, there wasn't as much

overlap with validation used for AdminInvitesUserForm. So move validation for Web User Resource its own file and
create a class to organize the validations relevant to AdminInvitesUserForm
…lly defined and the conditionally allowed headers should not be preserved upon additional calls to check_header
@Jtang-1 Jtang-1 force-pushed the jt/create-user-api-validation branch from 1a81553 to 6366ebf Compare November 28, 2024 05:14
couch_user is already included in the request so the test is updated to reflect that.
The couch_user is now used in `bulk_user_upload_api` so the test needs to be updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Risk: High Change affects files that have been flagged as high risk. Risk: Medium Change affects files that have been flagged as medium risk.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants