From 0d67716c0ea28960d0bcdd2d8fecacae4933c68f Mon Sep 17 00:00:00 2001 From: Simon Labarere Date: Thu, 4 Jul 2024 14:04:12 +0100 Subject: [PATCH 1/9] CCM-5702: Obfuscate bearer tokens --- .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 2 +- .../test_missing_accept_header.py | 2 +- tests/development/headers/test_cors.py | 4 +-- .../development/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 2 +- .../test_field_validation.py | 30 +++++++++---------- .../test_invalid_routing_plan.py | 6 ++-- .../test_performance.py | 4 +-- .../create_message_batches/test_success.py | 14 ++++----- .../create_messages/test_field_validation.py | 20 ++++++------- .../test_invalid_routing_plan.py | 6 ++-- .../messages/create_messages/test_success.py | 14 ++++----- .../messages/get_message/test_404.py | 4 +-- .../messages/get_message/test_success.py | 12 ++++---- tests/development/nhsapp_accounts/test_400.py | 6 ++-- tests/development/nhsapp_accounts/test_404.py | 4 +-- tests/development/nhsapp_accounts/test_429.py | 2 +- tests/development/nhsapp_accounts/test_502.py | 2 +- .../nhsapp_accounts/test_success.py | 4 +-- tests/development/test_404_errors.py | 2 +- tests/end_to_end/test_email.py | 8 ++--- tests/end_to_end/test_letter.py | 8 ++--- tests/end_to_end/test_nhsapp.py | 12 ++++---- tests/end_to_end/test_sms.py | 8 ++--- .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 2 +- tests/integration/headers/test_cors.py | 4 +-- .../integration/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 2 +- .../test_field_validation.py | 30 +++++++++---------- .../test_invalid_routing_plan.py | 6 ++-- .../test_performance.py | 4 +-- .../create_message_batches/test_success.py | 14 ++++----- .../create_messages/test_field_validation.py | 20 ++++++------- .../test_invalid_routing_plan.py | 6 ++-- .../messages/create_messages/test_success.py | 14 ++++----- .../messages/get_message/test_404.py | 4 +-- .../messages/get_message/test_success.py | 2 +- tests/integration/nhsapp_accounts/test_400.py | 6 ++-- tests/integration/nhsapp_accounts/test_404.py | 2 +- .../nhsapp_accounts/test_success.py | 2 +- tests/integration/test_404_errors.py | 2 +- tests/lib/authentication.py | 3 +- tests/lib/secret.py | 9 ++++++ .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 2 +- tests/production/headers/test_cors.py | 4 +-- .../production/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 2 +- .../test_field_validation.py | 30 +++++++++---------- .../test_invalid_routing_config.py | 4 +-- .../test_performance.py | 4 +-- .../create_messages/test_field_validation.py | 20 ++++++------- .../test_invalid_routing_plan.py | 4 +-- .../messages/get_message/test_404.py | 4 +-- .../messages/get_message/test_success.py | 2 +- tests/production/nhsapp_accounts/test_400.py | 6 ++-- tests/production/nhsapp_accounts/test_404.py | 2 +- .../nhsapp_accounts/test_success.py | 4 +-- tests/production/test_404_errors.py | 2 +- 64 files changed, 213 insertions(+), 203 deletions(-) create mode 100644 tests/lib/secret.py diff --git a/tests/development/content_types/test_406_errors.py b/tests/development/content_types/test_406_errors.py index e6dc04534..edea90462 100644 --- a/tests/development/content_types/test_406_errors.py +++ b/tests/development/content_types/test_406_errors.py @@ -29,7 +29,7 @@ def test_406( .. include:: ../../partials/content_types/test_406.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id }) diff --git a/tests/development/content_types/test_415_errors.py b/tests/development/content_types/test_415_errors.py index de1ecf644..1bd3947d2 100644 --- a/tests/development/content_types/test_415_errors.py +++ b/tests/development/content_types/test_415_errors.py @@ -29,7 +29,7 @@ def test_415_invalid( .. include:: ../../partials/content_types/test_415_invalid.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": "application/json", content_type_name: content_type_value, "X-Correlation-Id": correlation_id diff --git a/tests/development/content_types/test_content_type_negotiation.py b/tests/development/content_types/test_content_type_negotiation.py index 42fd543af..da3fdbc5e 100644 --- a/tests/development/content_types/test_content_type_negotiation.py +++ b/tests/development/content_types/test_content_type_negotiation.py @@ -36,7 +36,7 @@ def test_application_response_type(nhsd_apim_proxy_url, bearer_token_internal_de .. include:: ../../partials/content_types/test_application_response_type.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **accept_headers.get("headers") }) diff --git a/tests/development/content_types/test_missing_accept_header.py b/tests/development/content_types/test_missing_accept_header.py index c07960684..a8f30ad47 100644 --- a/tests/development/content_types/test_missing_accept_header.py +++ b/tests/development/content_types/test_missing_accept_header.py @@ -27,7 +27,7 @@ def test_missing_accept_header( headers={ "Content-Type": content_type, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, }, json=data ) diff --git a/tests/development/headers/test_cors.py b/tests/development/headers/test_cors.py index 9efeab818..805a582b6 100644 --- a/tests/development/headers/test_cors.py +++ b/tests/development/headers/test_cors.py @@ -20,7 +20,7 @@ def test_cors_options(nhsd_apim_proxy_url, bearer_token_internal_dev, method, en .. include :: ../../partials/headers/test_cors_options.rst """ resp = requests.options(f"{nhsd_apim_proxy_url}{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method @@ -38,7 +38,7 @@ def test_cors(nhsd_apim_proxy_url, bearer_token_internal_dev, method, endpoints) .. include :: ../../partials/headers/test_cors.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": "*/*", "Origin": ORIGIN }) diff --git a/tests/development/headers/test_x_amz_removal.py b/tests/development/headers/test_x_amz_removal.py index a9eaac972..a1be05572 100644 --- a/tests/development/headers/test_x_amz_removal.py +++ b/tests/development/headers/test_x_amz_removal.py @@ -12,7 +12,7 @@ def test_request_with_x_amz_is_removed(nhsd_apim_proxy_url, bearer_token_internal_dev, endpoints, method,): resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method diff --git a/tests/development/headers/test_x_correlation_id.py b/tests/development/headers/test_x_correlation_id.py index 1255d6bc3..973a379ca 100644 --- a/tests/development/headers/test_x_correlation_id.py +++ b/tests/development/headers/test_x_correlation_id.py @@ -26,7 +26,7 @@ def test_request_with_x_correlation_id( .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{endpoints}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "x-correlation-id": correlation_id }) diff --git a/tests/development/message_batches/create_message_batches/test_field_validation.py b/tests/development/message_batches/create_message_batches/test_field_validation.py index 73e5ecefe..239864b47 100644 --- a/tests/development/message_batches/create_message_batches/test_field_validation.py +++ b/tests/development/message_batches/create_message_batches/test_field_validation.py @@ -24,7 +24,7 @@ def test_invalid_body(nhsd_apim_proxy_url, bearer_token_internal_dev, correlatio resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -52,7 +52,7 @@ def test_property_missing(nhsd_apim_proxy_url, bearer_token_internal_dev, proper resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -83,7 +83,7 @@ def test_data_null(nhsd_apim_proxy_url, bearer_token_internal_dev, property, poi resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -114,7 +114,7 @@ def test_data_invalid(nhsd_apim_proxy_url, bearer_token_internal_dev, property, resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -151,7 +151,7 @@ def test_data_duplicate(nhsd_apim_proxy_url, bearer_token_internal_dev, property resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -179,7 +179,7 @@ def test_data_too_few_items(nhsd_apim_proxy_url, bearer_token_internal_dev, prop resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -206,7 +206,7 @@ def test_invalid_nhs_number(nhsd_apim_proxy_url, bearer_token_internal_dev, nhs_ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -244,7 +244,7 @@ def test_invalid_dob(nhsd_apim_proxy_url, bearer_token_internal_dev, dob, correl .. include:: ../../partials/validation/test_invalid_dob.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -282,7 +282,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -320,7 +320,7 @@ def test_invalid_message_batch_reference(nhsd_apim_proxy_url, bearer_token_inter .. include:: ../../partials/validation/test_invalid_message_batch_reference.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -358,7 +358,7 @@ def test_invalid_message_reference(nhsd_apim_proxy_url, bearer_token_internal_de .. include:: ../../partials/validation/test_invalid_message_reference.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -397,7 +397,7 @@ def test_blank_value_under_messages(nhsd_apim_proxy_url, bearer_token_internal_d .. include:: ../../partials/validation/test_blank_value_under_messages.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -428,7 +428,7 @@ def test_null_value_under_messages(nhsd_apim_proxy_url, bearer_token_internal_de .. include:: ../../partials/validation/test_null_value_under_messages.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -460,7 +460,7 @@ def test_invalid_personalisation(nhsd_apim_proxy_url, bearer_token_internal_dev, .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -499,7 +499,7 @@ def test_null_personalisation(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py index a58e81b85..b25c337d1 100644 --- a/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py +++ b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -17,7 +17,7 @@ def test_no_such_routing_plan(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ "data": { @@ -54,7 +54,7 @@ def test_routing_plan_not_belonging_to_client_id(nhsd_apim_proxy_url, bearer_tok .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ "data": { @@ -97,7 +97,7 @@ def test_routing_plan_missing_templates( .. include:: ../../partials/invalid_routing_plans/test_500_missing_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ "data": { diff --git a/tests/development/message_batches/create_message_batches/test_performance.py b/tests/development/message_batches/create_message_batches/test_performance.py index f891f2a14..67bf6fcec 100644 --- a/tests/development/message_batches/create_message_batches/test_performance.py +++ b/tests/development/message_batches/create_message_batches/test_performance.py @@ -29,7 +29,7 @@ def test_create_messages_large_invalid_payload(nhsd_apim_proxy_url, bearer_token }) resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE }, json=data @@ -58,7 +58,7 @@ def test_create_messages_large_not_unique_payload(nhsd_apim_proxy_url, bearer_to }) resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE }, json=data diff --git a/tests/development/message_batches/create_message_batches/test_success.py b/tests/development/message_batches/create_message_batches/test_success.py index 7bcd73cf8..e89b46b15 100644 --- a/tests/development/message_batches/create_message_batches/test_success.py +++ b/tests/development/message_batches/create_message_batches/test_success.py @@ -19,7 +19,7 @@ def test_201_message_batch_valid_accept_headers( resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, @@ -44,7 +44,7 @@ def test_201_message_batch_valid_content_type_headers( resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": content_type, }, @@ -73,7 +73,7 @@ def test_201_message_batch_valid_nhs_number( resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, @@ -98,7 +98,7 @@ def test_201_message_batch_valid_dob(nhsd_apim_proxy_url, bearer_token_internal_ resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, @@ -122,7 +122,7 @@ def test_request_without_dob(nhsd_apim_proxy_url, bearer_token_internal_dev): resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, @@ -148,7 +148,7 @@ def test_201_message_batches_request_idempotency( respOne = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, @@ -160,7 +160,7 @@ def test_201_message_batches_request_idempotency( respTwo = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE, }, diff --git a/tests/development/messages/create_messages/test_field_validation.py b/tests/development/messages/create_messages/test_field_validation.py index 3ffcf5c55..b011174c1 100644 --- a/tests/development/messages/create_messages/test_field_validation.py +++ b/tests/development/messages/create_messages/test_field_validation.py @@ -24,7 +24,7 @@ def test_invalid_body(nhsd_apim_proxy_url, bearer_token_internal_dev, correlatio resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -52,7 +52,7 @@ def test_property_missing(nhsd_apim_proxy_url, bearer_token_internal_dev, proper resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -83,7 +83,7 @@ def test_data_null(nhsd_apim_proxy_url, bearer_token_internal_dev, property, poi resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -114,7 +114,7 @@ def test_data_invalid(nhsd_apim_proxy_url, bearer_token_internal_dev, property, resp = requests.post( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, @@ -141,7 +141,7 @@ def test_invalid_nhs_number(nhsd_apim_proxy_url, bearer_token_internal_dev, nhs_ .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -176,7 +176,7 @@ def test_invalid_dob(nhsd_apim_proxy_url, bearer_token_internal_dev, dob, correl .. include:: ../../partials/validation/test_invalid_dob.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -210,7 +210,7 @@ def test_invalid_routing_plan(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -244,7 +244,7 @@ def test_invalid_message_reference(nhsd_apim_proxy_url, bearer_token_internal_de .. include:: ../../partials/validation/test_invalid_message_reference.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -279,7 +279,7 @@ def test_invalid_personalisation(nhsd_apim_proxy_url, bearer_token_internal_dev, .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -313,7 +313,7 @@ def test_null_personalisation(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, **headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/development/messages/create_messages/test_invalid_routing_plan.py b/tests/development/messages/create_messages/test_invalid_routing_plan.py index 9e0b8757e..03fec1871 100644 --- a/tests/development/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/development/messages/create_messages/test_invalid_routing_plan.py @@ -17,7 +17,7 @@ def test_no_such_routing_plan(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ @@ -51,7 +51,7 @@ def test_routing_plan_not_belonging_to_client_id(nhsd_apim_proxy_url, bearer_tok .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ @@ -91,7 +91,7 @@ def test_routing_plan_missing_templates( .. include:: ../../partials/invalid_routing_plans/test_500_missing_routing_plan.rst """ resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id }, json={ "data": { diff --git a/tests/development/messages/create_messages/test_success.py b/tests/development/messages/create_messages/test_success.py index f402e589b..ffb65bb3d 100644 --- a/tests/development/messages/create_messages/test_success.py +++ b/tests/development/messages/create_messages/test_success.py @@ -15,7 +15,7 @@ def test_201_message_valid_accept_headers(nhsd_apim_proxy_url, bearer_token_inte """ data = Generators.generate_valid_create_message_body("dev") resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data @@ -32,7 +32,7 @@ def test_201_message_valid_content_type_headers(nhsd_apim_proxy_url, bearer_toke """ data = Generators.generate_valid_create_message_body("dev") resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": content_type }, json=data @@ -50,7 +50,7 @@ def test_201_message_valid_nhs_number(nhsd_apim_proxy_url, bearer_token_internal data["data"]["attributes"]["recipient"]["nhsNumber"] = constants.VALID_NHS_NUMBER resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data @@ -69,7 +69,7 @@ def test_201_message_valid_dob(nhsd_apim_proxy_url, bearer_token_internal_dev, d data["data"]["attributes"]["recipient"]["dateOfBirth"] = dob resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data @@ -87,7 +87,7 @@ def test_request_without_dob(nhsd_apim_proxy_url, bearer_token_internal_dev): data["data"]["attributes"]["recipient"].pop("dateOfBirth") resp = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data @@ -104,7 +104,7 @@ def test_201_message_request_idempotency(nhsd_apim_proxy_url, bearer_token_inter data = Generators.generate_valid_create_message_body("dev") respOne = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data @@ -113,7 +113,7 @@ def test_201_message_request_idempotency(nhsd_apim_proxy_url, bearer_token_inter time.sleep(5) respTwo = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data diff --git a/tests/development/messages/get_message/test_404.py b/tests/development/messages/get_message/test_404.py index a5060d2e7..81535291e 100644 --- a/tests/development/messages/get_message/test_404.py +++ b/tests/development/messages/get_message/test_404.py @@ -12,7 +12,7 @@ def test_message_id_not_belonging_to_client_id(nhsd_apim_proxy_url, bearer_token """ resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/successful_email_other_owner", - headers={"Authorization": bearer_token_internal_dev} + headers={"Authorization": bearer_token_internal_dev.value} ) Assertions.assert_error_with_optional_correlation_id( resp, @@ -29,7 +29,7 @@ def test_message_id_that_does_not_exist(nhsd_apim_proxy_url, bearer_token_intern """ resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/does_not_exist", - headers={"Authorization": bearer_token_internal_dev} + headers={"Authorization": bearer_token_internal_dev.value} ) Assertions.assert_error_with_optional_correlation_id( resp, diff --git a/tests/development/messages/get_message/test_success.py b/tests/development/messages/get_message/test_success.py index d7088601d..c5c621c12 100644 --- a/tests/development/messages/get_message/test_success.py +++ b/tests/development/messages/get_message/test_success.py @@ -16,7 +16,7 @@ def test_200_get_message(nhsd_apim_proxy_url, bearer_token_internal_dev, accept_ resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/{message_ids}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -33,7 +33,7 @@ def test_200_get_message_pending_enrichment(nhsd_apim_proxy_url, bearer_token_in resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/pending_enrichment_request_item_id", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -51,7 +51,7 @@ def test_200_get_message_sending(nhsd_apim_proxy_url, bearer_token_internal_dev, resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/sending_nhsapp_request_item_id", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -69,7 +69,7 @@ def test_200_get_message_successful(nhsd_apim_proxy_url, bearer_token_internal_d resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/successful_letter_request_item_id", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -87,7 +87,7 @@ def test_200_get_message_failed(nhsd_apim_proxy_url, bearer_token_internal_dev, resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/exit_code_request_item_id", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -105,7 +105,7 @@ def test_200_get_message_cascade(nhsd_apim_proxy_url, bearer_token_internal_dev, resp = requests.get( f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}/cascade_sending_all_status_request_item_id", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "Accept": accept_headers, "Content-Type": "application/json" }, diff --git a/tests/development/nhsapp_accounts/test_400.py b/tests/development/nhsapp_accounts/test_400.py index 343bd1c5e..70447b9e6 100644 --- a/tests/development/nhsapp_accounts/test_400.py +++ b/tests/development/nhsapp_accounts/test_400.py @@ -16,7 +16,7 @@ def test_400_missing_ods_code(nhsd_apim_proxy_url, bearer_token_internal_dev, pa .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_missing_ods_code.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -40,7 +40,7 @@ def test_400_invalid_ods_code(nhsd_apim_proxy_url, bearer_token_internal_dev, od .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_invalid_ods_code.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -65,7 +65,7 @@ def test_400_invalid_page(nhsd_apim_proxy_url, bearer_token_internal_dev, ods_co .. include:: ../../partials/invalid_page/test_400_nhsapp_accounts_invalid_page.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/development/nhsapp_accounts/test_404.py b/tests/development/nhsapp_accounts/test_404.py index 4b17896c7..b6b9d8f1e 100644 --- a/tests/development/nhsapp_accounts/test_404.py +++ b/tests/development/nhsapp_accounts/test_404.py @@ -20,7 +20,7 @@ def test_404_page_not_found(nhsd_apim_proxy_url, bearer_token_internal_dev, ods_ .. include:: ../../partials/not_found/test_404_nhsapp_accounts_page_not_found.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -44,7 +44,7 @@ def test_404_report_not_found(nhsd_apim_proxy_url, bearer_token_internal_dev, co .. include:: ../../partials/not_found/test_404_nhsapp_accounts_report_not_found.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/development/nhsapp_accounts/test_429.py b/tests/development/nhsapp_accounts/test_429.py index d4b983617..34d101e41 100644 --- a/tests/development/nhsapp_accounts/test_429.py +++ b/tests/development/nhsapp_accounts/test_429.py @@ -17,7 +17,7 @@ def test_429_too_many_requests(nhsd_apim_proxy_url, bearer_token_internal_dev, c .. include:: ../../partials/too_many_requests/test_429_nhs_app_accounts_too_many_requests.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/development/nhsapp_accounts/test_502.py b/tests/development/nhsapp_accounts/test_502.py index 95f8dfed5..cf04ae953 100644 --- a/tests/development/nhsapp_accounts/test_502.py +++ b/tests/development/nhsapp_accounts/test_502.py @@ -17,7 +17,7 @@ def test_502_bad_gateway(nhsd_apim_proxy_url, bearer_token_internal_dev, correla .. include:: ../../partials/bad_gatway/test_502_bad_gateway.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/development/nhsapp_accounts/test_success.py b/tests/development/nhsapp_accounts/test_success.py index 10b7a9946..ca0e3711c 100644 --- a/tests/development/nhsapp_accounts/test_success.py +++ b/tests/development/nhsapp_accounts/test_success.py @@ -17,7 +17,7 @@ def test_single_page(nhsd_apim_proxy_url, bearer_token_internal_dev, ods_code, p .. include:: ../../partials/happy_path/test_200_get_nhsapp_accounts_single_page.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -39,7 +39,7 @@ def test_multi_pages(nhsd_apim_proxy_url, bearer_token_internal_dev, ods_code, p .. include:: ../../partials/happy_path/test_200_get_nhsapp_accounts_multi_pages.rst """ resp = requests.get(f"{nhsd_apim_proxy_url}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/development/test_404_errors.py b/tests/development/test_404_errors.py index 8ad542ca4..f09c4a1c9 100644 --- a/tests/development/test_404_errors.py +++ b/tests/development/test_404_errors.py @@ -17,7 +17,7 @@ def test_404_not_found(nhsd_apim_proxy_url, bearer_token_internal_dev, request_p .. include:: ../../partials/not_found/test_404_not_found.rst """ resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ - "Authorization": bearer_token_internal_dev, + "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "*/*", "Content-Type": "application/json" diff --git a/tests/end_to_end/test_email.py b/tests/end_to_end/test_email.py index eca4103eb..0ffdbfa29 100644 --- a/tests/end_to_end/test_email.py +++ b/tests/end_to_end/test_email.py @@ -13,7 +13,7 @@ def test_email_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_interna """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("email", "internal-dev") ) @@ -21,7 +21,7 @@ def test_email_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_interna Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id ) @@ -39,7 +39,7 @@ def test_email_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("email", "internal-qa") ) @@ -47,7 +47,7 @@ def test_email_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id ) diff --git a/tests/end_to_end/test_letter.py b/tests/end_to_end/test_letter.py index b2fec4df9..9ce2a15ab 100644 --- a/tests/end_to_end/test_letter.py +++ b/tests/end_to_end/test_letter.py @@ -13,7 +13,7 @@ def test_letter_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_intern """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("letter", "internal-dev"), ) @@ -21,7 +21,7 @@ def test_letter_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_intern Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id, end_state="sending", poll_time=595, @@ -43,7 +43,7 @@ def test_letter_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("letter", "internal-qa"), ) @@ -51,7 +51,7 @@ def test_letter_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id, end_state="sending", poll_time=595, diff --git a/tests/end_to_end/test_nhsapp.py b/tests/end_to_end/test_nhsapp.py index 564b826b1..23d14a5c7 100644 --- a/tests/end_to_end/test_nhsapp.py +++ b/tests/end_to_end/test_nhsapp.py @@ -12,7 +12,7 @@ def test_nhsapp_end_to_end(nhsd_apim_proxy_url, bearer_token_internal_dev): """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("nhsapp", "internal-dev") ) @@ -20,14 +20,14 @@ def test_nhsapp_end_to_end(nhsd_apim_proxy_url, bearer_token_internal_dev): Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id ) Assertions.assert_get_message_status( Helper.get_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, message_id ), "delivered" @@ -44,7 +44,7 @@ def test_nhsapp_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("nhsapp", "internal-qa", personalisation) ) @@ -52,7 +52,7 @@ def test_nhsapp_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id, end_state="sending" ) @@ -60,7 +60,7 @@ def test_nhsapp_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): Assertions.assert_get_message_status( Helper.get_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, message_id ), "sending" diff --git a/tests/end_to_end/test_sms.py b/tests/end_to_end/test_sms.py index aec94625b..b555f419d 100644 --- a/tests/end_to_end/test_sms.py +++ b/tests/end_to_end/test_sms.py @@ -13,7 +13,7 @@ def test_sms_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_internal_ """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("sms", "internal-dev") ) @@ -21,7 +21,7 @@ def test_sms_end_to_end_internal_dev(nhsd_apim_proxy_url, bearer_token_internal_ Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id ) @@ -39,7 +39,7 @@ def test_sms_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): """ resp = Helper.send_single_message( nhsd_apim_proxy_url, - {"Authorization": bearer_token_internal_dev}, + {"Authorization": bearer_token_internal_dev.value}, Generators.generate_send_message_body("sms", "internal-qa") ) @@ -47,7 +47,7 @@ def test_sms_end_to_end_uat(nhsd_apim_proxy_url, bearer_token_internal_dev): Helper.poll_get_message( url=nhsd_apim_proxy_url, - auth={"Authorization": bearer_token_internal_dev}, + auth={"Authorization": bearer_token_internal_dev.value}, message_id=message_id ) diff --git a/tests/integration/content_types/test_406_errors.py b/tests/integration/content_types/test_406_errors.py index d12998dcf..31c04d681 100644 --- a/tests/integration/content_types/test_406_errors.py +++ b/tests/integration/content_types/test_406_errors.py @@ -28,7 +28,7 @@ def test_406( resp = getattr(requests, method)(f"{INT_URL}{endpoints}", headers={ accept_header_name: accept_header_value, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, }) Assertions.assert_error_with_optional_correlation_id( diff --git a/tests/integration/content_types/test_415_errors.py b/tests/integration/content_types/test_415_errors.py index c64966e94..eb34c87dd 100644 --- a/tests/integration/content_types/test_415_errors.py +++ b/tests/integration/content_types/test_415_errors.py @@ -27,7 +27,7 @@ def test_415_invalid( .. include:: ../../partials/content_types/test_415_invalid.rst """ resp = getattr(requests, method)(f"{INT_URL}{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", content_type_name: content_type_value, "X-Correlation-Id": correlation_id diff --git a/tests/integration/content_types/test_content_type_negotiation.py b/tests/integration/content_types/test_content_type_negotiation.py index ac3f77481..1e283ab13 100644 --- a/tests/integration/content_types/test_content_type_negotiation.py +++ b/tests/integration/content_types/test_content_type_negotiation.py @@ -36,7 +36,7 @@ def test_application_response_type(bearer_token_int, accept_headers, method, end .. include:: ../../partials/content_types/test_application_response_type.rst """ resp = getattr(requests, method)(f"{INT_URL}{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **accept_headers.get("headers") }) diff --git a/tests/integration/headers/test_cors.py b/tests/integration/headers/test_cors.py index 6dfcf2645..98a25f23e 100644 --- a/tests/integration/headers/test_cors.py +++ b/tests/integration/headers/test_cors.py @@ -16,7 +16,7 @@ def test_cors_options(bearer_token_int, method, endpoints): .. include :: ../../partials/headers/test_cors_options.rst """ resp = requests.options(f"{INT_URL}{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method @@ -32,7 +32,7 @@ def test_cors(bearer_token_int, method, endpoints): .. include :: ../../partials/headers/test_cors.rst """ resp = getattr(requests, method)(f"{INT_URL}{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "*/*", "Origin": ORIGIN }) diff --git a/tests/integration/headers/test_x_amz_removal.py b/tests/integration/headers/test_x_amz_removal.py index bd9d18f35..a45b8b4c2 100644 --- a/tests/integration/headers/test_x_amz_removal.py +++ b/tests/integration/headers/test_x_amz_removal.py @@ -12,7 +12,7 @@ def test_request_with_x_amz_is_removed(bearer_token_int, endpoints, method): resp = getattr(requests, method)(f"{INT_URL}/{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method diff --git a/tests/integration/headers/test_x_correlation_id.py b/tests/integration/headers/test_x_correlation_id.py index 61d8c3e6c..5985ec92d 100644 --- a/tests/integration/headers/test_x_correlation_id.py +++ b/tests/integration/headers/test_x_correlation_id.py @@ -16,7 +16,7 @@ def test_request_with_x_correlation_id(bearer_token_int, correlation_id, method, .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ resp = getattr(requests, method)(f"{INT_URL}{endpoints}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "x-correlation-id": correlation_id }) diff --git a/tests/integration/message_batches/create_message_batches/test_field_validation.py b/tests/integration/message_batches/create_message_batches/test_field_validation.py index 24ee176d4..b002c75f6 100644 --- a/tests/integration/message_batches/create_message_batches/test_field_validation.py +++ b/tests/integration/message_batches/create_message_batches/test_field_validation.py @@ -24,7 +24,7 @@ def test_invalid_body(bearer_token_int, correlation_id): headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, data="{}SF{}NOTVALID", ) @@ -52,7 +52,7 @@ def test_property_missing(bearer_token_int, property, pointer, correlation_id): headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=Permutations.new_dict_without_key( Generators.generate_valid_create_message_batch_body("int"), @@ -83,7 +83,7 @@ def test_data_null(bearer_token_int, property, pointer, correlation_id): headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=Permutations.new_dict_with_null_key( Generators.generate_valid_create_message_batch_body("int"), @@ -114,7 +114,7 @@ def test_data_invalid(bearer_token_int, property, pointer, correlation_id): headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_batch_body("int"), @@ -151,7 +151,7 @@ def test_data_duplicate(bearer_token_int, property, pointer, correlation_id): headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=data, ) @@ -179,7 +179,7 @@ def test_data_too_few_items(bearer_token_int, property, pointer, correlation_id) headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_batch_body("int"), @@ -206,7 +206,7 @@ def test_invalid_nhs_number(bearer_token_int, nhs_number, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -245,7 +245,7 @@ def test_invalid_dob(bearer_token_int, dob, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -283,7 +283,7 @@ def test_invalid_routing_plan(bearer_token_int, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -321,7 +321,7 @@ def test_invalid_message_batch_reference(bearer_token_int, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -359,7 +359,7 @@ def test_invalid_message_reference(bearer_token_int, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -398,7 +398,7 @@ def test_blank_value_under_messages(bearer_token_int, invalid_value, correlation resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -429,7 +429,7 @@ def test_null_value_under_messages(bearer_token_int, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -461,7 +461,7 @@ def test_invalid_personalisation(bearer_token_int, correlation_id, personalisati resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -500,7 +500,7 @@ def test_null_personalisation(bearer_token_int, correlation_id, personalisation) resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", diff --git a/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py index 3c290e49a..b6d2b4f4e 100644 --- a/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py +++ b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -24,7 +24,7 @@ def test_no_such_routing_plan(bearer_token_int, correlation_id): resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -62,7 +62,7 @@ def test_routing_plan_not_belonging_to_client_id(bearer_token_int, correlation_i resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "MessageBatch", @@ -100,7 +100,7 @@ def test_routing_plan_missing_templates(bearer_token_int, correlation_id, routin """ resp = requests.post(f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id }, json={ "data": { diff --git a/tests/integration/message_batches/create_message_batches/test_performance.py b/tests/integration/message_batches/create_message_batches/test_performance.py index e9325a0db..9b79c43be 100644 --- a/tests/integration/message_batches/create_message_batches/test_performance.py +++ b/tests/integration/message_batches/create_message_batches/test_performance.py @@ -31,7 +31,7 @@ def test_create_messages_large_invalid_payload(bearer_token_int): resp = requests.post(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=data ) Assertions.assert_error_with_optional_correlation_id(resp, 400, None, None) @@ -60,7 +60,7 @@ def test_create_messages_large_not_unique_payload(bearer_token_int): resp = requests.post(f"{INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": CONTENT_TYPE, "Content-Type": CONTENT_TYPE, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json=data ) Assertions.assert_error_with_optional_correlation_id(resp, 400, None, None) diff --git a/tests/integration/message_batches/create_message_batches/test_success.py b/tests/integration/message_batches/create_message_batches/test_success.py index e4d1ffab3..3357978a4 100644 --- a/tests/integration/message_batches/create_message_batches/test_success.py +++ b/tests/integration/message_batches/create_message_batches/test_success.py @@ -18,7 +18,7 @@ def test_201_message_batch_valid_accept_headers(bearer_token_int, accept_headers resp = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": accept_headers, "Content-Type": "application/json", }, @@ -42,7 +42,7 @@ def test_201_message_batch_valid_content_type_headers(bearer_token_int, content_ resp = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": content_type, }, @@ -65,7 +65,7 @@ def test_201_message_batch_valid_nhs_number(bearer_token_int): resp = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json", }, @@ -90,7 +90,7 @@ def test_201_message_batch_valid_dob(bearer_token_int, dob): resp = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json", }, @@ -114,7 +114,7 @@ def test_request_without_dob(bearer_token_int): resp = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json", }, @@ -137,7 +137,7 @@ def test_201_message_batches_request_idempotency(bearer_token_int): respOne = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json", }, @@ -149,7 +149,7 @@ def test_201_message_batches_request_idempotency(bearer_token_int): respTwo = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json", }, diff --git a/tests/integration/messages/create_messages/test_field_validation.py b/tests/integration/messages/create_messages/test_field_validation.py index 17068e088..79cbbed39 100644 --- a/tests/integration/messages/create_messages/test_field_validation.py +++ b/tests/integration/messages/create_messages/test_field_validation.py @@ -24,7 +24,7 @@ def test_invalid_body(bearer_token_int, correlation_id): resp = requests.post( f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, @@ -52,7 +52,7 @@ def test_property_missing(bearer_token_int, property, pointer, correlation_id): resp = requests.post( f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, @@ -83,7 +83,7 @@ def test_data_null(bearer_token_int, property, pointer, correlation_id): resp = requests.post( f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, @@ -114,7 +114,7 @@ def test_data_invalid(bearer_token_int, property, pointer, correlation_id): resp = requests.post( f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, @@ -141,7 +141,7 @@ def test_invalid_nhs_number(bearer_token_int, nhs_number, correlation_id): .. include:: ../../partials/validation/test_invalid_nhs_number.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -176,7 +176,7 @@ def test_invalid_dob(bearer_token_int, dob, correlation_id): .. include:: ../../partials/validation/test_invalid_dob.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -210,7 +210,7 @@ def test_invalid_routing_plan(bearer_token_int, correlation_id): .. include:: ../../partials/validation/test_invalid_routing_plan.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -244,7 +244,7 @@ def test_invalid_message_reference(bearer_token_int, correlation_id): .. include:: ../../partials/validation/test_invalid_message_reference.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -279,7 +279,7 @@ def test_invalid_personalisation(bearer_token_int, correlation_id, personalisati .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ @@ -313,7 +313,7 @@ def test_null_personalisation(bearer_token_int, correlation_id, personalisation) .. include:: ../../partials/validation/test_invalid_personalisation.rst """ resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, **headers, "X-Correlation-Id": correlation_id }, json={ diff --git a/tests/integration/messages/create_messages/test_invalid_routing_plan.py b/tests/integration/messages/create_messages/test_invalid_routing_plan.py index e17061106..8b644fb55 100644 --- a/tests/integration/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/integration/messages/create_messages/test_invalid_routing_plan.py @@ -25,7 +25,7 @@ def test_no_such_routing_plan(bearer_token_int, correlation_id): resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { @@ -60,7 +60,7 @@ def test_routing_plan_not_belonging_to_client_id(bearer_token_int, correlation_i resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { @@ -96,7 +96,7 @@ def test_routing_plan_missing_templates(bearer_token_int, correlation_id, routin resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ **headers, "X-Correlation-Id": correlation_id, - "Authorization": bearer_token_int + "Authorization": bearer_token_int.value }, json={ "data": { "type": "Message", diff --git a/tests/integration/messages/create_messages/test_success.py b/tests/integration/messages/create_messages/test_success.py index 3de62ad47..a68ab7a54 100644 --- a/tests/integration/messages/create_messages/test_success.py +++ b/tests/integration/messages/create_messages/test_success.py @@ -18,7 +18,7 @@ def test_201_single_message_with_valid_accept_headers(bearer_token_int, accept_h resp = requests.post( f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": accept_headers, "Content-Type": "application/json" }, @@ -35,7 +35,7 @@ def test_201_single_message_with_valid_content_type_headers(bearer_token_int, co """ data = Generators.generate_valid_create_message_body("int") resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": content_type }, json=data @@ -52,7 +52,7 @@ def test_201_single_message_with_valid_nhs_number(bearer_token_int): data["data"]["attributes"]["recipient"]["nhsNumber"] = VALID_NHS_NUMBER resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -70,7 +70,7 @@ def test_201_single_message_with_valid_dob(bearer_token_int, dob): data["data"]["attributes"]["recipient"]["dateOfBirth"] = dob resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -87,7 +87,7 @@ def test_single_message_request_without_dob(bearer_token_int): data["data"]["attributes"]["recipient"].pop("dateOfBirth") resp = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -103,7 +103,7 @@ def test_201_message_request_idempotency(bearer_token_int): data = Generators.generate_valid_create_message_body("int") respOne = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data @@ -112,7 +112,7 @@ def test_201_message_request_idempotency(bearer_token_int): time.sleep(5) respTwo = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data diff --git a/tests/integration/messages/get_message/test_404.py b/tests/integration/messages/get_message/test_404.py index 9dd283bfb..9ee05df82 100644 --- a/tests/integration/messages/get_message/test_404.py +++ b/tests/integration/messages/get_message/test_404.py @@ -14,7 +14,7 @@ def test_message_id_not_belonging_to_client_id(bearer_token_int): """ resp = requests.get( f"{INT_URL}{MESSAGES_ENDPOINT}/{MESSAGE_ID_NOT_BELONGING_TO_CLIENT}", - headers={"Authorization": bearer_token_int} + headers={"Authorization": bearer_token_int.value} ) Assertions.assert_error_with_optional_correlation_id( resp, @@ -31,7 +31,7 @@ def test_message_id_that_does_not_exist(bearer_token_int): """ resp = requests.get( f"{INT_URL}{MESSAGES_ENDPOINT}/does_not_exist", - headers={"Authorization": bearer_token_int} + headers={"Authorization": bearer_token_int.value} ) Assertions.assert_error_with_optional_correlation_id( resp, diff --git a/tests/integration/messages/get_message/test_success.py b/tests/integration/messages/get_message/test_success.py index 3083e1418..31a3d5ade 100644 --- a/tests/integration/messages/get_message/test_success.py +++ b/tests/integration/messages/get_message/test_success.py @@ -15,7 +15,7 @@ def test_200_get_message(bearer_token_int, message_ids): """ resp = requests.get( f"{INT_URL}{MESSAGES_ENDPOINT}/{message_ids}", - headers={"Authorization": bearer_token_int} + headers={"Authorization": bearer_token_int.value} ) Assertions.assert_200_response_message(resp, INT_URL) Assertions.assert_get_message_response_channels(resp, "email", "delivered") diff --git a/tests/integration/nhsapp_accounts/test_400.py b/tests/integration/nhsapp_accounts/test_400.py index 696b4e492..7ba5ae0d0 100644 --- a/tests/integration/nhsapp_accounts/test_400.py +++ b/tests/integration/nhsapp_accounts/test_400.py @@ -16,7 +16,7 @@ def test_400_missing_ods_code(bearer_token_int, page, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_missing_ods_code.rst """ resp = requests.get(f"{constants.INT_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -40,7 +40,7 @@ def test_400_invalid_ods_code(bearer_token_int, ods_code, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_invalid_ods_code.rst """ resp = requests.get(f"{constants.INT_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -65,7 +65,7 @@ def test_400_invalid_page(bearer_token_int, ods_code, page, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_invalid_page.rst """ resp = requests.get(f"{constants.INT_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/integration/nhsapp_accounts/test_404.py b/tests/integration/nhsapp_accounts/test_404.py index 5d9767211..98a1855e2 100644 --- a/tests/integration/nhsapp_accounts/test_404.py +++ b/tests/integration/nhsapp_accounts/test_404.py @@ -19,7 +19,7 @@ def test_404_page_not_found(bearer_token_int, ods_code, page, correlation_id): .. include:: ../../partials/not_found/test_404_nhsapp_accounts_page_not_found.rst """ resp = requests.get(f"{constants.INT_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/integration/nhsapp_accounts/test_success.py b/tests/integration/nhsapp_accounts/test_success.py index f4d22ec5c..511185b54 100644 --- a/tests/integration/nhsapp_accounts/test_success.py +++ b/tests/integration/nhsapp_accounts/test_success.py @@ -17,7 +17,7 @@ def test_single_page(bearer_token_int, ods_code, page, correlation_id): .. include:: ../../partials/happy_path/test_200_get_nhsapp_accounts_single_page.rst """ resp = requests.get(f"{INT_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/integration/test_404_errors.py b/tests/integration/test_404_errors.py index 7038e9ff5..bbbee06f4 100644 --- a/tests/integration/test_404_errors.py +++ b/tests/integration/test_404_errors.py @@ -16,7 +16,7 @@ def test_404_not_found(bearer_token_int, request_path, correlation_id, method): .. include:: ../../partials/not_found/test_404_not_found.rst """ resp = getattr(requests, method)(f"{INT_URL}{request_path}", headers={ - "Authorization": bearer_token_int, + "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "*/*", "Content-Type": "application/json" diff --git a/tests/lib/authentication.py b/tests/lib/authentication.py index 3967ce670..3fb413b7a 100644 --- a/tests/lib/authentication.py +++ b/tests/lib/authentication.py @@ -4,6 +4,7 @@ import jwt import requests import json +from .secret import Secret class AuthenticationCache(): @@ -63,4 +64,4 @@ def generate_authentication(self, env): self.tokens[env] = (f"Bearer {details.get('access_token')}", int(time())) bearer_token = self.tokens[env][0] - return bearer_token + return Secret(bearer_token) diff --git a/tests/lib/secret.py b/tests/lib/secret.py new file mode 100644 index 000000000..e99a1e568 --- /dev/null +++ b/tests/lib/secret.py @@ -0,0 +1,9 @@ +class Secret: + def __init__(self, value): + self.value = value + + def __repr__(self): + return "Secret(********)" + + def __str___(self): + return "*******" diff --git a/tests/production/content_types/test_406_errors.py b/tests/production/content_types/test_406_errors.py index a8432024a..5f9c57124 100644 --- a/tests/production/content_types/test_406_errors.py +++ b/tests/production/content_types/test_406_errors.py @@ -14,7 +14,7 @@ def test_406(bearer_token_prod, method, endpoints): """ resp = getattr(requests, method)(f"{PROD_URL}/{endpoints}", headers={ "Accept": "invalid", - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, }) Assertions.assert_error_with_optional_correlation_id( diff --git a/tests/production/content_types/test_415_errors.py b/tests/production/content_types/test_415_errors.py index 92653304a..373d2a956 100644 --- a/tests/production/content_types/test_415_errors.py +++ b/tests/production/content_types/test_415_errors.py @@ -15,7 +15,7 @@ def test_415_invalid(bearer_token_prod, method, endpoints): .. include:: ../../partials/content_types/test_415_invalid.rst """ resp = getattr(requests, method)(f"{PROD_URL}{endpoints}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "Accept": "application/json", "Content-Type": "invalid" }) diff --git a/tests/production/content_types/test_content_type_negotiation.py b/tests/production/content_types/test_content_type_negotiation.py index 1da6ca1e9..bd949882e 100644 --- a/tests/production/content_types/test_content_type_negotiation.py +++ b/tests/production/content_types/test_content_type_negotiation.py @@ -35,7 +35,7 @@ def test_application_response_type(bearer_token_prod, accept_headers, method, en .. include:: ../../partials/content_types/test_application_response_type.rst """ resp = getattr(requests, method)(f"{PROD_URL}{endpoints}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, **accept_headers.get("headers") }) diff --git a/tests/production/headers/test_cors.py b/tests/production/headers/test_cors.py index c8b20621a..67a3d0c4a 100644 --- a/tests/production/headers/test_cors.py +++ b/tests/production/headers/test_cors.py @@ -16,7 +16,7 @@ def test_cors_options(bearer_token_prod, method, endpoints): .. include :: ../../partials/headers/test_cors_options.rst """ resp = requests.options(f"{PROD_URL}{endpoints}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method @@ -32,7 +32,7 @@ def test_cors(bearer_token_prod, method, endpoints): .. include :: ../../partials/headers/test_cors.rst """ resp = getattr(requests, method)(f"{PROD_URL}{endpoints}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "Accept": "*/*", "Origin": ORIGIN }) diff --git a/tests/production/headers/test_x_amz_removal.py b/tests/production/headers/test_x_amz_removal.py index b7cf3f971..0174bb56b 100644 --- a/tests/production/headers/test_x_amz_removal.py +++ b/tests/production/headers/test_x_amz_removal.py @@ -12,7 +12,7 @@ def test_request_with_x_amz_is_removed(bearer_token_prod, nhsd_apim_proxy_url, endpoints, method): resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}/{endpoints}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "Accept": "*/*", "Origin": ORIGIN, "Access-Control-Request-Method": method diff --git a/tests/production/headers/test_x_correlation_id.py b/tests/production/headers/test_x_correlation_id.py index 51d668c78..31ed7299a 100644 --- a/tests/production/headers/test_x_correlation_id.py +++ b/tests/production/headers/test_x_correlation_id.py @@ -20,7 +20,7 @@ def test_request_with_x_correlation_id( .. include:: ../../partials/headers/test_request_with_x_correlation_id.rst """ resp = getattr(requests, method)(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "x-correlation-id": correlation_id }) diff --git a/tests/production/message_batches/create_message_batches/test_field_validation.py b/tests/production/message_batches/create_message_batches/test_field_validation.py index 82ebbe956..72f8bc467 100644 --- a/tests/production/message_batches/create_message_batches/test_field_validation.py +++ b/tests/production/message_batches/create_message_batches/test_field_validation.py @@ -25,7 +25,7 @@ def test_invalid_body(bearer_token_prod): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, data="{}SF{}NOTVALID", ) @@ -48,7 +48,7 @@ def test_property_missing(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_without_key( Generators.generate_valid_create_message_batch_body(), @@ -74,7 +74,7 @@ def test_data_null(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_null_key( Generators.generate_valid_create_message_batch_body(), @@ -100,7 +100,7 @@ def test_data_invalid(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_batch_body(), @@ -132,7 +132,7 @@ def test_data_duplicate(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=data, ) @@ -155,7 +155,7 @@ def test_data_too_few_items(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_batch_body(), @@ -180,7 +180,7 @@ def test_invalid_nhs_number(bearer_token_prod, nhs_number): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -217,7 +217,7 @@ def test_invalid_dob(bearer_token_prod, dob): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -253,7 +253,7 @@ def test_invalid_routing_plan(bearer_token_prod): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -289,7 +289,7 @@ def test_invalid_message_batch_reference(bearer_token_prod): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -325,7 +325,7 @@ def test_invalid_message_reference(bearer_token_prod): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -362,7 +362,7 @@ def test_blank_value_under_messages(bearer_token_prod, invalid_value): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -391,7 +391,7 @@ def test_null_value_under_messages(bearer_token_prod): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -421,7 +421,7 @@ def test_invalid_personalisation(bearer_token_prod, personalisation): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", @@ -458,7 +458,7 @@ def test_null_personalisation(bearer_token_prod, personalisation): """ resp = requests.post(f"{constants.PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json={ "data": { "type": "MessageBatch", diff --git a/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py index c94710f06..d2b82dd27 100644 --- a/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py +++ b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py @@ -15,7 +15,7 @@ def test_no_such_routing_plan(bearer_token_prod): .. include:: ../../partials/invalid_routing_plans/test_no_such_routing_plan.rst """ resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, }, json={ "data": { "type": "MessageBatch", @@ -50,7 +50,7 @@ def test_routing_plan_not_belonging_to_client_id(bearer_token_prod): .. include:: ../../partials/invalid_routing_plans/test_routing_plan_not_belonging_to_client_id.rst """ resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, }, json={ "data": { "type": "MessageBatch", diff --git a/tests/production/message_batches/create_message_batches/test_performance.py b/tests/production/message_batches/create_message_batches/test_performance.py index 2e78e38d3..bea1c1064 100644 --- a/tests/production/message_batches/create_message_batches/test_performance.py +++ b/tests/production/message_batches/create_message_batches/test_performance.py @@ -30,7 +30,7 @@ def test_create_messages_large_invalid_payload(bearer_token_prod): resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json", - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=data ) Assertions.assert_error_with_optional_correlation_id(resp, 400, None, None) @@ -59,7 +59,7 @@ def test_create_messages_large_not_unique_payload(bearer_token_prod): resp = requests.post(f"{PROD_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Accept": "application/json", "Content-Type": "application/json", - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=data ) Assertions.assert_error_with_optional_correlation_id(resp, 400, None, None) diff --git a/tests/production/messages/create_messages/test_field_validation.py b/tests/production/messages/create_messages/test_field_validation.py index cc4266e2a..972bdcef1 100644 --- a/tests/production/messages/create_messages/test_field_validation.py +++ b/tests/production/messages/create_messages/test_field_validation.py @@ -21,7 +21,7 @@ def test_invalid_body(bearer_token_prod): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, data="{}SF{}NOTVALID", ) @@ -47,7 +47,7 @@ def test_property_missing(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_without_key( Generators.generate_valid_create_message_body("prod"), @@ -76,7 +76,7 @@ def test_data_null(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_null_key( Generators.generate_valid_create_message_body("prod"), @@ -105,7 +105,7 @@ def test_data_invalid(bearer_token_prod, property, pointer): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -132,7 +132,7 @@ def test_invalid_nhs_number(bearer_token_prod, nhs_number): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -159,7 +159,7 @@ def test_invalid_dob(bearer_token_prod, dob): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -185,7 +185,7 @@ def test_invalid_routing_plan(bearer_token_prod): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -211,7 +211,7 @@ def test_invalid_message_reference(bearer_token_prod): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -238,7 +238,7 @@ def test_invalid_personalisation(bearer_token_prod, personalisation): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -265,7 +265,7 @@ def test_null_personalisation(bearer_token_prod, personalisation): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), diff --git a/tests/production/messages/create_messages/test_invalid_routing_plan.py b/tests/production/messages/create_messages/test_invalid_routing_plan.py index c782e2116..5e88c9005 100644 --- a/tests/production/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/production/messages/create_messages/test_invalid_routing_plan.py @@ -23,7 +23,7 @@ def test_no_such_routing_plan(bearer_token_prod): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), @@ -49,7 +49,7 @@ def test_routing_plan_not_belonging_to_client_id(bearer_token_prod): f"{constants.PROD_URL}{MESSAGES_ENDPOINT}", headers={ **headers, - "Authorization": bearer_token_prod + "Authorization": bearer_token_prod.value }, json=Permutations.new_dict_with_new_value( Generators.generate_valid_create_message_body("prod"), diff --git a/tests/production/messages/get_message/test_404.py b/tests/production/messages/get_message/test_404.py index 37fe0f964..596e9ee2a 100644 --- a/tests/production/messages/get_message/test_404.py +++ b/tests/production/messages/get_message/test_404.py @@ -14,7 +14,7 @@ def test_message_id_not_belonging_to_client_id(bearer_token_prod): """ resp = requests.get( f"{PROD_URL}{MESSAGES_ENDPOINT}/{MESSAGE_ID_NOT_BELONGING_TO_CLIENT}", - headers={"Authorization": bearer_token_prod} + headers={"Authorization": bearer_token_prod.value} ) Assertions.assert_error_with_optional_correlation_id( resp, @@ -31,7 +31,7 @@ def test_message_id_that_does_not_exist(bearer_token_prod): """ resp = requests.get( f"{PROD_URL}{MESSAGES_ENDPOINT}/does_not_exist", - headers={"Authorization": bearer_token_prod} + headers={"Authorization": bearer_token_prod.value} ) Assertions.assert_error_with_optional_correlation_id( resp, diff --git a/tests/production/messages/get_message/test_success.py b/tests/production/messages/get_message/test_success.py index 27ef14fbd..d77201505 100644 --- a/tests/production/messages/get_message/test_success.py +++ b/tests/production/messages/get_message/test_success.py @@ -16,7 +16,7 @@ def test_200_get_message(bearer_token_prod, message_ids): """ resp = requests.get( f"{PROD_URL}{MESSAGES_ENDPOINT}/{message_ids}", - headers={"Authorization": bearer_token_prod} + headers={"Authorization": bearer_token_prod.value} ) Assertions.assert_200_response_message(resp, PROD_URL) Assertions.assert_get_message_response_channels(resp, "email", "delivered") diff --git a/tests/production/nhsapp_accounts/test_400.py b/tests/production/nhsapp_accounts/test_400.py index 4c3fdac50..aa0f04e13 100644 --- a/tests/production/nhsapp_accounts/test_400.py +++ b/tests/production/nhsapp_accounts/test_400.py @@ -16,7 +16,7 @@ def test_400_missing_ods_code(bearer_token_prod, page, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_missing_ods_code.rst """ resp = requests.get(f"{constants.PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -40,7 +40,7 @@ def test_400_invalid_ods_code(bearer_token_prod, ods_code, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_invalid_ods_code.rst """ resp = requests.get(f"{constants.PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -65,7 +65,7 @@ def test_400_invalid_page(bearer_token_prod, ods_code, page, correlation_id): .. include:: ../../partials/invalid_ods_code/test_400_nhsapp_accounts_invalid_page.rst """ resp = requests.get(f"{constants.PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/production/nhsapp_accounts/test_404.py b/tests/production/nhsapp_accounts/test_404.py index c6b5f5013..2e68ae521 100644 --- a/tests/production/nhsapp_accounts/test_404.py +++ b/tests/production/nhsapp_accounts/test_404.py @@ -19,7 +19,7 @@ def test_404_page_not_found(bearer_token_prod, ods_code, page, correlation_id): .. include:: ../../partials/not_found/test_404_nhsapp_accounts_page_not_found.rst """ resp = requests.get(f"{constants.PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/production/nhsapp_accounts/test_success.py b/tests/production/nhsapp_accounts/test_success.py index dd0edaad5..34fc283e2 100644 --- a/tests/production/nhsapp_accounts/test_success.py +++ b/tests/production/nhsapp_accounts/test_success.py @@ -18,7 +18,7 @@ def test_single_page(bearer_token_prod, ods_code, page, correlation_id): .. include:: ../../partials/happy_path/test_200_get_nhsapp_accounts_single_page.rst """ resp = requests.get(f"{PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ @@ -39,7 +39,7 @@ def test_multi_pages(bearer_token_prod, ods_code, page, correlation_id): .. include:: ../../partials/happy_path/test_200_get_nhsapp_accounts_multi_pages.rst """ resp = requests.get(f"{PROD_URL}{NHSAPP_ACCOUNTS_ENDPOINT}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "X-Correlation-Id": correlation_id, "Accept": "application/vnd.api+json" }, params={ diff --git a/tests/production/test_404_errors.py b/tests/production/test_404_errors.py index af52cf296..645621f27 100644 --- a/tests/production/test_404_errors.py +++ b/tests/production/test_404_errors.py @@ -16,7 +16,7 @@ def test_404_not_found(bearer_token_prod, request_path, method): .. include:: ../../partials/not_found/test_404_not_found.rst """ resp = getattr(requests, method)(f"{PROD_URL}{request_path}", headers={ - "Authorization": bearer_token_prod, + "Authorization": bearer_token_prod.value, "Accept": "*/*", "Content-Type": "application/json" }) From 2ab0bff858a6c79c7918924ad0351ab2bbbf00a8 Mon Sep 17 00:00:00 2001 From: Rachel Kennedy Date: Wed, 10 Jul 2024 13:25:59 +0100 Subject: [PATCH 2/9] CCM-5506: Update 406 415 Test scenarios --- tests/development/content_types/test_406_errors.py | 4 ++-- tests/development/content_types/test_415_errors.py | 4 ++-- tests/development/test_404_errors.py | 7 +++---- tests/integration/content_types/test_406_errors.py | 4 ++-- tests/integration/content_types/test_415_errors.py | 4 ++-- tests/integration/test_404_errors.py | 7 +++---- tests/sandbox/content_types/test_406_errors.py | 4 ++-- tests/sandbox/content_types/test_415_errors.py | 4 ++-- tests/sandbox/test_404_errors.py | 7 +++---- 9 files changed, 21 insertions(+), 24 deletions(-) diff --git a/tests/development/content_types/test_406_errors.py b/tests/development/content_types/test_406_errors.py index edea90462..f36be90ca 100644 --- a/tests/development/content_types/test_406_errors.py +++ b/tests/development/content_types/test_406_errors.py @@ -4,8 +4,8 @@ from lib.fixtures import * from lib.constants.constants import DEFAULT_CONTENT_TYPE, VALID_ENDPOINTS -HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] -HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +HEADER_NAME = ["accept", "ACCEPT"] +HEADER_VALUE = ["", "application/xml", "application/json; charset=utf-9"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] diff --git a/tests/development/content_types/test_415_errors.py b/tests/development/content_types/test_415_errors.py index 1bd3947d2..82437b7bc 100644 --- a/tests/development/content_types/test_415_errors.py +++ b/tests/development/content_types/test_415_errors.py @@ -4,8 +4,8 @@ from lib.fixtures import * from lib.constants.constants import VALID_ENDPOINTS -CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] -CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +CONTENT_TYPE_NAME = ["content-type", "conTENT_tYpe"] +CONTENT_TYPE_VALUE = ["", "image/png", "application/json; charset=utf-9"] METHODS = ["post", "put", "patch"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] diff --git a/tests/development/test_404_errors.py b/tests/development/test_404_errors.py index f09c4a1c9..6b2ee9de9 100644 --- a/tests/development/test_404_errors.py +++ b/tests/development/test_404_errors.py @@ -3,20 +3,19 @@ from lib import Assertions, Generators from lib.fixtures import * -POST_PATHS = ["/v1/ignore/i-dont-exist", "/api/fake-endpoint", "/im-a-teapot"] +ENDPOINT = "/v1/ignore/i-dont-exist" CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @pytest.mark.devtest -@pytest.mark.parametrize("request_path", POST_PATHS) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) -def test_404_not_found(nhsd_apim_proxy_url, bearer_token_internal_dev, request_path, correlation_id, method): +def test_404_not_found(nhsd_apim_proxy_url, bearer_token_internal_dev, correlation_id, method): """ .. include:: ../../partials/not_found/test_404_not_found.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{ENDPOINT}", headers={ "Authorization": bearer_token_internal_dev.value, "X-Correlation-Id": correlation_id, "Accept": "*/*", diff --git a/tests/integration/content_types/test_406_errors.py b/tests/integration/content_types/test_406_errors.py index 31c04d681..f806800e7 100644 --- a/tests/integration/content_types/test_406_errors.py +++ b/tests/integration/content_types/test_406_errors.py @@ -4,8 +4,8 @@ from lib.constants.constants import CORRELATION_IDS, METHODS, INT_URL, DEFAULT_CONTENT_TYPE, VALID_ENDPOINTS from lib.fixtures import * -HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] -HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +HEADER_NAME = ["accept", "AcCePt"] +HEADER_VALUE = ["", "xyz/abc", "application/json; charset=utf-9"] @pytest.mark.inttest diff --git a/tests/integration/content_types/test_415_errors.py b/tests/integration/content_types/test_415_errors.py index eb34c87dd..9989bfc52 100644 --- a/tests/integration/content_types/test_415_errors.py +++ b/tests/integration/content_types/test_415_errors.py @@ -4,8 +4,8 @@ from lib.constants.constants import INT_URL, CORRELATION_IDS, VALID_ENDPOINTS from lib.fixtures import * -CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] -CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +CONTENT_TYPE_NAME = ["content-type", "conTENT_tYpe"] +CONTENT_TYPE_VALUE = ["", "audio/mpeg", "application/json; charset=utf-9"] METHODS = ["post", "put", "patch"] diff --git a/tests/integration/test_404_errors.py b/tests/integration/test_404_errors.py index bbbee06f4..f9339e9aa 100644 --- a/tests/integration/test_404_errors.py +++ b/tests/integration/test_404_errors.py @@ -4,18 +4,17 @@ from lib.constants.constants import INT_URL, METHODS, CORRELATION_IDS from lib.fixtures import * -POST_PATHS = ["/v1/ignore/i-dont-exist", "/api/fake-endpoint", "/im-a-teapot"] +ENDPOINT = "/v1/ignore/i-dont-exist" @pytest.mark.devtest -@pytest.mark.parametrize("request_path", POST_PATHS) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) -def test_404_not_found(bearer_token_int, request_path, correlation_id, method): +def test_404_not_found(bearer_token_int, correlation_id, method): """ .. include:: ../../partials/not_found/test_404_not_found.rst """ - resp = getattr(requests, method)(f"{INT_URL}{request_path}", headers={ + resp = getattr(requests, method)(f"{INT_URL}{ENDPOINT}", headers={ "Authorization": bearer_token_int.value, "X-Correlation-Id": correlation_id, "Accept": "*/*", diff --git a/tests/sandbox/content_types/test_406_errors.py b/tests/sandbox/content_types/test_406_errors.py index 2c3e8dec1..e3d13744e 100644 --- a/tests/sandbox/content_types/test_406_errors.py +++ b/tests/sandbox/content_types/test_406_errors.py @@ -3,8 +3,8 @@ from lib import Assertions, Generators from lib.constants.constants import METHODS, DEFAULT_CONTENT_TYPE, VALID_ENDPOINTS -HEADER_NAME = ["accept", "ACCEPT", "Accept", "AcCePt"] -HEADER_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +HEADER_NAME = ["accept", "AcCePt"] +HEADER_VALUE = ["", "xyz/abc", "application/json; charset=utf-9"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] diff --git a/tests/sandbox/content_types/test_415_errors.py b/tests/sandbox/content_types/test_415_errors.py index 8114e8894..584c0afe4 100644 --- a/tests/sandbox/content_types/test_415_errors.py +++ b/tests/sandbox/content_types/test_415_errors.py @@ -3,8 +3,8 @@ from lib import Assertions, Generators from lib.constants.constants import VALID_ENDPOINTS -CONTENT_TYPE_NAME = ["content-type", "CONTENT_TYPE", "Content_Type", "conTENT_tYpe"] -CONTENT_TYPE_VALUE = ["", "application/xml", "image/png", "text/plain", "audio/mpeg", "xyz/abc"] +CONTENT_TYPE_NAME = ["content-type", "conTENT_tYpe"] +CONTENT_TYPE_VALUE = ["", "xyz/abc", "application/json; charset=utf-9"] METHODS = ["post", "put", "patch"] CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] diff --git a/tests/sandbox/test_404_errors.py b/tests/sandbox/test_404_errors.py index 23c9b1cff..9fc7e4062 100644 --- a/tests/sandbox/test_404_errors.py +++ b/tests/sandbox/test_404_errors.py @@ -2,20 +2,19 @@ import pytest from lib import Assertions, Generators -POST_PATHS = ["/v1/ignore/i-dont-exist", "/api/fake-endpoint", "/im-a-teapot"] +ENDPOINT = "/v1/ignore/i-dont-exist" CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @pytest.mark.sandboxtest -@pytest.mark.parametrize("request_path", POST_PATHS) @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) @pytest.mark.parametrize("method", METHODS) -def test_404_not_found(nhsd_apim_proxy_url, request_path, correlation_id, method): +def test_404_not_found(nhsd_apim_proxy_url, correlation_id, method): """ .. include:: ../../partials/not_found/test_404_not_found.rst """ - resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{request_path}", headers={ + resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{ENDPOINT}", headers={ "X-Correlation-Id": correlation_id, "Accept": "*/*", "Content-Type": "application/json" From 00bf2336f04165331dc6a814760230fc04fefbdc Mon Sep 17 00:00:00 2001 From: Rachel Kennedy Date: Wed, 10 Jul 2024 15:09:09 +0100 Subject: [PATCH 3/9] CCM-5505: Split timeout tests into their own files --- tests/docs/sandbox/generic/timeouts.rst | 4 +- tests/sandbox/test_408_errors.py | 24 ++++++++++ ...t_timeout_errors.py => test_504_errors.py} | 45 ++++++------------- 3 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 tests/sandbox/test_408_errors.py rename tests/sandbox/{test_timeout_errors.py => test_504_errors.py} (80%) diff --git a/tests/docs/sandbox/generic/timeouts.rst b/tests/docs/sandbox/generic/timeouts.rst index 8581b37cf..bfb752a99 100644 --- a/tests/docs/sandbox/generic/timeouts.rst +++ b/tests/docs/sandbox/generic/timeouts.rst @@ -8,7 +8,7 @@ Server timeouts :noindex: :members: -.. automodule:: sandbox.test_timeout_errors +.. automodule:: sandbox.test_504_errors :noindex: :members: test_504_timeout, test_504_timeout_simulate, test_504_timeout_prefer, test_408_server_timeout_rethrown_504 @@ -16,6 +16,6 @@ Server timeouts Client timeouts --------------- -.. automodule:: sandbox.test_timeout_errors +.. automodule:: sandbox.test_408_errors :noindex: :members: test_408_timeout_prefer diff --git a/tests/sandbox/test_408_errors.py b/tests/sandbox/test_408_errors.py new file mode 100644 index 000000000..317e12610 --- /dev/null +++ b/tests/sandbox/test_408_errors.py @@ -0,0 +1,24 @@ +import requests +import pytest +from lib import Assertions, Generators + +CORRELATION_IDS = [None, "b1ad9302-5df9-4066-bcd2-b274cfab1e72"] + + +@pytest.mark.sandboxtest +@pytest.mark.parametrize("correlation_id", CORRELATION_IDS) +def test_408_timeout_prefer(nhsd_apim_proxy_url, correlation_id): + """ + .. include:: ../../partials/timeouts/test_408_timeout_prefer.rst + """ + resp = requests.get(f"{nhsd_apim_proxy_url}", headers={ + "Prefer": "code=408", + "X-Correlation-Id": correlation_id + }) + + Assertions.assert_error_with_optional_correlation_id( + resp, + 408, + Generators.generate_request_timeout_error(), + correlation_id + ) diff --git a/tests/sandbox/test_timeout_errors.py b/tests/sandbox/test_504_errors.py similarity index 80% rename from tests/sandbox/test_timeout_errors.py rename to tests/sandbox/test_504_errors.py index e1f9befaa..977d195dd 100644 --- a/tests/sandbox/test_timeout_errors.py +++ b/tests/sandbox/test_504_errors.py @@ -7,11 +7,11 @@ @pytest.mark.sandboxtest @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) -def test_408_server_timeout_rethrown_504(nhsd_apim_proxy_url, correlation_id): +def test_504_timeout(nhsd_apim_proxy_url, correlation_id): """ - .. include:: ../../partials/timeouts/test_408_server_timeout_rethrown_504.rst + .. include:: ../../partials/timeouts/test_504_timeout.rst """ - resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout_408", headers={ + resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout_504", headers={ "X-Correlation-Id": correlation_id }) @@ -25,30 +25,11 @@ def test_408_server_timeout_rethrown_504(nhsd_apim_proxy_url, correlation_id): @pytest.mark.sandboxtest @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) -def test_408_timeout_prefer(nhsd_apim_proxy_url, correlation_id): - """ - .. include:: ../../partials/timeouts/test_408_timeout_prefer.rst - """ - resp = requests.get(f"{nhsd_apim_proxy_url}", headers={ - "Prefer": "code=408", - "X-Correlation-Id": correlation_id - }) - - Assertions.assert_error_with_optional_correlation_id( - resp, - 408, - Generators.generate_request_timeout_error(), - correlation_id - ) - - -@pytest.mark.sandboxtest -@pytest.mark.parametrize("correlation_id", CORRELATION_IDS) -def test_504_timeout(nhsd_apim_proxy_url, correlation_id): +def test_504_timeout_simulate(nhsd_apim_proxy_url, correlation_id): """ - .. include:: ../../partials/timeouts/test_504_timeout.rst + .. include:: ../../partials/timeouts/test_504_timeout_simulate.rst """ - resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout_504", headers={ + resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout?sleep=3000", headers={ "X-Correlation-Id": correlation_id }) @@ -62,11 +43,12 @@ def test_504_timeout(nhsd_apim_proxy_url, correlation_id): @pytest.mark.sandboxtest @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) -def test_504_timeout_simulate(nhsd_apim_proxy_url, correlation_id): +def test_504_timeout_prefer(nhsd_apim_proxy_url, correlation_id): """ - .. include:: ../../partials/timeouts/test_504_timeout_simulate.rst + .. include:: ../../partials/timeouts/test_504_timeout_prefer.rst """ - resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout?sleep=3000", headers={ + resp = requests.get(f"{nhsd_apim_proxy_url}", headers={ + "Prefer": "code=504", "X-Correlation-Id": correlation_id }) @@ -80,12 +62,11 @@ def test_504_timeout_simulate(nhsd_apim_proxy_url, correlation_id): @pytest.mark.sandboxtest @pytest.mark.parametrize("correlation_id", CORRELATION_IDS) -def test_504_timeout_prefer(nhsd_apim_proxy_url, correlation_id): +def test_408_server_timeout_rethrown_504(nhsd_apim_proxy_url, correlation_id): """ - .. include:: ../../partials/timeouts/test_504_timeout_prefer.rst + .. include:: ../../partials/timeouts/test_408_server_timeout_rethrown_504.rst """ - resp = requests.get(f"{nhsd_apim_proxy_url}", headers={ - "Prefer": "code=504", + resp = requests.get(f"{nhsd_apim_proxy_url}/_timeout_408", headers={ "X-Correlation-Id": correlation_id }) From 57014821b2fa4bedfc96087d272443f5a15a6646 Mon Sep 17 00:00:00 2001 From: simonlabarere <156111959+simonlabarere@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:07:26 +0100 Subject: [PATCH 4/9] CCM-5798: Update channel status callback doc (#665) * CCM-5798: Update channel status callback doc * CCM-5798: Update channel status callback documentation --- .../callbacks/channel-subscription-openapi-spec.json | 4 ++-- specification/schemas/components/SupplierStatus.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/callbacks/channel-subscription-openapi-spec.json b/specification/callbacks/channel-subscription-openapi-spec.json index f5cbfe1d3..8478183aa 100644 --- a/specification/callbacks/channel-subscription-openapi-spec.json +++ b/specification/callbacks/channel-subscription-openapi-spec.json @@ -11,7 +11,7 @@ } ], "paths": { - "/nhs-notify-callbacks/v1/message-status": { + "/nhs-notify-callbacks/v1/channel-status": { "post": { "summary": "Receive a callback", "description": "You may develop this endpoint on your service if you want to receive callbacks from NHS Notify.\n\nWe have created an OpenAPI specification detailing the behaviour of the endpoint that consumers should create to subscribe to callbacks.\n\nWe will send your API key in the `x-api-key` header. Your service should respond with:\n\n* `401 Unauthorized` if the API key is not received\n* `401 Unauthorized` if the API key is invalid\n\nWe will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from an authorized sender. Details on this will be provided during the onboarding process. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`.\n\nEvery request includes an idempotencyKey located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially.\n\nIf a request fails, our retry policy will make up to three attempts with intervals of five seconds between each attempt.\n\nThe default behaviour of NHS Notify will make a callback to this endpoint when:\n\n* the message has been delivered (via any channel)\n* the message could not be delivered to a given channel (but may be deliverable by an alternative channel)\n* the message could not be delivered by any channel\n\nCallbacks can be received for additional state transitions subject to the needs of the user. These additional state transitions can be requested during onboarding. These statuses are:\n\n* `pending_enrichment` - the message is currently pending enrichment\n* `enriched` - we have queried PDS for this patient's details and now know how to contact this individual\n* `sending` - the message is in the process of being sent", @@ -110,7 +110,7 @@ "description": "The current status of this channel at the time this response was generated.", "$ref": "#/components/schemas/Enum_ChannelStatus" }, - "messageStatusDescription": { + "channelStatusDescription": { "type": "string", "description": "If there is extra information associated with the status of this channel, it is provided here." }, diff --git a/specification/schemas/components/SupplierStatus.yaml b/specification/schemas/components/SupplierStatus.yaml index 5e0796d05..aa7b860f2 100644 --- a/specification/schemas/components/SupplierStatus.yaml +++ b/specification/schemas/components/SupplierStatus.yaml @@ -23,7 +23,7 @@ properties: channelStatus: description: The current status of this channel at the time this response was generated. $ref: ../enums/ChannelStatus.yaml - messageStatusDescription: + channelStatusDescription: type: string description: If there is extra information associated with the status of this channel, it is provided here. example: "" From 10753ba19ecd256bf23fb57afca1601b5cd3762c Mon Sep 17 00:00:00 2001 From: simonlabarere <156111959+simonlabarere@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:44:22 +0100 Subject: [PATCH 5/9] CCM-1704: Address sonar issues (#658) * CCM-1704: Address sonar issues * CCM-1704: Address review comments --- nhsd-git-secrets/nhsd-git-secrets.dockerfile | 7 +- .../resources/jsc/Routing.CheckValid.js | 2 +- .../resources/jsc/SetResponseDefaults.js | 5 +- .../resources/jsc/helpers/validationErrors.js | 2 +- sandbox/Dockerfile | 2 +- sandbox/handlers/batch_send.js | 7 +- sandbox/handlers/get_message.js | 1 - sandbox/handlers/nhsapp_accounts.js | 4 +- sandbox/handlers/utils.js | 5 +- .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 6 +- .../test_missing_accept_header.py | 6 +- tests/development/headers/test_cors.py | 2 +- .../development/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 6 +- .../test_field_validation.py | 2 +- .../test_invalid_routing_plan.py | 2 +- .../test_performance.py | 2 +- .../create_message_batches/test_success.py | 8 +- .../create_messages/test_field_validation.py | 2 +- .../test_invalid_routing_plan.py | 2 +- .../messages/create_messages/test_success.py | 8 +- .../messages/get_message/test_404.py | 2 +- .../messages/get_message/test_success.py | 2 +- tests/development/nhsapp_accounts/test_400.py | 2 +- tests/development/nhsapp_accounts/test_404.py | 2 +- tests/development/nhsapp_accounts/test_429.py | 2 +- tests/development/nhsapp_accounts/test_502.py | 2 +- .../nhsapp_accounts/test_success.py | 2 +- tests/development/test_404_errors.py | 2 +- tests/end_to_end/test_email.py | 2 +- tests/end_to_end/test_letter.py | 2 +- tests/end_to_end/test_nhsapp.py | 2 +- tests/end_to_end/test_sms.py | 2 +- .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 6 +- tests/integration/headers/test_cors.py | 2 +- .../integration/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 6 +- .../test_field_validation.py | 2 +- .../test_invalid_routing_plan.py | 2 +- .../test_performance.py | 2 +- .../create_message_batches/test_success.py | 8 +- .../create_messages/test_field_validation.py | 2 +- .../test_invalid_routing_plan.py | 2 +- .../messages/create_messages/test_success.py | 8 +- .../messages/get_message/test_404.py | 2 +- .../messages/get_message/test_success.py | 2 +- tests/integration/nhsapp_accounts/test_400.py | 2 +- tests/integration/nhsapp_accounts/test_404.py | 2 +- .../nhsapp_accounts/test_success.py | 2 +- tests/integration/test_404_errors.py | 2 +- tests/lib/__init__.py | 2 +- tests/lib/assertions.py | 92 +++++++++---------- tests/lib/constants/constants.py | 12 ++- tests/lib/error_handler.py | 6 +- tests/lib/generators.py | 16 ++-- tests/lib/helper.py | 16 ++-- .../content_types/test_406_errors.py | 2 +- .../content_types/test_415_errors.py | 2 +- .../test_content_type_negotiation.py | 6 +- tests/production/headers/test_cors.py | 2 +- .../production/headers/test_x_amz_removal.py | 2 +- .../headers/test_x_correlation_id.py | 6 +- .../test_field_validation.py | 2 +- .../test_invalid_routing_config.py | 2 +- .../test_performance.py | 6 +- .../create_messages/test_field_validation.py | 2 +- .../test_invalid_routing_plan.py | 2 +- .../messages/get_message/test_404.py | 2 +- .../messages/get_message/test_success.py | 2 +- tests/production/nhsapp_accounts/test_400.py | 2 +- tests/production/nhsapp_accounts/test_404.py | 2 +- .../nhsapp_accounts/test_success.py | 2 +- tests/production/test_404_errors.py | 4 +- .../content_types/test_content_negotiation.py | 4 +- .../sandbox/headers/test_x_correlation_id.py | 4 +- .../test_performance.py | 6 +- tests/sandbox/test_429_errors.py | 4 +- tests/sandbox/test_500_errors.py | 4 +- tests/test_endpoints.py | 10 +- zap/Dockerfile | 2 +- 84 files changed, 195 insertions(+), 200 deletions(-) diff --git a/nhsd-git-secrets/nhsd-git-secrets.dockerfile b/nhsd-git-secrets/nhsd-git-secrets.dockerfile index 2a6c3cec0..636afdd60 100644 --- a/nhsd-git-secrets/nhsd-git-secrets.dockerfile +++ b/nhsd-git-secrets/nhsd-git-secrets.dockerfile @@ -17,11 +17,12 @@ # ################################################################################## -FROM ubuntu:latest +FROM ubuntu:24.10 RUN echo "Installing required modules" -RUN apt-get update -RUN apt-get -y install curl git build-essential +RUN apt-get update \ + && apt-get -y install curl git build-essential \ + && apt-get clean # By default, we copy the entire project into the dockerfile for secret scanning # Tweak that COPY if you only want some of the source diff --git a/proxies/shared/resources/jsc/Routing.CheckValid.js b/proxies/shared/resources/jsc/Routing.CheckValid.js index 7c3a4669b..1a7087403 100644 --- a/proxies/shared/resources/jsc/Routing.CheckValid.js +++ b/proxies/shared/resources/jsc/Routing.CheckValid.js @@ -12,7 +12,7 @@ const isSandbox = /sandbox/.test(context.getVariable("request.header.host")); const validPaths = [ { - match: /^\/v1\/message\-batches$/, + match: /^\/v1\/message-batches$/, methods: ['post'] }, { diff --git a/proxies/shared/resources/jsc/SetResponseDefaults.js b/proxies/shared/resources/jsc/SetResponseDefaults.js index 10370f013..a3e7b79b8 100644 --- a/proxies/shared/resources/jsc/SetResponseDefaults.js +++ b/proxies/shared/resources/jsc/SetResponseDefaults.js @@ -18,15 +18,14 @@ context.setVariable("error.header.Cache-Control", "no-cache, no-store, must-reva context.setVariable("response.header.X-Content-Type-Options", "nosniff"); context.setVariable("error.header.X-Content-Type-Options", "nosniff"); -backendCorrelationId = context.getVariable("backendCorrelationId"); +const backendCorrelationId = context.getVariable("backendCorrelationId"); context.setVariable("response.header.X-Correlation-Id", backendCorrelationId); context.setVariable("error.header.X-Correlation-Id", backendCorrelationId); // remove aws headers const headerNames = (context.getVariable("response.headers.names") + "").slice(1, -1).split(', '); -const headerRegex = /^x-amz/; headerNames.forEach(function (header) { - if (headerRegex.test(header.toLowerCase())) { + if (header.toLowerCase().startsWith('x-amz')) { context.removeVariable("response.header." + header); context.removeVariable("error.header." + header); } diff --git a/proxies/shared/resources/jsc/helpers/validationErrors.js b/proxies/shared/resources/jsc/helpers/validationErrors.js index dd60c3ac7..2192539b9 100644 --- a/proxies/shared/resources/jsc/helpers/validationErrors.js +++ b/proxies/shared/resources/jsc/helpers/validationErrors.js @@ -2,7 +2,7 @@ function createErrorObject(code, title, detail, pointer, links) { return { "id": messageId + "." + errors.length, "code": code, - "links": Object.assign({}, { "about": "https://digital.nhs.uk/developer/api-catalogue/communications-manager" }, links), + "links": Object.assign({}, { "about": "https://digital.nhs.uk/developer/api-catalogue/communications-manager" }, links), // NOSONAR "status": "400", "title": title, "detail": detail, diff --git a/sandbox/Dockerfile b/sandbox/Dockerfile index 59d4abf36..8ccce031d 100644 --- a/sandbox/Dockerfile +++ b/sandbox/Dockerfile @@ -1,4 +1,4 @@ -FROM node:12 +FROM node:20.15.0 COPY . /sandbox diff --git a/sandbox/handlers/batch_send.js b/sandbox/handlers/batch_send.js index bc9332885..f6861f435 100644 --- a/sandbox/handlers/batch_send.js +++ b/sandbox/handlers/batch_send.js @@ -83,12 +83,7 @@ export async function batch_send(req, res, next) { return; } - // Note: the docker container uses node:12 which does not support optional chaining - const odsCodes = messages.map((message) => { - if (message && message.originator) { - return message.originator.odsCode; - } - }); + const odsCodes = messages.map((message) => ( message?.originator?.odsCode )); if (odsCodes.includes(undefined) && req.headers["authorization"] === noDefaultOdsClientAuth) { sendError( res, diff --git a/sandbox/handlers/get_message.js b/sandbox/handlers/get_message.js index d7116927f..4be459bd2 100644 --- a/sandbox/handlers/get_message.js +++ b/sandbox/handlers/get_message.js @@ -25,6 +25,5 @@ export async function get_message(req, res, next) { return } res.type('json').status(200).send(fileContent) - return }); } diff --git a/sandbox/handlers/nhsapp_accounts.js b/sandbox/handlers/nhsapp_accounts.js index 3eac37a68..854a5d5b7 100644 --- a/sandbox/handlers/nhsapp_accounts.js +++ b/sandbox/handlers/nhsapp_accounts.js @@ -2,7 +2,7 @@ import * as fs from 'fs' import { sendError } from './utils.js' const paginationOdsCode = 'T00001'; -const odsCodeRegex = new RegExp('^[A-Za-z]\\d{5}$|^[A-Za-z]\\d[A-Za-z]\\d[A-Za-z]$') +const odsCodeRegex = /^[A-Za-z]\d{5}$|^[A-Za-z]\d[A-Za-z]\d[A-Za-z]$/; const badGatewayOdsCode = 'T00502'; // simulates something going wrong between the BE and the NHS APP API' const notFoundOdsCode = 'T00404'; // valid format but no data stored against it const tooManyRequestsOdsCode = 'T00429'; @@ -18,7 +18,7 @@ export async function nhsapp_accounts(req, res, next) { return; } - if (!req.query || !req.query['ods-organisation-code']) { + if (!req.query?.['ods-organisation-code']) { sendError(res, 400, 'Missing ODS Code') next() return; diff --git a/sandbox/handlers/utils.js b/sandbox/handlers/utils.js index cca66ffd3..5f42e6127 100644 --- a/sandbox/handlers/utils.js +++ b/sandbox/handlers/utils.js @@ -47,8 +47,5 @@ export function hasValidGlobalTemplatePersonalisation(personalisation) { return false; } - if (personalisationFields[0] !== "body") { - return false; - } - return true; + return personalisationFields[0] === "body"; } \ No newline at end of file diff --git a/tests/development/content_types/test_406_errors.py b/tests/development/content_types/test_406_errors.py index f36be90ca..63af42302 100644 --- a/tests/development/content_types/test_406_errors.py +++ b/tests/development/content_types/test_406_errors.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.constants import DEFAULT_CONTENT_TYPE, VALID_ENDPOINTS HEADER_NAME = ["accept", "ACCEPT"] diff --git a/tests/development/content_types/test_415_errors.py b/tests/development/content_types/test_415_errors.py index 82437b7bc..a71a97cd5 100644 --- a/tests/development/content_types/test_415_errors.py +++ b/tests/development/content_types/test_415_errors.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.constants import VALID_ENDPOINTS CONTENT_TYPE_NAME = ["content-type", "conTENT_tYpe"] diff --git a/tests/development/content_types/test_content_type_negotiation.py b/tests/development/content_types/test_content_type_negotiation.py index da3fdbc5e..3f3d34a85 100644 --- a/tests/development/content_types/test_content_type_negotiation.py +++ b/tests/development/content_types/test_content_type_negotiation.py @@ -1,8 +1,8 @@ import requests import pytest from lib.constants.constants import METHODS, VALID_ENDPOINTS -from lib.fixtures import * -from lib import Error_Handler +from lib.fixtures import * # NOSONAR +from lib import error_handler DEFAULT_CONTENT_TYPE = "application/vnd.api+json" ACCEPT_HEADERS = [ @@ -40,6 +40,6 @@ def test_application_response_type(nhsd_apim_proxy_url, bearer_token_internal_de **accept_headers.get("headers") }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.headers.get("Content-Type") == accept_headers.get("expect") diff --git a/tests/development/content_types/test_missing_accept_header.py b/tests/development/content_types/test_missing_accept_header.py index a8f30ad47..2eb300abb 100644 --- a/tests/development/content_types/test_missing_accept_header.py +++ b/tests/development/content_types/test_missing_accept_header.py @@ -1,7 +1,7 @@ import requests import pytest -from lib import Assertions, Generators, Error_Handler -from lib.fixtures import * +from lib import Assertions, Generators, error_handler +from lib.fixtures import * # NOSONAR from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT CORRELATION_IDS = [None, "88b10816-5d45-4992-bed0-ea685aaa0e1f"] @@ -32,7 +32,7 @@ def test_missing_accept_header( json=data ) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) Assertions.assert_201_response( resp, data["data"]["attributes"]["messageBatchReference"], data["data"]["attributes"]["routingPlanId"] diff --git a/tests/development/headers/test_cors.py b/tests/development/headers/test_cors.py index 805a582b6..5f39ca835 100644 --- a/tests/development/headers/test_cors.py +++ b/tests/development/headers/test_cors.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.constants import VALID_ENDPOINTS diff --git a/tests/development/headers/test_x_amz_removal.py b/tests/development/headers/test_x_amz_removal.py index a1be05572..60373a785 100644 --- a/tests/development/headers/test_x_amz_removal.py +++ b/tests/development/headers/test_x_amz_removal.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.constants import VALID_ENDPOINTS, ORIGIN, METHODS diff --git a/tests/development/headers/test_x_correlation_id.py b/tests/development/headers/test_x_correlation_id.py index 973a379ca..bfea48eb8 100644 --- a/tests/development/headers/test_x_correlation_id.py +++ b/tests/development/headers/test_x_correlation_id.py @@ -1,7 +1,7 @@ import requests import pytest -from lib import Error_Handler, Assertions -from lib.fixtures import * +from lib import error_handler, Assertions +from lib.fixtures import * # NOSONAR from lib.constants.constants import VALID_ENDPOINTS @@ -30,6 +30,6 @@ def test_request_with_x_correlation_id( "x-correlation-id": correlation_id }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) Assertions.assert_correlation_id(resp.headers.get("X-Correlation-Id"), correlation_id) diff --git a/tests/development/message_batches/create_message_batches/test_field_validation.py b/tests/development/message_batches/create_message_batches/test_field_validation.py index 239864b47..e459a922b 100644 --- a/tests/development/message_batches/create_message_batches/test_field_validation.py +++ b/tests/development/message_batches/create_message_batches/test_field_validation.py @@ -2,7 +2,7 @@ import pytest import uuid from lib import Assertions, Permutations, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR import lib.constants.constants as constants from lib.constants.shared_paths import ROUTING_PLAN_ID_PATH from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ diff --git a/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py index b25c337d1..b311d7447 100644 --- a/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py +++ b/tests/development/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -2,7 +2,7 @@ import pytest import uuid from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT from lib.constants.constants import INVALID_ROUTING_PLAN from lib.constants.constants import DUPLICATE_ROUTING_PLAN_TEMPLATE_ID diff --git a/tests/development/message_batches/create_message_batches/test_performance.py b/tests/development/message_batches/create_message_batches/test_performance.py index 67bf6fcec..d427882a1 100644 --- a/tests/development/message_batches/create_message_batches/test_performance.py +++ b/tests/development/message_batches/create_message_batches/test_performance.py @@ -2,7 +2,7 @@ import pytest import uuid from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.constants import NUM_MAX_ERRORS from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT diff --git a/tests/development/message_batches/create_message_batches/test_success.py b/tests/development/message_batches/create_message_batches/test_success.py index e89b46b15..197c2782a 100644 --- a/tests/development/message_batches/create_message_batches/test_success.py +++ b/tests/development/message_batches/create_message_batches/test_success.py @@ -2,7 +2,7 @@ import pytest import time from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR import lib.constants.constants as constants from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT @@ -145,7 +145,7 @@ def test_201_message_batches_request_idempotency( """ data = Generators.generate_valid_create_message_batch_body("dev") - respOne = requests.post( + resp_one = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": bearer_token_internal_dev.value, @@ -157,7 +157,7 @@ def test_201_message_batches_request_idempotency( time.sleep(5) - respTwo = requests.post( + resp_two = requests.post( f"{nhsd_apim_proxy_url}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": bearer_token_internal_dev.value, @@ -167,4 +167,4 @@ def test_201_message_batches_request_idempotency( json=data, ) - Assertions.assert_message_batches_idempotency(respOne, respTwo) + Assertions.assert_message_batches_idempotency(resp_one, resp_two) diff --git a/tests/development/messages/create_messages/test_field_validation.py b/tests/development/messages/create_messages/test_field_validation.py index b011174c1..36c32d543 100644 --- a/tests/development/messages/create_messages/test_field_validation.py +++ b/tests/development/messages/create_messages/test_field_validation.py @@ -2,7 +2,7 @@ import pytest import uuid from lib import Assertions, Permutations, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR import lib.constants.constants as constants from lib.constants.messages_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ INVALID_PROPERTIES_PATHS, MESSAGES_ENDPOINT diff --git a/tests/development/messages/create_messages/test_invalid_routing_plan.py b/tests/development/messages/create_messages/test_invalid_routing_plan.py index 03fec1871..488694cce 100644 --- a/tests/development/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/development/messages/create_messages/test_invalid_routing_plan.py @@ -2,7 +2,7 @@ import pytest import uuid from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.messages_paths import MESSAGES_ENDPOINT from lib.constants.constants import INVALID_ROUTING_PLAN from lib.constants.constants import DUPLICATE_ROUTING_PLAN_TEMPLATE_ID diff --git a/tests/development/messages/create_messages/test_success.py b/tests/development/messages/create_messages/test_success.py index ffb65bb3d..131f13ee7 100644 --- a/tests/development/messages/create_messages/test_success.py +++ b/tests/development/messages/create_messages/test_success.py @@ -2,7 +2,7 @@ import pytest import time from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.messages_paths import MESSAGES_ENDPOINT import lib.constants.constants as constants @@ -103,7 +103,7 @@ def test_201_message_request_idempotency(nhsd_apim_proxy_url, bearer_token_inter """ data = Generators.generate_valid_create_message_body("dev") - respOne = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ + resp_one = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE @@ -112,11 +112,11 @@ def test_201_message_request_idempotency(nhsd_apim_proxy_url, bearer_token_inter time.sleep(5) - respTwo = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ + resp_two = requests.post(f"{nhsd_apim_proxy_url}{MESSAGES_ENDPOINT}", headers={ "Authorization": bearer_token_internal_dev.value, "Accept": constants.DEFAULT_CONTENT_TYPE, "Content-Type": constants.DEFAULT_CONTENT_TYPE }, json=data ) - Assertions.assert_messages_idempotency(respOne, respTwo) + Assertions.assert_messages_idempotency(resp_one, resp_two) diff --git a/tests/development/messages/get_message/test_404.py b/tests/development/messages/get_message/test_404.py index 81535291e..6ef035cca 100644 --- a/tests/development/messages/get_message/test_404.py +++ b/tests/development/messages/get_message/test_404.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from lib.constants.messages_paths import MESSAGES_ENDPOINT diff --git a/tests/development/messages/get_message/test_success.py b/tests/development/messages/get_message/test_success.py index c5c621c12..a3d124c03 100644 --- a/tests/development/messages/get_message/test_success.py +++ b/tests/development/messages/get_message/test_success.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions -from lib.fixtures import * +from lib.fixtures import * # NOSONAR import lib.constants.constants as constants from lib.constants.messages_paths import MESSAGES_ENDPOINT, MESSAGE_IDS, CHANNEL_TYPE, CHANNEL_STATUS diff --git a/tests/development/nhsapp_accounts/test_400.py b/tests/development/nhsapp_accounts/test_400.py index 70447b9e6..e33232cd1 100644 --- a/tests/development/nhsapp_accounts/test_400.py +++ b/tests/development/nhsapp_accounts/test_400.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ VALID_MULTI_PAGE_NUMBERS, INVALID_ODS_CODES, CORRELATION_IDS, LIVE_ODS_CODES, INVALID_PAGES -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.devtest diff --git a/tests/development/nhsapp_accounts/test_404.py b/tests/development/nhsapp_accounts/test_404.py index b6b9d8f1e..83dd68001 100644 --- a/tests/development/nhsapp_accounts/test_404.py +++ b/tests/development/nhsapp_accounts/test_404.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR REPORT_NOT_FOUND_PAGE_NUMBERS = [1000, 2000, 3000] NOT_FOUND_ODS_CODE = 'T00404' diff --git a/tests/development/nhsapp_accounts/test_429.py b/tests/development/nhsapp_accounts/test_429.py index 34d101e41..c5f902040 100644 --- a/tests/development/nhsapp_accounts/test_429.py +++ b/tests/development/nhsapp_accounts/test_429.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ SINGLE_PAGE_ODS_CODES, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR TOO_MANY_REQUESTS_ODS_CODE = 'T00429' diff --git a/tests/development/nhsapp_accounts/test_502.py b/tests/development/nhsapp_accounts/test_502.py index cf04ae953..ebe01fafd 100644 --- a/tests/development/nhsapp_accounts/test_502.py +++ b/tests/development/nhsapp_accounts/test_502.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ SINGLE_PAGE_ODS_CODES, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR BAD_GATEWAY_ODS_CODE = 'T00401' # The mock for the NHS App API will return a 401 should cause the BE to return a 502 diff --git a/tests/development/nhsapp_accounts/test_success.py b/tests/development/nhsapp_accounts/test_success.py index ca0e3711c..62a868b27 100644 --- a/tests/development/nhsapp_accounts/test_success.py +++ b/tests/development/nhsapp_accounts/test_success.py @@ -4,7 +4,7 @@ from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS, VALID_MULTI_PAGE_NUMBERS, \ MULTI_LAST_PAGE, VALID_SINGLE_PAGE_NUMBERS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.devtest diff --git a/tests/development/test_404_errors.py b/tests/development/test_404_errors.py index 6b2ee9de9..9bed2f3a5 100644 --- a/tests/development/test_404_errors.py +++ b/tests/development/test_404_errors.py @@ -1,7 +1,7 @@ import requests import pytest from lib import Assertions, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR ENDPOINT = "/v1/ignore/i-dont-exist" CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] diff --git a/tests/end_to_end/test_email.py b/tests/end_to_end/test_email.py index 0ffdbfa29..3c29dde15 100644 --- a/tests/end_to_end/test_email.py +++ b/tests/end_to_end/test_email.py @@ -1,7 +1,7 @@ import pytest import os from lib import Assertions, Helper, Generators -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from notifications_python_client.notifications import NotificationsAPIClient diff --git a/tests/end_to_end/test_letter.py b/tests/end_to_end/test_letter.py index 9ce2a15ab..909ec3f97 100644 --- a/tests/end_to_end/test_letter.py +++ b/tests/end_to_end/test_letter.py @@ -1,7 +1,7 @@ import pytest import os from lib import Assertions, Generators, Helper -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from notifications_python_client.notifications import NotificationsAPIClient diff --git a/tests/end_to_end/test_nhsapp.py b/tests/end_to_end/test_nhsapp.py index 23d14a5c7..6a4a89bcf 100644 --- a/tests/end_to_end/test_nhsapp.py +++ b/tests/end_to_end/test_nhsapp.py @@ -1,7 +1,7 @@ import pytest import uuid from lib import Assertions, Generators, Helper -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.e2e diff --git a/tests/end_to_end/test_sms.py b/tests/end_to_end/test_sms.py index b555f419d..44eb71c7f 100644 --- a/tests/end_to_end/test_sms.py +++ b/tests/end_to_end/test_sms.py @@ -1,7 +1,7 @@ import pytest import os from lib import Assertions, Generators, Helper -from lib.fixtures import * +from lib.fixtures import * # NOSONAR from notifications_python_client.notifications import NotificationsAPIClient diff --git a/tests/integration/content_types/test_406_errors.py b/tests/integration/content_types/test_406_errors.py index f806800e7..165b31a84 100644 --- a/tests/integration/content_types/test_406_errors.py +++ b/tests/integration/content_types/test_406_errors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS, METHODS, INT_URL, DEFAULT_CONTENT_TYPE, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR HEADER_NAME = ["accept", "AcCePt"] HEADER_VALUE = ["", "xyz/abc", "application/json; charset=utf-9"] diff --git a/tests/integration/content_types/test_415_errors.py b/tests/integration/content_types/test_415_errors.py index 9989bfc52..7a7d50bc4 100644 --- a/tests/integration/content_types/test_415_errors.py +++ b/tests/integration/content_types/test_415_errors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import INT_URL, CORRELATION_IDS, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR CONTENT_TYPE_NAME = ["content-type", "conTENT_tYpe"] CONTENT_TYPE_VALUE = ["", "audio/mpeg", "application/json; charset=utf-9"] diff --git a/tests/integration/content_types/test_content_type_negotiation.py b/tests/integration/content_types/test_content_type_negotiation.py index 1e283ab13..b7b558e0a 100644 --- a/tests/integration/content_types/test_content_type_negotiation.py +++ b/tests/integration/content_types/test_content_type_negotiation.py @@ -1,8 +1,8 @@ import requests import pytest -from lib import Error_Handler +from lib import error_handler from lib.constants.constants import INT_URL, METHODS, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR DEFAULT_CONTENT_TYPE = "application/vnd.api+json" ACCEPT_HEADERS = [ @@ -40,6 +40,6 @@ def test_application_response_type(bearer_token_int, accept_headers, method, end **accept_headers.get("headers") }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.headers.get("Content-Type") == accept_headers.get("expect") diff --git a/tests/integration/headers/test_cors.py b/tests/integration/headers/test_cors.py index 98a25f23e..80c56fca3 100644 --- a/tests/integration/headers/test_cors.py +++ b/tests/integration/headers/test_cors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions from lib.constants.constants import INT_URL, VALID_ENDPOINTS, ORIGIN -from lib.fixtures import * +from lib.fixtures import * # NOSONAR METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] TEST_METHODS = ["get", "post", "put", "delete"] diff --git a/tests/integration/headers/test_x_amz_removal.py b/tests/integration/headers/test_x_amz_removal.py index a45b8b4c2..453af80fd 100644 --- a/tests/integration/headers/test_x_amz_removal.py +++ b/tests/integration/headers/test_x_amz_removal.py @@ -3,7 +3,7 @@ from lib import Assertions from lib.constants.constants import VALID_ENDPOINTS, ORIGIN, METHODS, INT_URL -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest diff --git a/tests/integration/headers/test_x_correlation_id.py b/tests/integration/headers/test_x_correlation_id.py index 5985ec92d..8871bf76d 100644 --- a/tests/integration/headers/test_x_correlation_id.py +++ b/tests/integration/headers/test_x_correlation_id.py @@ -1,8 +1,8 @@ import requests import pytest -from lib import Assertions, Error_Handler +from lib import Assertions, error_handler from lib.constants.constants import INT_URL, METHODS, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR CORRELATION_IDS = [None, "a17669c8-219a-11ee-ba86-322b0407c489"] @@ -20,6 +20,6 @@ def test_request_with_x_correlation_id(bearer_token_int, correlation_id, method, "x-correlation-id": correlation_id }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) Assertions.assert_correlation_id(resp.headers.get("X-Correlation-Id"), correlation_id) diff --git a/tests/integration/message_batches/create_message_batches/test_field_validation.py b/tests/integration/message_batches/create_message_batches/test_field_validation.py index b002c75f6..950469c4e 100644 --- a/tests/integration/message_batches/create_message_batches/test_field_validation.py +++ b/tests/integration/message_batches/create_message_batches/test_field_validation.py @@ -6,7 +6,7 @@ from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCH_REFERENCE_PATH, \ FIRST_MESSAGE_RECIPIENT_NHSNUMBER_PATH, FIRST_MESSAGE_REFERENCE_PATH, MESSAGE_BATCHES_ENDPOINT, ROUTING_PLAN_ID_PATH -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { "Accept": "application/json", "Content-Type": "application/json" diff --git a/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py index b6d2b4f4e..c852d1a79 100644 --- a/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py +++ b/tests/integration/message_batches/create_message_batches/test_invalid_routing_plan.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators import lib.constants.constants as constants from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR CORRELATION_IDS = [None, "228aac39-542d-4803-b28e-5de9e100b9f8"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] diff --git a/tests/integration/message_batches/create_message_batches/test_performance.py b/tests/integration/message_batches/create_message_batches/test_performance.py index 9b79c43be..7549290f8 100644 --- a/tests/integration/message_batches/create_message_batches/test_performance.py +++ b/tests/integration/message_batches/create_message_batches/test_performance.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators from lib.constants.constants import NUM_MAX_ERRORS, INT_URL from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR NUM_MESSAGES = 50000 CONTENT_TYPE = "application/json" diff --git a/tests/integration/message_batches/create_message_batches/test_success.py b/tests/integration/message_batches/create_message_batches/test_success.py index 3357978a4..94f992742 100644 --- a/tests/integration/message_batches/create_message_batches/test_success.py +++ b/tests/integration/message_batches/create_message_batches/test_success.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators import lib.constants.constants as constants from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest @@ -134,7 +134,7 @@ def test_201_message_batches_request_idempotency(bearer_token_int): """ data = Generators.generate_valid_create_message_batch_body("int") - respOne = requests.post( + resp_one = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": bearer_token_int.value, @@ -146,7 +146,7 @@ def test_201_message_batches_request_idempotency(bearer_token_int): time.sleep(5) - respTwo = requests.post( + resp_two = requests.post( f"{constants.INT_URL}{MESSAGE_BATCHES_ENDPOINT}", headers={ "Authorization": bearer_token_int.value, @@ -156,4 +156,4 @@ def test_201_message_batches_request_idempotency(bearer_token_int): json=data, ) - Assertions.assert_message_batches_idempotency(respOne, respTwo) + Assertions.assert_message_batches_idempotency(resp_one, resp_two) diff --git a/tests/integration/messages/create_messages/test_field_validation.py b/tests/integration/messages/create_messages/test_field_validation.py index 79cbbed39..927d08c92 100644 --- a/tests/integration/messages/create_messages/test_field_validation.py +++ b/tests/integration/messages/create_messages/test_field_validation.py @@ -6,7 +6,7 @@ INVALID_PERSONALISATION_VALUES, NULL_VALUES, CORRELATION_IDS from lib.constants.messages_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ INVALID_PROPERTIES_PATHS, MESSAGES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { diff --git a/tests/integration/messages/create_messages/test_invalid_routing_plan.py b/tests/integration/messages/create_messages/test_invalid_routing_plan.py index 8b644fb55..d613c1f0a 100644 --- a/tests/integration/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/integration/messages/create_messages/test_invalid_routing_plan.py @@ -8,7 +8,7 @@ from lib.constants.constants import INVALID_ROUTING_PLAN from lib.constants.constants import CORRELATION_IDS from lib.constants.constants import INT_URL -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { "Accept": "application/json", diff --git a/tests/integration/messages/create_messages/test_success.py b/tests/integration/messages/create_messages/test_success.py index a68ab7a54..7864f30e1 100644 --- a/tests/integration/messages/create_messages/test_success.py +++ b/tests/integration/messages/create_messages/test_success.py @@ -5,7 +5,7 @@ from lib.constants.constants import INT_URL, VALID_CONTENT_TYPE_HEADERS, VALID_ACCEPT_HEADERS, \ VALID_NHS_NUMBER, VALID_DOB, VALID_ROUTING_PLAN_ID_INT from lib.constants.messages_paths import MESSAGES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest @@ -102,7 +102,7 @@ def test_201_message_request_idempotency(bearer_token_int): """ data = Generators.generate_valid_create_message_body("int") - respOne = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ + resp_one = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" @@ -111,11 +111,11 @@ def test_201_message_request_idempotency(bearer_token_int): time.sleep(5) - respTwo = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ + resp_two = requests.post(f"{INT_URL}{MESSAGES_ENDPOINT}", headers={ "Authorization": bearer_token_int.value, "Accept": "application/json", "Content-Type": "application/json" }, json=data ) - Assertions.assert_messages_idempotency(respOne, respTwo) + Assertions.assert_messages_idempotency(resp_one, resp_two) diff --git a/tests/integration/messages/get_message/test_404.py b/tests/integration/messages/get_message/test_404.py index 9ee05df82..43275ac5e 100644 --- a/tests/integration/messages/get_message/test_404.py +++ b/tests/integration/messages/get_message/test_404.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators from lib.constants.constants import INT_URL from lib.constants.messages_paths import MESSAGES_ENDPOINT, MESSAGE_ID_NOT_BELONGING_TO_CLIENT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest diff --git a/tests/integration/messages/get_message/test_success.py b/tests/integration/messages/get_message/test_success.py index 31a3d5ade..425b1cb5b 100644 --- a/tests/integration/messages/get_message/test_success.py +++ b/tests/integration/messages/get_message/test_success.py @@ -4,7 +4,7 @@ from lib import Assertions from lib.constants.constants import INT_URL from lib.constants.messages_paths import MESSAGES_ENDPOINT, SUCCESSFUL_MESSAGE_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest diff --git a/tests/integration/nhsapp_accounts/test_400.py b/tests/integration/nhsapp_accounts/test_400.py index 7ba5ae0d0..90c8ef470 100644 --- a/tests/integration/nhsapp_accounts/test_400.py +++ b/tests/integration/nhsapp_accounts/test_400.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ VALID_MULTI_PAGE_NUMBERS, INVALID_ODS_CODES, CORRELATION_IDS, INVALID_PAGES, LIVE_ODS_CODES -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest diff --git a/tests/integration/nhsapp_accounts/test_404.py b/tests/integration/nhsapp_accounts/test_404.py index 98a1855e2..a27a663f0 100644 --- a/tests/integration/nhsapp_accounts/test_404.py +++ b/tests/integration/nhsapp_accounts/test_404.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR REPORT_NOT_FOUND_PAGE_NUMBERS = [1000, 2000, 3000] diff --git a/tests/integration/nhsapp_accounts/test_success.py b/tests/integration/nhsapp_accounts/test_success.py index 511185b54..2d9a9c434 100644 --- a/tests/integration/nhsapp_accounts/test_success.py +++ b/tests/integration/nhsapp_accounts/test_success.py @@ -4,7 +4,7 @@ from lib.constants.constants import INT_URL from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS, VALID_SINGLE_PAGE_NUMBERS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.inttest diff --git a/tests/integration/test_404_errors.py b/tests/integration/test_404_errors.py index f9339e9aa..e750aaced 100644 --- a/tests/integration/test_404_errors.py +++ b/tests/integration/test_404_errors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import INT_URL, METHODS, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR ENDPOINT = "/v1/ignore/i-dont-exist" diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index be6e796a2..cbc87da1b 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -2,5 +2,5 @@ from .permutations import Permutations from .generators import Generators from .authentication import AuthenticationCache -from .error_handler import Error_Handler +from .error_handler import error_handler from .helper import Helper diff --git a/tests/lib/assertions.py b/tests/lib/assertions.py index 01d58d8f1..5064dabd7 100644 --- a/tests/lib/assertions.py +++ b/tests/lib/assertions.py @@ -1,5 +1,5 @@ from .constants.constants import CORS_METHODS, CORS_MAX_AGE, CORS_ALLOW_HEADERS, CORS_EXPOSE_HEADERS, CORS_POLICY -from .error_handler import Error_Handler +from .error_handler import error_handler import json from urllib.parse import urlparse, parse_qs @@ -7,7 +7,7 @@ class Assertions(): @staticmethod def assert_201_response(resp, message_batch_reference, routing_plan_id): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 201, f"Response: {resp.status_code}: {resp.text}" @@ -29,7 +29,7 @@ def assert_201_response(resp, message_batch_reference, routing_plan_id): @staticmethod def assert_200_response_nhsapp_accounts(resp, base_url, ods_code, page): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200, f"Response: {resp.status_code}: {resp.text}" @@ -73,12 +73,12 @@ def assert_200_response_nhsapp_accounts(resp, base_url, ods_code, page): @staticmethod def assert_200_response_message(resp, base_url): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200, f"Response: {resp.status_code}: {resp.text}" response = resp.json().get("data") - messageStatus = response.get("attributes").get("messageStatus") + message_status = response.get("attributes").get("messageStatus") assert response.get("type") == "Message" assert response.get("id") is not None @@ -96,7 +96,7 @@ def assert_200_response_message(resp, base_url): assert response.get("attributes").get("timestamps").get("created") assert response.get("attributes").get("timestamps").get("created") is not None assert response.get("attributes").get("timestamps").get("created") != "" - if messageStatus != "pending_enrichment": + if message_status != "pending_enrichment": assert response.get("attributes").get("metadata") is not None assert response.get("attributes").get("metadata") != "" assert response.get("attributes").get("metadata")[0].get("queriedAt") is not None @@ -106,7 +106,7 @@ def assert_200_response_message(resp, base_url): assert response.get("attributes").get("metadata")[0].get("version") is not None assert response.get("attributes").get("metadata")[0].get("version") != "" assert response.get("attributes").get("metadata")[0].get("labels") != "" - if messageStatus == "sending" or messageStatus == "delivered": + if message_status == "sending" or message_status == "delivered": assert response.get("attributes").get("channels") is not None assert response.get("attributes").get("channels")[0].get("type") is not None assert response.get("attributes").get("channels")[0].get("type") != "" @@ -122,26 +122,26 @@ def assert_200_response_message(resp, base_url): assert response.get("links").get("self").endswith(f"/v1/messages/{response.get('id')}") @staticmethod - def assert_get_message_status(resp, status, failureReason=None): + def assert_get_message_status(resp, status, failure_reason=None): response = resp.json().get("data") assert response.get("attributes").get("messageStatus") == status if status == "failed": - assert response.get("attributes").get("messageStatusDescription") == failureReason + assert response.get("attributes").get("messageStatusDescription") == failure_reason @staticmethod - def assert_get_message_response_channels(resp, channelType, channelStatus): + def assert_get_message_response_channels(resp, channel_type, channel_status): response = resp.json().get("data") channels = response.get("attributes").get("channels") for c in range(len(channels)): - assert response.get("attributes").get("channels")[c].get("type") in channelType + assert response.get("attributes").get("channels")[c].get("type") in channel_type assert response.get("attributes").get("channels")[c].get("retryCount") == 1 - assert response.get("attributes").get("channels")[c].get("channelStatus") in channelStatus + assert response.get("attributes").get("channels")[c].get("channelStatus") in channel_status assert response.get("attributes").get("channels")[c].get("timestamps") is not None assert response.get("attributes").get("channels")[c].get("routingPlan") is not None @staticmethod def assert_201_response_messages(resp, environment): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 201, f"Response: {resp.status_code}: {resp.text}" @@ -163,7 +163,7 @@ def assert_201_response_messages(resp, environment): @staticmethod def assert_200_valid_message_id_response_body(resp, message_id, url): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200, f"Response: {resp.status_code}: {resp.text}" @@ -206,47 +206,47 @@ def assert_letter_gov_uk(response, message_id): break @staticmethod - def assert_message_batches_idempotency(respOne, respTwo): - Error_Handler.handle_retry(respOne) - Error_Handler.handle_retry(respTwo) + def assert_message_batches_idempotency(resp_one, resp_two): + error_handler.handle_retry(resp_one) + error_handler.handle_retry(resp_two) - assert respOne.status_code == 201 - assert respTwo.status_code == 201 + assert resp_one.status_code == 201 + assert resp_two.status_code == 201 - responseOne = respOne.json().get("data") - responseTwo = respTwo.json().get("data") + response_one = resp_one.json().get("data") + response_two = resp_two.json().get("data") - assert responseOne.get("id") == responseTwo.get("id") + assert response_one.get("id") == response_two.get("id") @staticmethod - def assert_messages_idempotency(respOne, respTwo): - Error_Handler.handle_retry(respOne) - Error_Handler.handle_retry(respTwo) - - assert respOne.status_code == 201 - assert respTwo.status_code == 201 - - responseOne = respOne.json().get("data") - responseTwo = respTwo.json().get("data") - - assert responseOne.get("id") == responseTwo.get("id") - assert (responseOne.get("attributes").get("messageStatus") == - responseTwo.get("attributes").get("messageStatus")) - assert (responseOne.get("attributes").get("timestamps").get("created") == - responseTwo.get("attributes").get("timestamps").get("created")) - assert (responseOne.get("attributes").get("routingPlan").get("id") == - responseTwo.get("attributes").get("routingPlan").get("id")) - assert (responseOne.get("attributes").get("routingPlan").get("version") == - responseTwo.get("attributes").get("routingPlan").get("version")) + def assert_messages_idempotency(resp_one, resp_two): + error_handler.handle_retry(resp_one) + error_handler.handle_retry(resp_two) + + assert resp_one.status_code == 201 + assert resp_two.status_code == 201 + + response_one = resp_one.json().get("data") + response_two = resp_two.json().get("data") + + assert response_one.get("id") == response_two.get("id") + assert (response_one.get("attributes").get("messageStatus") == + response_one.get("attributes").get("messageStatus")) + assert (response_one.get("attributes").get("timestamps").get("created") == + response_two.get("attributes").get("timestamps").get("created")) + assert (response_one.get("attributes").get("routingPlan").get("id") == + response_two.get("attributes").get("routingPlan").get("id")) + assert (response_one.get("attributes").get("routingPlan").get("version") == + response_two.get("attributes").get("routingPlan").get("version")) @staticmethod def assert_error_with_optional_correlation_id(resp, code, error, correlation_id): if code == 429: - Error_Handler.handle_504_retry(resp) + error_handler.handle_504_retry(resp) elif code == 504: - Error_Handler.handle_429_retry(resp) + error_handler.handle_429_retry(resp) else: - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == code, f"Response: {resp.status_code}: {resp.text}" @@ -289,7 +289,7 @@ def assert_correlation_id(res_correlation_id, correlation_id): @staticmethod def assert_cors_response(resp, website): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200, f"Response: {resp.status_code}: {resp.text}" assert resp.headers.get("Access-Control-Allow-Origin") == website @@ -300,7 +300,7 @@ def assert_cors_response(resp, website): @staticmethod def assert_cors_headers(resp, website): - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.headers.get("Access-Control-Allow-Origin") == website assert resp.headers.get("Access-Control-Expose-Headers") == CORS_EXPOSE_HEADERS diff --git a/tests/lib/constants/constants.py b/tests/lib/constants/constants.py index ed915f9d1..de0f1d3e8 100644 --- a/tests/lib/constants/constants.py +++ b/tests/lib/constants/constants.py @@ -42,8 +42,8 @@ UNEXPECTED_429 = AssertionError('Unexpected 429') UNEXPECTED_504 = AssertionError('Unexpected 504') -VALID_ACCEPT_HEADERS = ["*/*", DEFAULT_CONTENT_TYPE, "application/vnd.api+json"] -VALID_CONTENT_TYPE_HEADERS = [DEFAULT_CONTENT_TYPE, "application/vnd.api+json"] +VALID_ACCEPT_HEADERS = ["*/*", DEFAULT_CONTENT_TYPE] +VALID_CONTENT_TYPE_HEADERS = [DEFAULT_CONTENT_TYPE] INVALID_MESSAGE_VALUES = ["", [], 5, 0.1] @@ -264,25 +264,27 @@ def __init__(self, code, status, title, detail, links={}): "A downstream service is not responding." ) +INVALID_REQUEST_TITLE = "Invalid Request" + # NHS App Accounts errors ERROR_NHS_APP_ACCOUNTS_MISSING_ODS_CODE = Error( "CM_INVALID_REQUEST", "400", - "Invalid Request", + INVALID_REQUEST_TITLE, "Missing ODS Code" ) ERROR_NHS_APP_ACCOUNTS_INVALID_ODS_CODE = Error( "CM_INVALID_REQUEST", "400", - "Invalid Request", + INVALID_REQUEST_TITLE, "Invalid ODS Code" ) ERROR_NHS_APP_ACCOUNTS_INVALID_PAGE = Error( "CM_INVALID_REQUEST", "400", - "Invalid Request", + INVALID_REQUEST_TITLE, "page must be a positive non-zero integer" ) diff --git a/tests/lib/error_handler.py b/tests/lib/error_handler.py index c3507e94c..c29be0cc1 100644 --- a/tests/lib/error_handler.py +++ b/tests/lib/error_handler.py @@ -1,11 +1,11 @@ import lib.constants.constants as constants -class Error_Handler(): +class error_handler(): @staticmethod def handle_retry(resp): - Error_Handler.handle_429_retry(resp) - Error_Handler.handle_504_retry(resp) + error_handler.handle_429_retry(resp) + error_handler.handle_504_retry(resp) @staticmethod def handle_429_retry(resp): diff --git a/tests/lib/generators.py b/tests/lib/generators.py index cddeb75f9..e2d9b1123 100644 --- a/tests/lib/generators.py +++ b/tests/lib/generators.py @@ -70,14 +70,14 @@ def generate_valid_create_message_body(environment="sandbox"): @staticmethod def generate_send_message_body(channel, environment, personalisation="Hello"): if environment == "internal-dev": - nhsNumber = "9627193232" - dateOfBirth = "1998-03-21" + nhs_number = "9627193232" + date_of_birth = "1998-03-21" if channel == "nhsapp": - nhsNumber = "9842434109" - dateOfBirth = "2002-10-23" + nhs_number = "9842434109" + date_of_birth = "2002-10-23" elif environment == "internal-qa": - nhsNumber = "9730617953" - dateOfBirth = "2009-09-02" + nhs_number = "9730617953" + date_of_birth = "2009-09-02" else: raise ValueError(f"Invalid environment value provided: {environment}") if channel == "nhsapp": @@ -97,8 +97,8 @@ def generate_send_message_body(channel, environment, personalisation="Hello"): "routingPlanId": routing_plan_id, "messageReference": str(uuid.uuid1()), "recipient": { - "nhsNumber": nhsNumber, - "dateOfBirth": dateOfBirth + "nhsNumber": nhs_number, + "dateOfBirth": date_of_birth }, "originator": { "odsCode": "X26" diff --git a/tests/lib/helper.py b/tests/lib/helper.py index 9c37e03b7..6fedbf3ab 100644 --- a/tests/lib/helper.py +++ b/tests/lib/helper.py @@ -4,7 +4,9 @@ from install_playwright import install from playwright.sync_api import expect, sync_playwright from lib.constants.messages_paths import MESSAGES_ENDPOINT -from lib import Error_Handler +from lib import error_handler + +DEFAULT_CONTENT_TYPE = "application/vnd.api+json" class Helper(): @@ -12,11 +14,11 @@ class Helper(): def send_single_message(url, auth, body): resp = requests.post(f"{url}{MESSAGES_ENDPOINT}", headers={ **auth, - "Accept": "application/vnd.api+json", - "Content-Type": "application/vnd.api+json" + "Accept": DEFAULT_CONTENT_TYPE, + "Content-Type": DEFAULT_CONTENT_TYPE }, json=body ) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 201 return resp @@ -24,9 +26,9 @@ def send_single_message(url, auth, body): def get_message(url, auth, message_id): resp = requests.get(f"{url}{MESSAGES_ENDPOINT}/{message_id}", headers={ **auth, - "Accept": "application/vnd.api+json" + "Accept": DEFAULT_CONTENT_TYPE }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200 return resp @@ -40,7 +42,7 @@ def poll_get_message(url, auth, message_id, end_state="delivered", poll_time=300 f"{url}{MESSAGES_ENDPOINT}/{message_id}", headers={ **auth, - "Accept": "application/vnd.api+json" + "Accept": DEFAULT_CONTENT_TYPE }, ) diff --git a/tests/production/content_types/test_406_errors.py b/tests/production/content_types/test_406_errors.py index 5f9c57124..90be97fea 100644 --- a/tests/production/content_types/test_406_errors.py +++ b/tests/production/content_types/test_406_errors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import METHODS, PROD_URL, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/content_types/test_415_errors.py b/tests/production/content_types/test_415_errors.py index 373d2a956..4e72568e2 100644 --- a/tests/production/content_types/test_415_errors.py +++ b/tests/production/content_types/test_415_errors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions, Generators from lib.constants.constants import CORRELATION_IDS, PROD_URL, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR METHODS = ["post", "put", "patch"] diff --git a/tests/production/content_types/test_content_type_negotiation.py b/tests/production/content_types/test_content_type_negotiation.py index bd949882e..e3f78956a 100644 --- a/tests/production/content_types/test_content_type_negotiation.py +++ b/tests/production/content_types/test_content_type_negotiation.py @@ -1,8 +1,8 @@ import requests import pytest -from lib import Error_Handler +from lib import error_handler from lib.constants.constants import METHODS, PROD_URL, VALID_ENDPOINTS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR ACCEPT_HEADERS = [ { @@ -39,6 +39,6 @@ def test_application_response_type(bearer_token_prod, accept_headers, method, en **accept_headers.get("headers") }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.headers.get("Content-Type") == accept_headers.get("expect") diff --git a/tests/production/headers/test_cors.py b/tests/production/headers/test_cors.py index 67a3d0c4a..074126d0e 100644 --- a/tests/production/headers/test_cors.py +++ b/tests/production/headers/test_cors.py @@ -2,7 +2,7 @@ import pytest from lib import Assertions from lib.constants.constants import PROD_URL, VALID_ENDPOINTS, ORIGIN -from lib.fixtures import * +from lib.fixtures import * # NOSONAR METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"] TEST_METHODS = ["get", "post", "put", "delete"] diff --git a/tests/production/headers/test_x_amz_removal.py b/tests/production/headers/test_x_amz_removal.py index 0174bb56b..8b7036a6a 100644 --- a/tests/production/headers/test_x_amz_removal.py +++ b/tests/production/headers/test_x_amz_removal.py @@ -3,7 +3,7 @@ from lib import Assertions from lib.constants.constants import VALID_ENDPOINTS, ORIGIN, METHODS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR # Add prodtest once 4.9.0 is in prod diff --git a/tests/production/headers/test_x_correlation_id.py b/tests/production/headers/test_x_correlation_id.py index 31ed7299a..477158fdf 100644 --- a/tests/production/headers/test_x_correlation_id.py +++ b/tests/production/headers/test_x_correlation_id.py @@ -1,9 +1,9 @@ import requests import pytest -from lib import Assertions, Error_Handler +from lib import Assertions, error_handler from lib.constants.constants import METHODS, PROD_URL from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR CORRELATION_IDS = [None, "a17669c8-219a-11ee-ba86-322b0407c489"] @@ -24,6 +24,6 @@ def test_request_with_x_correlation_id( "x-correlation-id": correlation_id }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) Assertions.assert_correlation_id(resp.headers.get("X-Correlation-Id"), correlation_id) diff --git a/tests/production/message_batches/create_message_batches/test_field_validation.py b/tests/production/message_batches/create_message_batches/test_field_validation.py index 72f8bc467..57f03e2a4 100644 --- a/tests/production/message_batches/create_message_batches/test_field_validation.py +++ b/tests/production/message_batches/create_message_batches/test_field_validation.py @@ -5,7 +5,7 @@ import lib.constants.constants as constants from lib.constants.message_batches_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ INVALID_PROPERTIES_PATHS, DUPLICATE_PROPERTIES_PATHS, TOO_FEW_PROPERTIES_PATHS, MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { "Accept": "application/json", diff --git a/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py index d2b82dd27..3844a51d4 100644 --- a/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py +++ b/tests/production/message_batches/create_message_batches/test_invalid_routing_config.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators from lib.constants.constants import PROD_URL, INVALID_ROUTING_PLAN_PROD from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/message_batches/create_message_batches/test_performance.py b/tests/production/message_batches/create_message_batches/test_performance.py index bea1c1064..f2f8bc43e 100644 --- a/tests/production/message_batches/create_message_batches/test_performance.py +++ b/tests/production/message_batches/create_message_batches/test_performance.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators from lib.constants.constants import PROD_URL, NUM_MAX_ERRORS from lib.constants.message_batches_paths import MESSAGE_BATCHES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR NUM_MESSAGES = 50000 @@ -18,7 +18,7 @@ def test_create_messages_large_invalid_payload(bearer_token_prod): # around 50k messages gives us close to our max body size data["data"]["attributes"]["messages"] = [] - for i in range(0, NUM_MESSAGES): + for _ in range(0, NUM_MESSAGES): data["data"]["attributes"]["messages"].append({ "messageReference": str(uuid.uuid1()), "recipient": { @@ -47,7 +47,7 @@ def test_create_messages_large_not_unique_payload(bearer_token_prod): # around 50k messages gives us close to our max body size data["data"]["attributes"]["messages"] = [] reference = str(uuid.uuid1()) - for i in range(0, NUM_MESSAGES): + for _ in range(0, NUM_MESSAGES): data["data"]["attributes"]["messages"].append({ "messageReference": reference, "recipient": { diff --git a/tests/production/messages/create_messages/test_field_validation.py b/tests/production/messages/create_messages/test_field_validation.py index 972bdcef1..a45169db0 100644 --- a/tests/production/messages/create_messages/test_field_validation.py +++ b/tests/production/messages/create_messages/test_field_validation.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.messages_paths import MISSING_PROPERTIES_PATHS, NULL_PROPERTIES_PATHS, \ INVALID_PROPERTIES_PATHS, MESSAGES_ENDPOINT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { "Accept": "application/json", diff --git a/tests/production/messages/create_messages/test_invalid_routing_plan.py b/tests/production/messages/create_messages/test_invalid_routing_plan.py index 5e88c9005..5fc6f1d01 100644 --- a/tests/production/messages/create_messages/test_invalid_routing_plan.py +++ b/tests/production/messages/create_messages/test_invalid_routing_plan.py @@ -5,7 +5,7 @@ import lib.constants.constants as constants from lib.constants.messages_paths import MESSAGES_ENDPOINT from lib.constants.constants import INVALID_ROUTING_PLAN_PROD -from lib.fixtures import * +from lib.fixtures import * # NOSONAR headers = { diff --git a/tests/production/messages/get_message/test_404.py b/tests/production/messages/get_message/test_404.py index 596e9ee2a..3abb22038 100644 --- a/tests/production/messages/get_message/test_404.py +++ b/tests/production/messages/get_message/test_404.py @@ -4,7 +4,7 @@ from lib import Assertions, Generators from lib.constants.constants import PROD_URL from lib.constants.messages_paths import MESSAGES_ENDPOINT, MESSAGE_ID_NOT_BELONGING_TO_CLIENT -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/messages/get_message/test_success.py b/tests/production/messages/get_message/test_success.py index d77201505..2bed8864e 100644 --- a/tests/production/messages/get_message/test_success.py +++ b/tests/production/messages/get_message/test_success.py @@ -4,7 +4,7 @@ from lib import Assertions from lib.constants.constants import PROD_URL from lib.constants.messages_paths import MESSAGES_ENDPOINT, SUCCESSFUL_MESSAGE_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/nhsapp_accounts/test_400.py b/tests/production/nhsapp_accounts/test_400.py index aa0f04e13..622ce6bca 100644 --- a/tests/production/nhsapp_accounts/test_400.py +++ b/tests/production/nhsapp_accounts/test_400.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ VALID_MULTI_PAGE_NUMBERS, INVALID_ODS_CODES, CORRELATION_IDS, INVALID_PAGES, LIVE_ODS_CODES -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/nhsapp_accounts/test_404.py b/tests/production/nhsapp_accounts/test_404.py index 2e68ae521..5cb838be5 100644 --- a/tests/production/nhsapp_accounts/test_404.py +++ b/tests/production/nhsapp_accounts/test_404.py @@ -4,7 +4,7 @@ import lib.constants.constants as constants from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR REPORT_NOT_FOUND_PAGE_NUMBERS = [1000, 2000, 3000] diff --git a/tests/production/nhsapp_accounts/test_success.py b/tests/production/nhsapp_accounts/test_success.py index 34fc283e2..e55e7c1bc 100644 --- a/tests/production/nhsapp_accounts/test_success.py +++ b/tests/production/nhsapp_accounts/test_success.py @@ -5,7 +5,7 @@ from lib.constants.nhsapp_accounts_paths import NHSAPP_ACCOUNTS_ENDPOINT, ODS_CODE_PARAM_NAME, PAGE_PARAM_NAME, \ LIVE_ODS_CODES, CORRELATION_IDS, VALID_MULTI_PAGE_NUMBERS, \ MULTI_LAST_PAGE, VALID_SINGLE_PAGE_NUMBERS -from lib.fixtures import * +from lib.fixtures import * # NOSONAR @pytest.mark.prodtest diff --git a/tests/production/test_404_errors.py b/tests/production/test_404_errors.py index 645621f27..26ea7d0c8 100644 --- a/tests/production/test_404_errors.py +++ b/tests/production/test_404_errors.py @@ -1,8 +1,8 @@ import requests import pytest from lib import Assertions, Generators -from lib.constants.constants import * -from lib.fixtures import * +from lib.constants.constants import * # NOSONAR +from lib.fixtures import * # NOSONAR POST_PATHS = ["/v1/ignore/i-dont-exist"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] diff --git a/tests/sandbox/content_types/test_content_negotiation.py b/tests/sandbox/content_types/test_content_negotiation.py index 11097749d..a6011b448 100644 --- a/tests/sandbox/content_types/test_content_negotiation.py +++ b/tests/sandbox/content_types/test_content_negotiation.py @@ -1,7 +1,7 @@ import requests import pytest from lib.constants.constants import METHODS, VALID_ENDPOINTS -from lib import Error_Handler +from lib import error_handler ACCEPT_HEADERS = [ { @@ -36,6 +36,6 @@ def test_application_response_type(nhsd_apim_proxy_url, accept_headers, method, resp = getattr(requests, method)(f"{nhsd_apim_proxy_url}{endpoints}", headers=accept_headers.get("headers")) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.headers.get("Content-Type") == accept_headers.get("expect") diff --git a/tests/sandbox/headers/test_x_correlation_id.py b/tests/sandbox/headers/test_x_correlation_id.py index 31a1598ef..42a685eb9 100644 --- a/tests/sandbox/headers/test_x_correlation_id.py +++ b/tests/sandbox/headers/test_x_correlation_id.py @@ -1,7 +1,7 @@ import requests import pytest from lib.constants.constants import CORRELATION_IDS, METHODS, VALID_ENDPOINTS -from lib import Error_Handler, Assertions +from lib import error_handler, Assertions @pytest.mark.sandboxtest @@ -21,6 +21,6 @@ def test_request_with_x_correlation_id( "x-correlation-id": correlation_id }) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) Assertions.assert_correlation_id(resp.headers.get("X-Correlation-Id"), correlation_id) diff --git a/tests/sandbox/message_batches/create_message_batches/test_performance.py b/tests/sandbox/message_batches/create_message_batches/test_performance.py index 9a3d08941..fa6180fd6 100644 --- a/tests/sandbox/message_batches/create_message_batches/test_performance.py +++ b/tests/sandbox/message_batches/create_message_batches/test_performance.py @@ -17,7 +17,7 @@ def test_create_messages_large_valid_payload(nhsd_apim_proxy_url): # around 50k messages gives us close to our max body size data["data"]["attributes"]["messages"] = [] - for i in range(0, NUM_MESSAGES): + for _ in range(0, NUM_MESSAGES): data["data"]["attributes"]["messages"].append( { "messageReference": str(uuid.uuid1()), @@ -47,7 +47,7 @@ def test_create_messages_large_invalid_payload(nhsd_apim_proxy_url): # around 50k messages gives us close to our max body size data["data"]["attributes"]["messages"] = [] - for i in range(0, NUM_MESSAGES): + for _ in range(0, NUM_MESSAGES): data["data"]["attributes"]["messages"].append( { "messageReference": str(uuid.uuid1()), @@ -77,7 +77,7 @@ def test_create_messages_large_not_unique_payload(nhsd_apim_proxy_url): # around 50k messages gives us close to our max body size data["data"]["attributes"]["messages"] = [] reference = str(uuid.uuid1()) - for i in range(0, NUM_MESSAGES): + for _ in range(0, NUM_MESSAGES): data["data"]["attributes"]["messages"].append( { "messageReference": reference, diff --git a/tests/sandbox/test_429_errors.py b/tests/sandbox/test_429_errors.py index 4982e4173..b7b744080 100644 --- a/tests/sandbox/test_429_errors.py +++ b/tests/sandbox/test_429_errors.py @@ -1,6 +1,6 @@ import requests import pytest -from lib import Assertions, Generators, Error_Handler +from lib import Assertions, Generators, error_handler CORRELATION_IDS = [None, "0f160ae2-9b62-47bf-bdf0-c6a844d59488"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @@ -20,7 +20,7 @@ def test_too_many_requests_get(nhsd_apim_proxy_url, correlation_id, method): "X-Correlation-Id": correlation_id }) - Error_Handler.handle_504_retry(resp) + error_handler.handle_504_retry(resp) Assertions.assert_error_with_optional_correlation_id( resp, diff --git a/tests/sandbox/test_500_errors.py b/tests/sandbox/test_500_errors.py index 558fcac05..0a03deff7 100644 --- a/tests/sandbox/test_500_errors.py +++ b/tests/sandbox/test_500_errors.py @@ -1,6 +1,6 @@ import requests import pytest -from lib import Assertions, Generators, Error_Handler +from lib import Assertions, Generators, error_handler CORRELATION_IDS = [None, "19645ac5-b81b-4f05-9630-5c687ad05f71"] METHODS = ["get", "post", "put", "patch", "delete", "head", "options"] @@ -20,7 +20,7 @@ def test_internal_server_error_get(nhsd_apim_proxy_url, correlation_id, method): "X-Correlation-Id": correlation_id }) - Error_Handler.handle_504_retry(resp) + error_handler.handle_504_retry(resp) Assertions.assert_error_with_optional_correlation_id( resp, diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index a06fd5f4c..a4e1071a7 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -7,7 +7,7 @@ import pytest import time from os import getenv -from lib import Error_Handler +from lib import error_handler def determine_expected_commit_id(deployed_commit_id): @@ -42,7 +42,7 @@ def test_wait_for_ping(nhsd_apim_proxy_url): time.sleep(5) retries += 1 - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) if resp.status_code != 200: pytest.fail(f"Status code {resp.status_code}, expecting 200") @@ -60,7 +60,7 @@ def test_status(nhsd_apim_proxy_url, status_endpoint_auth_headers): f"{nhsd_apim_proxy_url}/_status", headers=status_endpoint_auth_headers ) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 200 @@ -73,7 +73,7 @@ def test_401_status_without_apikey(nhsd_apim_proxy_url): f"{nhsd_apim_proxy_url}/_status" ) - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) assert resp.status_code == 401 @@ -95,7 +95,7 @@ def test_wait_for_status(nhsd_apim_proxy_url, status_endpoint_auth_headers): time.sleep(5) retries += 1 - Error_Handler.handle_retry(resp) + error_handler.handle_retry(resp) if resp.status_code != 200: pytest.fail(f"Status code {resp.status_code}, expecting 200") diff --git a/zap/Dockerfile b/zap/Dockerfile index 87c070b67..78d97075e 100644 --- a/zap/Dockerfile +++ b/zap/Dockerfile @@ -1,3 +1,3 @@ -FROM softwaresecurityproject/zap-stable +FROM softwaresecurityproject/zap-stable:2.15.0 COPY ./zap/policies/ /home/zap/.ZAP/policies/ From da806913abbc0a2d8f7c73ac5006129122a2f8b1 Mon Sep 17 00:00:00 2001 From: Ian Hodges Date: Mon, 15 Jul 2024 14:22:01 +0100 Subject: [PATCH 6/9] CCM-4908 Change merge strategy (#664) --- CONTRIBUTING.md | 23 ++- package-lock.json | 431 ---------------------------------------------- 2 files changed, 18 insertions(+), 436 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a6dab728..d3dd4e9b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,17 +16,30 @@ so please explain why the changes need to be made (unless it is self-evident). * It is the responsibility of the author of the merge to ensure their merge is in a mergeable state. * It is the responsibility of the maintainers to ensure the merge process is unambiguous and automated where possible. -### Branch naming -Branch names should be of the format: +### Branches -`apm-nnn-short-issue-description` +All changes are created on a short lived branch specifically for that change. Once ready, the branch must be merged into the `release` branch via a Pull Request. -Multiple branches are permitted for the same ticket. +Branch names must follow the format below: + +``` +feature/${jira-ticket-number}_${precis-of-branch-purpose} +``` + +e.g. + +``` +feature/CCM-1234_cicd-documentation +``` + +Other branch prefixes that can be used are `chore`, and `fix`. + +The only merge strategy via Github is `Squash and merge`. If the merging is performed locally, every effort should be made to ensure only one commit is merged into the `release` branch. This is to keep a clean, concise history. ### Commit messages Commit messages should be formatted as follows: ``` -APM-NNN Summary of changes +CCM-1234: Summary of changes Longer description of changes if explaining rationale is necessary, limited to 80 columns and spanning as many lines as you need. diff --git a/package-lock.json b/package-lock.json index a0f7edf34..3c74d39ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -413,44 +413,6 @@ "node": ">=0.10.0" } }, - "node_modules/array.prototype.filter": { - "version": "1.0.4", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-array-method-boxes-properly": "^1.0.0", - "es-object-atoms": "^1.0.0", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.flat": { - "version": "1.3.2", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "es-abstract": "^1.22.1", - "es-shim-unscopables": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/arraybuffer.prototype.slice": { "version": "1.0.3", "dev": true, @@ -593,12 +555,6 @@ "dev": true, "license": "MIT" }, - "node_modules/boolbase": { - "version": "1.0.0", - "dev": true, - "license": "ISC", - "peer": true - }, "node_modules/brace-expansion": { "version": "2.0.1", "dev": true, @@ -688,44 +644,6 @@ "node": ">=4.0.0" } }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/chokidar": { "version": "3.6.0", "dev": true, @@ -871,22 +789,6 @@ "node": ">=4" } }, - "node_modules/css-select": { - "version": "5.1.0", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/css-to-react-native": { "version": "3.2.0", "dev": true, @@ -897,18 +799,6 @@ "postcss-value-parser": "^4.0.2" } }, - "node_modules/css-what": { - "version": "6.1.0", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/csstype": { "version": "3.1.3", "dev": true, @@ -1064,72 +954,11 @@ "node": ">=0.3.1" } }, - "node_modules/discontinuous-range": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "BSD-2-Clause", - "peer": true - }, - "node_modules/domhandler": { - "version": "5.0.3", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, "node_modules/dompurify": { "version": "3.1.5", "dev": true, "license": "(MPL-2.0 OR Apache-2.0)" }, - "node_modules/domutils": { - "version": "3.1.0", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, "node_modules/ecc-jsbn": { "version": "0.1.2", "dev": true, @@ -1144,51 +973,6 @@ "dev": true, "license": "MIT" }, - "node_modules/entities": { - "version": "4.5.0", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/enzyme": { - "version": "3.11.0", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "array.prototype.flat": "^1.2.3", - "cheerio": "^1.0.0-rc.3", - "enzyme-shallow-equal": "^1.0.1", - "function.prototype.name": "^1.1.2", - "has": "^1.0.3", - "html-element-map": "^1.2.0", - "is-boolean-object": "^1.0.1", - "is-callable": "^1.1.5", - "is-number-object": "^1.0.4", - "is-regex": "^1.0.5", - "is-string": "^1.0.5", - "is-subset": "^0.1.1", - "lodash.escape": "^4.0.1", - "lodash.isequal": "^4.5.0", - "object-inspect": "^1.7.0", - "object-is": "^1.0.2", - "object.assign": "^4.1.0", - "object.entries": "^1.1.1", - "object.values": "^1.1.1", - "raf": "^3.4.1", - "rst-selector-parser": "^2.2.3", - "string.prototype.trim": "^1.2.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/enzyme-shallow-equal": { "version": "1.0.7", "dev": true, @@ -1260,12 +1044,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es-array-method-boxes-properly": { - "version": "1.0.0", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/es-define-property": { "version": "1.0.0", "dev": true, @@ -1309,15 +1087,6 @@ "node": ">= 0.4" } }, - "node_modules/es-shim-unscopables": { - "version": "1.0.2", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "hasown": "^2.0.0" - } - }, "node_modules/es-to-primitive": { "version": "1.2.1", "dev": true, @@ -1828,38 +1597,6 @@ "dev": true, "license": "ISC" }, - "node_modules/html-element-map": { - "version": "1.3.1", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "array.prototype.filter": "^1.0.0", - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/htmlparser2": { - "version": "8.0.2", - "dev": true, - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "MIT", - "peer": true, - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" - } - }, "node_modules/http-reasons": { "version": "0.1.0", "dev": true, @@ -2195,12 +1932,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-subset": { - "version": "0.1.1", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/is-symbol": { "version": "1.0.4", "dev": true, @@ -2427,18 +2158,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.escape": { - "version": "4.0.1", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "dev": true, - "license": "MIT", - "peer": true - }, "node_modules/lodash.get": { "version": "4.4.2", "dev": true, @@ -2633,12 +2352,6 @@ } } }, - "node_modules/moo": { - "version": "0.5.2", - "dev": true, - "license": "BSD-3-Clause", - "peer": true - }, "node_modules/ms": { "version": "2.0.0", "dev": true, @@ -2661,35 +2374,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/nearley": { - "version": "2.20.1", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "commander": "^2.19.0", - "moo": "^0.5.0", - "railroad-diagrams": "^1.0.0", - "randexp": "0.4.6" - }, - "bin": { - "nearley-railroad": "bin/nearley-railroad.js", - "nearley-test": "bin/nearley-test.js", - "nearley-unparse": "bin/nearley-unparse.js", - "nearleyc": "bin/nearleyc.js" - }, - "funding": { - "type": "individual", - "url": "https://nearley.js.org/#give-to-nearley" - } - }, - "node_modules/nearley/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "peer": true - }, "node_modules/neo-async": { "version": "2.6.2", "dev": true, @@ -2853,18 +2537,6 @@ "dev": true, "license": "ISC" }, - "node_modules/nth-check": { - "version": "2.1.1", - "dev": true, - "license": "BSD-2-Clause", - "peer": true, - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, "node_modules/oas-kit-common": { "version": "1.0.8", "dev": true, @@ -3005,37 +2677,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object.entries": { - "version": "1.1.8", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/object.values": { - "version": "1.2.0", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/once": { "version": "1.4.0", "dev": true, @@ -3086,31 +2727,6 @@ "node": ">=6" } }, - "node_modules/parse5": { - "version": "7.1.2", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "7.0.0", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "domhandler": "^5.0.2", - "parse5": "^7.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/path-browserify": { "version": "1.0.1", "dev": true, @@ -3513,34 +3129,6 @@ ], "license": "MIT" }, - "node_modules/raf": { - "version": "3.4.1", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "performance-now": "^2.1.0" - } - }, - "node_modules/railroad-diagrams": { - "version": "1.0.0", - "dev": true, - "license": "CC0-1.0", - "peer": true - }, - "node_modules/randexp": { - "version": "0.4.6", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "discontinuous-range": "1.0.0", - "ret": "~0.1.10" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/randombytes": { "version": "2.1.0", "dev": true, @@ -3779,25 +3367,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/ret": { - "version": "0.1.15", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=0.12" - } - }, - "node_modules/rst-selector-parser": { - "version": "2.2.3", - "dev": true, - "license": "BSD-3-Clause", - "peer": true, - "dependencies": { - "lodash.flattendeep": "^4.4.0", - "nearley": "^2.7.10" - } - }, "node_modules/safe-array-concat": { "version": "1.1.2", "dev": true, From dce94cac5356ac5d4448512fedddbd218639ce6c Mon Sep 17 00:00:00 2001 From: Tom Webb Date: Wed, 17 Jul 2024 15:30:00 +0100 Subject: [PATCH 7/9] CCM-5828: Added details on how to generate hmac signature (#669) * CCM-5828: added details on how to generate hmac signature * CCM-5828: added code example into code block * Update specification/documentation/APIDescription.md * Update specification/callbacks/channel-subscription-openapi-spec.json * Update specification/documentation/APIDescription.md Co-authored-by: aaron-downing <92087051+aaron-downing@users.noreply.github.com> * Update specification/callbacks/channel-subscription-openapi-spec.json --------- Co-authored-by: aaron-downing <92087051+aaron-downing@users.noreply.github.com> --- .../callbacks/channel-subscription-openapi-spec.json | 4 ++-- specification/documentation/APIDescription.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/specification/callbacks/channel-subscription-openapi-spec.json b/specification/callbacks/channel-subscription-openapi-spec.json index 8478183aa..0b61d6e0d 100644 --- a/specification/callbacks/channel-subscription-openapi-spec.json +++ b/specification/callbacks/channel-subscription-openapi-spec.json @@ -14,7 +14,7 @@ "/nhs-notify-callbacks/v1/channel-status": { "post": { "summary": "Receive a callback", - "description": "You may develop this endpoint on your service if you want to receive callbacks from NHS Notify.\n\nWe have created an OpenAPI specification detailing the behaviour of the endpoint that consumers should create to subscribe to callbacks.\n\nWe will send your API key in the `x-api-key` header. Your service should respond with:\n\n* `401 Unauthorized` if the API key is not received\n* `401 Unauthorized` if the API key is invalid\n\nWe will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from an authorized sender. Details on this will be provided during the onboarding process. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`.\n\nEvery request includes an idempotencyKey located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially.\n\nIf a request fails, our retry policy will make up to three attempts with intervals of five seconds between each attempt.\n\nThe default behaviour of NHS Notify will make a callback to this endpoint when:\n\n* the message has been delivered (via any channel)\n* the message could not be delivered to a given channel (but may be deliverable by an alternative channel)\n* the message could not be delivered by any channel\n\nCallbacks can be received for additional state transitions subject to the needs of the user. These additional state transitions can be requested during onboarding. These statuses are:\n\n* `pending_enrichment` - the message is currently pending enrichment\n* `enriched` - we have queried PDS for this patient's details and now know how to contact this individual\n* `sending` - the message is in the process of being sent", + "description": "You may develop this endpoint on your service if you want to receive callbacks from NHS Notify.\n\nWe have created an OpenAPI specification detailing the behaviour of the endpoint that consumers should create to subscribe to callbacks.\n\nWe will send your API key in the `x-api-key` header. Your service should respond with:\n\n* `401 Unauthorized` if the API key is not received\n* `401 Unauthorized` if the API key is invalid\n\nWe will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from NHS Notify. This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form '.'. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`.\n\nEvery request includes an idempotencyKey located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially.\n\nIf a request fails, our retry policy will make up to three attempts with intervals of five seconds between each attempt.\n\nThe default behaviour of NHS Notify will make a callback to this endpoint when:\n\n* the message has been delivered (via any channel)\n* the message could not be delivered to a given channel (but may be deliverable by an alternative channel)\n* the message could not be delivered by any channel\n\nCallbacks can be received for additional state transitions subject to the needs of the user. These additional state transitions can be requested during onboarding. These statuses are:\n\n* `pending_enrichment` - the message is currently pending enrichment\n* `enriched` - we have queried PDS for this patient's details and now know how to contact this individual\n* `sending` - the message is in the process of being sent", "operationId": "post-v1-channel-callbacks", "parameters": [ { @@ -104,7 +104,7 @@ "type": "any", "enum": [ "nhsapp" - ] + ] }, "channelStatus": { "description": "The current status of this channel at the time this response was generated.", diff --git a/specification/documentation/APIDescription.md b/specification/documentation/APIDescription.md index 06b9d19dc..3450bbd2f 100644 --- a/specification/documentation/APIDescription.md +++ b/specification/documentation/APIDescription.md @@ -161,7 +161,8 @@ We will send your API key in the `x-api-key header`. Your service should respond * `401 Unauthorized` if the API key is not received * `401 Unauthorized` if the API key is invalid -We will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from an authorized sender. Details on this will be provided during the onboarding process. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`. +We will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from NHS Notify. +This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form '.'. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`. Every request includes an `idempotencyKey` field located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially. From 08c82d6315676c0104bec4ba0a0bcd44c086c7a7 Mon Sep 17 00:00:00 2001 From: Tom Webb Date: Thu, 18 Jul 2024 09:20:45 +0100 Subject: [PATCH 8/9] bug/CCM-5828 (#672) * CCM-5828: remove chevrons * CCM-5828: add code block and brackets --- specification/callbacks/channel-subscription-openapi-spec.json | 2 +- specification/documentation/APIDescription.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/specification/callbacks/channel-subscription-openapi-spec.json b/specification/callbacks/channel-subscription-openapi-spec.json index 0b61d6e0d..d4cf36c1d 100644 --- a/specification/callbacks/channel-subscription-openapi-spec.json +++ b/specification/callbacks/channel-subscription-openapi-spec.json @@ -14,7 +14,7 @@ "/nhs-notify-callbacks/v1/channel-status": { "post": { "summary": "Receive a callback", - "description": "You may develop this endpoint on your service if you want to receive callbacks from NHS Notify.\n\nWe have created an OpenAPI specification detailing the behaviour of the endpoint that consumers should create to subscribe to callbacks.\n\nWe will send your API key in the `x-api-key` header. Your service should respond with:\n\n* `401 Unauthorized` if the API key is not received\n* `401 Unauthorized` if the API key is invalid\n\nWe will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from NHS Notify. This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form '.'. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`.\n\nEvery request includes an idempotencyKey located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially.\n\nIf a request fails, our retry policy will make up to three attempts with intervals of five seconds between each attempt.\n\nThe default behaviour of NHS Notify will make a callback to this endpoint when:\n\n* the message has been delivered (via any channel)\n* the message could not be delivered to a given channel (but may be deliverable by an alternative channel)\n* the message could not be delivered by any channel\n\nCallbacks can be received for additional state transitions subject to the needs of the user. These additional state transitions can be requested during onboarding. These statuses are:\n\n* `pending_enrichment` - the message is currently pending enrichment\n* `enriched` - we have queried PDS for this patient's details and now know how to contact this individual\n* `sending` - the message is in the process of being sent", + "description": "You may develop this endpoint on your service if you want to receive callbacks from NHS Notify.\n\nWe have created an OpenAPI specification detailing the behaviour of the endpoint that consumers should create to subscribe to callbacks.\n\nWe will send your API key in the `x-api-key` header. Your service should respond with:\n\n* `401 Unauthorized` if the API key is not received\n* `401 Unauthorized` if the API key is invalid\n\nWe will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from NHS Notify. This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form `[APPLICATION_ID].[API_KEY]`. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`.\n\nEvery request includes an idempotencyKey located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially.\n\nIf a request fails, our retry policy will make up to three attempts with intervals of five seconds between each attempt.\n\nThe default behaviour of NHS Notify will make a callback to this endpoint when:\n\n* the message has been delivered (via any channel)\n* the message could not be delivered to a given channel (but may be deliverable by an alternative channel)\n* the message could not be delivered by any channel\n\nCallbacks can be received for additional state transitions subject to the needs of the user. These additional state transitions can be requested during onboarding. These statuses are:\n\n* `pending_enrichment` - the message is currently pending enrichment\n* `enriched` - we have queried PDS for this patient's details and now know how to contact this individual\n* `sending` - the message is in the process of being sent", "operationId": "post-v1-channel-callbacks", "parameters": [ { diff --git a/specification/documentation/APIDescription.md b/specification/documentation/APIDescription.md index 3450bbd2f..528c29ef5 100644 --- a/specification/documentation/APIDescription.md +++ b/specification/documentation/APIDescription.md @@ -162,7 +162,7 @@ We will send your API key in the `x-api-key header`. Your service should respond * `401 Unauthorized` if the API key is invalid We will send you a HMAC-SHA256 signature in the `x-hmac-sha256-signature` header. You will need to validate the signature to verify the response has come from NHS Notify. -This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form '.'. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`. +This can be achieved by hashing the request body using the HMAC-SHA256 algorithm with a secret value that is comprised of a concatenation of your APIM application ID and the API key that we provide you. The secret takes the following form `[APPLICATION_ID].[API_KEY]`. If you receive a request with an invalid signature you should ignore it and respond with a `403 Forbidden`. Every request includes an `idempotencyKey` field located in the meta collection of the body. This can help ensure your system remains idempotent, capable of managing duplicate delivery of callbacks. It's important to note that requests may be delivered non-sequentially. From 4a7b60bda877909049994fd67b0abc139f07ae25 Mon Sep 17 00:00:00 2001 From: Clare Jones Date: Thu, 18 Jul 2024 15:35:51 +0100 Subject: [PATCH 9/9] +minor