Open
Conversation
lambdas/tests/unit/handlers/test_post_user_restriction_handler.py
Outdated
Show resolved
Hide resolved
lambdas/tests/unit/handlers/test_post_user_restriction_handler.py
Outdated
Show resolved
Hide resolved
5d7ec4e to
8f6b18c
Compare
8f6b18c to
5af470e
Compare
Code security issues foundView full details here. |
Code security issues foundView full details here. |
|
Code security issues foundView full details here. |
steph-torres-nhs
approved these changes
Mar 23, 2026
NogaNHS
reviewed
Mar 24, 2026
NogaNHS
reviewed
Mar 24, 2026
| logger.error("Missing user context") | ||
| raise LambdaException( | ||
| 400, | ||
| LambdaError.SearchPatientMissing, |
NogaNHS
reviewed
Mar 24, 2026
Comment on lines
+79
to
+100
| if patient_id != nhs_number: | ||
| logger.error("patientId query param does not match nhs_number in request body") | ||
| raise LambdaException( | ||
| 400, | ||
| LambdaError.PatientIdMismatch, | ||
| ) | ||
|
|
||
| try: | ||
| creator, ods_code = extract_creator_and_ods_code_from_request_context() | ||
| except OdsErrorException: | ||
| logger.error("Missing user context") | ||
| raise LambdaException( | ||
| 400, | ||
| LambdaError.SearchPatientMissing, | ||
| ) | ||
|
|
||
| if restricted_smartcard_id == creator: | ||
| logger.error("You cannot create a restriction for yourself") | ||
| raise LambdaException( | ||
| 400, | ||
| LambdaError.CreateRestrictionSelfRestriction, | ||
| ) |
Contributor
There was a problem hiding this comment.
Should this be in the service? as this is business logic?
NogaNHS
reviewed
Mar 24, 2026
Comment on lines
+102
to
+117
| pds_service = get_pds_service() | ||
| patient = pds_service.fetch_patient_details(nhs_number) | ||
| if not patient: | ||
| logger.error("Patient not found in PDS") | ||
| raise LambdaException( | ||
| 404, | ||
| LambdaError.SearchPatientNoPDS, | ||
| ) | ||
| if patient.general_practice_ods != ods_code: | ||
| logger.error( | ||
| "Patient's general practice ODS does not match request context ODS", | ||
| ) | ||
| raise LambdaException( | ||
| 403, | ||
| LambdaError.SearchPatientNoAuth, | ||
| ) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Jira ticket: PRMP-1465
Description
Context
Checklist
Tasks for all changes:
I have run git pre-commits.(WIP)Deploy - Sandbox- workflow run - mainSANDBOX Full- Deploy feature branch to sandbox- workflow run - 23445862466