Skip to content

Commit ee9e3a9

Browse files
authored
ELI-397: Removes application handling for missing path param (#294)
1 parent 3ebe456 commit ee9e3a9

File tree

3 files changed

+0
-48
lines changed

3 files changed

+0
-48
lines changed

src/eligibility_signposting_api/common/api_error_response.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ class FHIRIssueCode(str, Enum):
2222
FORBIDDEN = "forbidden"
2323
PROCESSING = "processing"
2424
VALUE = "value"
25-
INVALID = "invalid"
2625

2726

2827
class FHIRSpineErrorCode(str, Enum):
2928
ACCESS_DENIED = "ACCESS_DENIED"
3029
INVALID_PARAMETER = "INVALID_PARAMETER"
31-
BAD_REQUEST = "BAD_REQUEST"
3230
INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
3331
REFERENCE_NOT_FOUND = "REFERENCE_NOT_FOUND"
3432

@@ -140,12 +138,3 @@ def log_and_generate_response(
140138
fhir_error_code=FHIRSpineErrorCode.ACCESS_DENIED,
141139
fhir_display_message="Access has been denied to process this request.",
142140
)
143-
144-
145-
NHS_NUMBER_MISSING_ERROR = APIErrorResponse(
146-
status_code=HTTPStatus.BAD_REQUEST,
147-
fhir_issue_code=FHIRIssueCode.INVALID,
148-
fhir_issue_severity=FHIRIssueSeverity.ERROR,
149-
fhir_error_code=FHIRSpineErrorCode.BAD_REQUEST,
150-
fhir_display_message="Bad Request",
151-
)

src/eligibility_signposting_api/common/request_validator.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
INVALID_CONDITION_FORMAT_ERROR,
1212
INVALID_INCLUDE_ACTIONS_ERROR,
1313
NHS_NUMBER_MISMATCH_ERROR,
14-
NHS_NUMBER_MISSING_ERROR,
1514
)
1615
from eligibility_signposting_api.config.contants import NHS_NUMBER_HEADER
1716

@@ -60,12 +59,6 @@ def wrapper(event: LambdaEvent, context: LambdaContext) -> dict[str, Any] | None
6059
path_nhs_no = event.get("pathParameters", {}).get("id")
6160
header_nhs_no = event.get("headers", {}).get(NHS_NUMBER_HEADER)
6261

63-
if not path_nhs_no:
64-
message = "Missing required NHS Number from path parameters"
65-
return NHS_NUMBER_MISSING_ERROR.log_and_generate_response(
66-
log_message=message, diagnostics=message, location_param="id"
67-
)
68-
6962
if not validate_nhs_number(path_nhs_no, header_nhs_no):
7063
message = "You are not authorised to request information for the supplied NHS Number"
7164
return NHS_NUMBER_MISMATCH_ERROR.log_and_generate_response(log_message=message, diagnostics=message)

tests/unit/common/test_request_validator.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,6 @@ def test_validate_request_params_nhs_mismatch(self, caplog):
8383
assert issue["details"]["coding"][0]["display"] == "Access has been denied to process this request."
8484
assert issue["diagnostics"] == "You are not authorised to request information for the supplied NHS Number"
8585

86-
def test_validate_request_params_nhs_missing_in_path(self, caplog):
87-
mock_handler = MagicMock()
88-
mock_context = {}
89-
event = {
90-
"headers": {"nhs-login-nhs-number": "1234567890"},
91-
}
92-
93-
decorator = request_validator.validate_request_params()
94-
wrapped_handler = decorator(mock_handler)
95-
96-
with caplog.at_level(logging.ERROR):
97-
response = wrapped_handler(event, mock_context)
98-
99-
mock_handler.assert_not_called()
100-
101-
assert response is not None
102-
assert response["statusCode"] == HTTPStatus.BAD_REQUEST
103-
response_body = json.loads(response["body"])
104-
issue = response_body["issue"][0]
105-
assert issue["code"] == "invalid"
106-
assert issue["severity"] == "error"
107-
assert issue["details"]["coding"][0]["code"] == "BAD_REQUEST"
108-
assert issue["details"]["coding"][0]["display"] == "Bad Request"
109-
assert issue["diagnostics"] == "Missing required NHS Number from path parameters"
110-
assert issue["location"][0] == "parameters/id"
111-
assert any(
112-
(record.levelname == "ERROR" and "Missing required NHS Number from path parameters" in record.message)
113-
for record in caplog.records
114-
)
115-
11686

11787
class TestValidateQueryParameters:
11888
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)