Skip to content
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

PRMP-1242: Fix missing auth service bug #466

Merged
merged 6 commits into from
Nov 22, 2024
Merged

PRMP-1242: Fix missing auth service bug #466

merged 6 commits into from
Nov 22, 2024

Conversation

abbas-khan10
Copy link
Contributor

No description provided.

@@ -26,8 +25,7 @@ def __init__(self, user_role, user_ods_code):

def handle_search_patient_request(self, nhs_number):
try:
auth_service = NhsOauthService(self.ssm_service)
pds_api_service = get_pds_service()(self.ssm_service, auth_service)
pds_api_service = get_pds_service()
Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of consistency, could we modify the name here to pds_service as set in other parts of the code? (e.g lloyd_george_validator.py line 215)

Suggested change
pds_api_service = get_pds_service()
pds_service = get_pds_service()

Copy link
Contributor

Choose a reason for hiding this comment

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

Good shout! I like your thinking, pds_api_service is a pretty loaded term, being the name of the unstubbed service.

Comment on lines 40 to 61
def test_get_pds_service_returns_stubbed_pds_when_true(monkeypatch):
monkeypatch.setenv("PDS_FHIR_IS_STUBBED", "True")

response = get_pds_service()

assert isinstance(response, MockPdsApiService)


def test_get_pds_service_returns_stubbed_pds_when_unset():
response = get_pds_service()

assert isinstance(response, MockPdsApiService)


def test_get_pds_service_returns_real_pds(monkeypatch):
monkeypatch.setenv("PDS_FHIR_IS_STUBBED", "False")

response = get_pds_service()

assert isinstance(response, PdsApiService)


Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed that in lambdas/utils/utilities.py, get_pds_service() checks PDS_FHIR_IS_STUBBED against both "False" and "false" values.
Could we modify these tests to also take into account if the boolean value starts with a lowercase? As testing may require us to modify the PDS_FHIR_IS_STUBBED value manually on the AWS console, I could see ourselves interchangeably setting uppercase or lowercase values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, will make these parameterized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point actually, the terraform contains() which determines this value will set to a lower case true/false our primary check should be for a lower case, but having both would be airtight

Copy link
Contributor

@AndyFlintNHS AndyFlintNHS left a comment

Choose a reason for hiding this comment

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

Approving on Abbas' behalf

@AndyFlintNHS AndyFlintNHS merged commit bc9efaa into main Nov 22, 2024
8 checks passed
@AndyFlintNHS AndyFlintNHS deleted the PRMP-1242 branch November 22, 2024 15:59
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