Skip to content

fix(jhe-pgd): make patient consents idempotent and improve invitation…#243

Open
travis-sauer-oltech wants to merge 2 commits intomainfrom
feat/jhe-pgd-update-invitation-link-and-consent-idempotency
Open

fix(jhe-pgd): make patient consents idempotent and improve invitation…#243
travis-sauer-oltech wants to merge 2 commits intomainfrom
feat/jhe-pgd-update-invitation-link-and-consent-idempotency

Conversation

@travis-sauer-oltech
Copy link
Copy Markdown
Member

… 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

… 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
Comment thread requirements.txt
@@ -0,0 +1,23 @@
coverage
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Comment thread core/views/patient.py
scope_code_id=scope_code_id,
)

if request.method in ["POST", "PATCH"]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread core/views/patient.py
from oauth2_provider.models import get_application_model

from core.admin_pagination import AdminListMixin
from core.context_processors import _get_oidc_client_id
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this import is unused, if so we should remove it.

data=payload,
format="json",
)
self.assertEqual(response2.status_code, 200)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

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.

3 participants