Skip to content

Commit e975a76

Browse files
authored
Merge pull request #564 from NHSDigital/ELI-623
Eli 623
2 parents 3a69fea + 0f4da27 commit e975a76

7 files changed

Lines changed: 36 additions & 8 deletions

File tree

infrastructure/stacks/api-layer/api_gateway.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,24 @@ resource "aws_api_gateway_stage" "eligibility-signposting-api" {
5656
# A subscription filter (see csoc_log_forwarding.tf) forwards these logs to CSOC
5757
access_log_settings {
5858
destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn
59-
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\" }"
59+
format = <<EOF
60+
{
61+
"accountId": "$context.accountId",
62+
"apiId": "$context.apiId",
63+
"api_key": "$context.identity.apiKey",
64+
"caller": "$context.identity.caller",
65+
"httpMethod": "$context.httpMethod",
66+
"ip": "$context.identity.sourceIp",
67+
"protocol": "$context.protocol",
68+
"requestId": "$context.requestId",
69+
"requestTime": "$context.requestTime",
70+
"resourcePath": "$context.resourcePath",
71+
"responseLength": "$context.responseLength",
72+
"stage": "$context.stage",
73+
"status": "$context.status",
74+
"user": "$context.identity.user"
75+
}
76+
EOF
6077
}
6178

6279
depends_on = [

src/eligibility_signposting_api/audit/audit_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def add_request_details(request: Request) -> None:
4848
x_correlation_id=request.headers.get("X-Correlation-ID"),
4949
nhsd_end_user_organisation_ods=request.headers.get("NHSD-End-User-Organisation-ODS"),
5050
nhsd_application_id=request.headers.get("nhsd-application-id"),
51+
nhse_product_id=request.headers.get("nhse-product-id"),
5152
)
5253
),
5354
query_params=(

src/eligibility_signposting_api/audit/audit_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class RequestAuditHeader(CamelCaseBaseModel):
1717
x_correlation_id: str | None = None
1818
nhsd_end_user_organisation_ods: str | None = None
1919
nhsd_application_id: str | None = None
20+
nhse_product_id: str | None = None
2021

2122

2223
class RequestAuditQueryParams(CamelCaseBaseModel):

src/eligibility_signposting_api/config/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
URL_PREFIX = "patient-check"
44
RULE_STOP_DEFAULT = False
55
NHS_NUMBER_HEADER = "nhs-login-nhs-number"
6-
CONSUMER_ID = "nhsd-application-id" # "Nhsd-Application-Id"
6+
CONSUMER_ID = "NHSE-Product-ID"
77
ALLOWED_CONDITIONS = Literal["COVID", "FLU", "MMR", "RSV"]

src/eligibility_signposting_api/logging/logs_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from mangum.types import LambdaContext, LambdaEvent
77

8+
from eligibility_signposting_api.config.constants import CONSUMER_ID
9+
810
logger = logging.getLogger(__name__)
911

1012

@@ -20,6 +22,8 @@ def wrapper(event: LambdaEvent, context: LambdaContext) -> dict[str, Any] | None
2022
"x_request_id": headers.get("X-Request-ID"),
2123
"x_correlation_id": headers.get("X-Correlation-ID"),
2224
"gateway_request_id": gateway_request_id,
25+
"nhse_product_id": headers.get(CONSUMER_ID),
26+
"nhsd_application_id": headers.get("nhsd-application-id"),
2327
},
2428
)
2529
return func(event, context)

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
AWS_CURRENT_SECRET = "test_value" # noqa: S105
5151
AWS_PREVIOUS_SECRET = "test_value_old" # noqa: S105
5252

53-
UNIQUE_CONSUMER_HEADER = "nhsd-application-id"
53+
UNIQUE_CONSUMER_HEADER = "nhse-product-id"
5454

5555

5656
@pytest.fixture(scope="session")

tests/integration/lambda/test_app_running_as_lambda.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i
207207
"x_request_id": "x_request_id",
208208
"x_correlation_id": "x_correlation_id",
209209
"nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods",
210-
"nhsd-application-id": consumer_id,
210+
"nhsd-application-id": "nhsd-application-id",
211+
"NHSE-Product-ID": consumer_id,
211212
},
212213
params={"includeActions": "Y"},
213214
timeout=10,
@@ -229,7 +230,8 @@ def test_given_nhs_number_in_path_matches_with_nhs_number_in_headers_and_check_i
229230
"xRequestId": "x_request_id",
230231
"xCorrelationId": "x_correlation_id",
231232
"nhsdEndUserOrganisationOds": "nhsd_end_user_organisation_ods",
232-
"nhsdApplicationId": consumer_id,
233+
"nhsdApplicationId": "nhsd-application-id",
234+
"nhseProductId": consumer_id,
233235
}
234236
expected_query_params = {"category": None, "conditions": None, "includeActions": "Y"}
235237

@@ -455,7 +457,8 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( #
455457
"x_request_id": "x_request_id",
456458
"x_correlation_id": "x_correlation_id",
457459
"nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods",
458-
"nhsd_application_id": consumer_id,
460+
"nhsd-application-id": "nhsd-application-id",
461+
"NHSE-Product-ID": consumer_id,
459462
},
460463
params={"includeActions": "Y", "category": "VACCINATIONS", "conditions": "COVID,FLU,RSV"},
461464
timeout=10,
@@ -475,7 +478,8 @@ def test_given_person_has_unique_status_for_different_conditions_with_audit( #
475478
"xRequestId": "x_request_id",
476479
"xCorrelationId": "x_correlation_id",
477480
"nhsdEndUserOrganisationOds": "nhsd_end_user_organisation_ods",
478-
"nhsdApplicationId": consumer_id,
481+
"nhsdApplicationId": "nhsd-application-id",
482+
"nhseProductId": consumer_id,
479483
}
480484
expected_query_params = {"category": "VACCINATIONS", "conditions": "COVID,FLU,RSV", "includeActions": "Y"}
481485

@@ -597,7 +601,8 @@ def test_no_active_iteration_returns_empty_processed_suggestions(
597601
"x_request_id": "x_request_id",
598602
"x_correlation_id": "x_correlation_id",
599603
"nhsd_end_user_organisation_ods": "nhsd_end_user_organisation_ods",
600-
"nhsd_application_id": consumer_id,
604+
"nhsd-application-id": "nhsd-application-id",
605+
"NHSE-Product-ID": consumer_id,
601606
},
602607
params={"includeActions": "Y", "category": "VACCINATIONS", "conditions": "COVID,FLU,RSV"},
603608
timeout=10,

0 commit comments

Comments
 (0)