-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/eli 216 nhs number matching #189
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
02ab7ed
negative test for iteration type
Karthikeyannhs 92c0c45
negative test for iteration type
Karthikeyannhs 788f4db
negative test for iteration type
Karthikeyannhs 0fe149f
Int tests now passing with decorator func
robbailiff2 baaf520
Merge branch 'main' into feature/eli-216-nhs_number_matching
robbailiff2 522d516
api gateway IT tests
Karthikeyannhs 2a27a60
Merge branch 'main' into feature/eli-216-nhs_number_matching
Karthikeyannhs 640b361
sonar suppress - covered by lambda tests
Karthikeyannhs 6c3e0d2
NHS_NUMBER_HEADER_NAME in constants
Karthikeyannhs 897141a
Merge branch 'main' into feature/eli-216-nhs_number_matching
Karthikeyannhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| MAGIC_COHORT_LABEL = "elid_all_people" | ||
| RULE_STOP_DEFAULT = False | ||
| NHS_NUMBER_HEADER_NAME = "nhs-login-nhs-number" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import logging | ||
| from collections.abc import Callable | ||
| from functools import wraps | ||
|
|
||
| from mangum.types import LambdaContext, LambdaEvent | ||
|
|
||
| from eligibility_signposting_api.config.contants import NHS_NUMBER_HEADER_NAME | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class MismatchedNHSNumberError(ValueError): | ||
| pass | ||
|
|
||
|
|
||
| def validate_matching_nhs_number() -> Callable: | ||
| def decorator(func: Callable) -> Callable: # pragma: no cover | ||
| @wraps(func) | ||
| def wrapper(event: LambdaEvent, context: LambdaContext) -> dict[str, int | str]: | ||
| headers = event.get("headers", {}) | ||
| path_params = event.get("pathParameters", {}) | ||
|
|
||
| header_nhs = headers.get(NHS_NUMBER_HEADER_NAME) | ||
| path_nhs = path_params.get("id") | ||
|
|
||
| logger.info("nhs numbers from the request", extra={"header_nhs": header_nhs, "path_nhs": path_nhs}) | ||
|
|
||
| if header_nhs != path_nhs: | ||
| logger.error("NHS number mismatch", extra={"header_nhs_no": header_nhs, "path_nhs_no": path_nhs}) | ||
| return {"statusCode": 403, "body": "NHS number mismatch"} | ||
| return func(event, context) | ||
|
|
||
| return wrapper | ||
|
|
||
| return decorator |
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
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
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
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.
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.
Does this work on WSL and MacOS ?
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.
thanks @ayeshalshukri1-nhs , we just rechecked it is working in both the machines.