diff --git a/infrastructure/stacks/api-layer/api_gateway.tf b/infrastructure/stacks/api-layer/api_gateway.tf index 46ccfb6f3..c39cf9f9d 100644 --- a/infrastructure/stacks/api-layer/api_gateway.tf +++ b/infrastructure/stacks/api-layer/api_gateway.tf @@ -56,7 +56,24 @@ resource "aws_api_gateway_stage" "eligibility-signposting-api" { # A subscription filter (see csoc_log_forwarding.tf) forwards these logs to CSOC access_log_settings { destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn - format = "{ \"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\", \"requestTime\":\"$context.requestTime\", \"httpMethod\":\"$context.httpMethod\", \"resourcePath\":\"$context.resourcePath\", \"status\":\"$context.status\", \"protocol\":\"$context.protocol\", \"responseLength\":\"$context.responseLength\", \"accountId\":\"$context.accountId\", \"apiId\":\"$context.apiId\", \"stage\":\"$context.stage\", \"api_key\":\"$context.identity.apiKey\" }" + format = < None: x_correlation_id=request.headers.get("X-Correlation-ID"), nhsd_end_user_organisation_ods=request.headers.get("NHSD-End-User-Organisation-ODS"), nhsd_application_id=request.headers.get("nhsd-application-id"), + nhse_product_id=request.headers.get("nhse-product-id"), ) ), query_params=( diff --git a/src/eligibility_signposting_api/audit/audit_models.py b/src/eligibility_signposting_api/audit/audit_models.py index 2f1b0ee2d..a9d3f8896 100644 --- a/src/eligibility_signposting_api/audit/audit_models.py +++ b/src/eligibility_signposting_api/audit/audit_models.py @@ -17,6 +17,7 @@ class RequestAuditHeader(CamelCaseBaseModel): x_correlation_id: str | None = None nhsd_end_user_organisation_ods: str | None = None nhsd_application_id: str | None = None + nhse_product_id: str | None = None class RequestAuditQueryParams(CamelCaseBaseModel): diff --git a/src/eligibility_signposting_api/config/constants.py b/src/eligibility_signposting_api/config/constants.py index 6deb0b4ec..1594d6d6f 100644 --- a/src/eligibility_signposting_api/config/constants.py +++ b/src/eligibility_signposting_api/config/constants.py @@ -3,5 +3,5 @@ URL_PREFIX = "patient-check" RULE_STOP_DEFAULT = False NHS_NUMBER_HEADER = "nhs-login-nhs-number" -CONSUMER_ID = "nhsd-application-id" # "Nhsd-Application-Id" +CONSUMER_ID = "NHSE-Product-ID" ALLOWED_CONDITIONS = Literal["COVID", "FLU", "MMR", "RSV"] diff --git a/src/eligibility_signposting_api/logging/logs_helper.py b/src/eligibility_signposting_api/logging/logs_helper.py index 12d8a48db..a10e1f050 100644 --- a/src/eligibility_signposting_api/logging/logs_helper.py +++ b/src/eligibility_signposting_api/logging/logs_helper.py @@ -5,6 +5,8 @@ from mangum.types import LambdaContext, LambdaEvent +from eligibility_signposting_api.config.constants import CONSUMER_ID + logger = logging.getLogger(__name__) @@ -20,6 +22,8 @@ def wrapper(event: LambdaEvent, context: LambdaContext) -> dict[str, Any] | None "x_request_id": headers.get("X-Request-ID"), "x_correlation_id": headers.get("X-Correlation-ID"), "gateway_request_id": gateway_request_id, + "nhse_product_id": headers.get(CONSUMER_ID), + "nhsd_application_id": headers.get("nhsd-application-id"), }, ) return func(event, context) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 6be20801c..84ea9a4e5 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -50,7 +50,7 @@ AWS_CURRENT_SECRET = "test_value" # noqa: S105 AWS_PREVIOUS_SECRET = "test_value_old" # noqa: S105 -UNIQUE_CONSUMER_HEADER = "nhsd-application-id" +UNIQUE_CONSUMER_HEADER = "nhse-product-id" @pytest.fixture(scope="session") diff --git a/tests/integration/lambda/test_app_running_as_lambda.py b/tests/integration/lambda/test_app_running_as_lambda.py index 09953f4ca..08618038b 100644 --- a/tests/integration/lambda/test_app_running_as_lambda.py +++ b/tests/integration/lambda/test_app_running_as_lambda.py @@ -207,7 +207,8 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i "x_request_id": "x_request_id", "x_correlation_id": "x_correlation_id", "nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods", - "nhsd-application-id": consumer_id, + "nhsd-application-id": "nhsd-application-id", + "NHSE-Product-ID": consumer_id, }, params={"includeActions": "Y"}, timeout=10, @@ -229,7 +230,8 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i "xRequestId": "x_request_id", "xCorrelationId": "x_correlation_id", "nhsdEndUserOrganisationOds": "nhsd_end_user_organisation_ods", - "nhsdApplicationId": consumer_id, + "nhsdApplicationId": "nhsd-application-id", + "nhseProductId": consumer_id, } expected_query_params = {"category": None, "conditions": None, "includeActions": "Y"} @@ -455,7 +457,8 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( # "x_request_id": "x_request_id", "x_correlation_id": "x_correlation_id", "nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods", - "nhsd_application_id": consumer_id, + "nhsd-application-id": "nhsd-application-id", + "NHSE-Product-ID": consumer_id, }, params={"includeActions": "Y", "category": "VACCINATIONS", "conditions": "COVID,FLU,RSV"}, timeout=10, @@ -475,7 +478,8 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( # "xRequestId": "x_request_id", "xCorrelationId": "x_correlation_id", "nhsdEndUserOrganisationOds": "nhsd_end_user_organisation_ods", - "nhsdApplicationId": consumer_id, + "nhsdApplicationId": "nhsd-application-id", + "nhseProductId": consumer_id, } expected_query_params = {"category": "VACCINATIONS", "conditions": "COVID,FLU,RSV", "includeActions": "Y"} @@ -597,7 +601,8 @@ def test_no_active_iteration_returns_empty_processed_suggestions( "x_request_id": "x_request_id", "x_correlation_id": "x_correlation_id", "nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods", - "nhsd_application_id": consumer_id, + "nhsd-application-id": "nhsd-application-id", + "NHSE-Product-ID": consumer_id, }, params={"includeActions": "Y", "category": "VACCINATIONS", "conditions": "COVID,FLU,RSV"}, timeout=10,