fix(jhe-pgd): make patient consents idempotent and improve invitation…#243
fix(jhe-pgd): make patient consents idempotent and improve invitation…#243travis-sauer-oltech wants to merge 2 commits intomainfrom
Conversation
… links - Make POST/PATCH consents upsert via update_or_create (avoid unique constraint failures) - Use timezone-aware consented_time - Build multi-host invitation links including hostname/client_id/code_verifier/code - Parse CH_INVITATION_LINK_EXCLUDE_HOST as boolean; allow env overrides for PKCE verifier/challenge - Add requirements.txt and fix runtests.py settings module - Add regression test ensuring duplicate consent POST is safe
for more information, see https://pre-commit.ci
| @@ -0,0 +1,23 @@ | |||
| coverage | |||
There was a problem hiding this comment.
As you mentioned, I do like having a plain-pip way to install things here. What I would like to avoid is a complete duplicate of the same information that's bound to get out of sync. I believe the Pipfile can consume this as the true source, though?
Maybe save this change for another PR, since it's not related to the functionality here?
| scope_code_id=scope_code_id, | ||
| ) | ||
|
|
||
| if request.method in ["POST", "PATCH"]: |
There was a problem hiding this comment.
I think it's okay for POST to be Idempotent (I don't have the deepest view on this one).
But shouldn't PATCH still fail if it doesn't exist already? If not, should we lose PATCH as a supported method? It doesn't seem right to have them both present and do the exact same thing.
| from oauth2_provider.models import get_application_model | ||
|
|
||
| from core.admin_pagination import AdminListMixin | ||
| from core.context_processors import _get_oidc_client_id |
There was a problem hiding this comment.
I think this import is unused, if so we should remove it.
| data=payload, | ||
| format="json", | ||
| ) | ||
| self.assertEqual(response2.status_code, 200) |
There was a problem hiding this comment.
Consider also asserting the count did not increase:
consent_count_before = StudyPatientScopeConsent.objects.count()
response2 = self.client.post(...)
self.assertEqual(StudyPatientScopeConsent.objects.count(), consent_count_before)
… links