This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
Change facility history API endpoint switch to a flag activated via group #881
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jwalgran
approved these changes
Oct 23, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I verified that this works properly by first confirming that c2@example.com
could not use the history endpoint, then added them to the group and confirmed that the history endpoint began working.
>>> u = User.objects.get(email='c2@example.com')
>>> g = Group.objects.get(name='can_get_facility_history')
>>> g.user_set.add(u)
I pushed up an additional commit that removes from scripts/resetdb
the attempt to set the now deleted history flag.
rajadain
force-pushed
the
ki/change-history-switch-to-flag
branch
from
October 24, 2019 17:50
f3b303f
to
246bf5d
Compare
Rebased on |
Please hold off on merging until after the 2.16.0 release is complete to prevent a staging deploy. |
rajadain
force-pushed
the
ki/change-history-switch-to-flag
branch
from
October 24, 2019 18:21
246bf5d
to
38508d0
Compare
rajadain
approved these changes
Oct 24, 2019
Add a data migration to add `can_get_facility_history` flag and group.
Update facility history endpoint tests to use the `can_get_facility_history` feature flag. Update facility history endpoint code to replace switch with flag. Replace endpoint decorator with custom flag_is_active check to circumvent a quirk with using waffle & DRF documented here: jazzband/django-waffle#221
Add tests to check the following history endpoint auth cases: - superuser receives 200 - not-signed-in-user receives a 401 - not-permitted-user receives a 403 - permitted user receives 200
This switch was replaced with a flag that is tied to a user group.
jwalgran
force-pushed
the
ki/change-history-switch-to-flag
branch
from
October 24, 2019 21:54
38508d0
to
391f3fd
Compare
🏄 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Overview
Change the facility history API endpoint feature flagging mechanism from a waffle-switch to a waffle-flag which restricts access based on whether the user is a member of a
can_get_facility_history
Group.Update tests and views to replace switch with flag, adding tests to check that the endpoint works as expected for various levels of authorization.
Un-hide facility history API endpoint from Swagger docs, as it will now be public but permission-ed.
Add a data migration to delete the previous
facility_history
switch.Update django-admin to display Group objects.
Connects #875
Notes
Due to an override we have made to the django-admin User object interactions, there is as yet no mechanism for assigning users to groups outside of the command line. I don't know what the preferred way to handle this is, but two options are:
Testing Instructions
./scripts/resetdb
./scripts/test
and verify that they passChecklist
fixup!
commits have been squashed