Skip to content

Commit

Permalink
Merge pull request #705 from NHSDigital/release
Browse files Browse the repository at this point in the history
CCM-6271: Release 4.24
  • Loading branch information
chris-elliott-nhsd authored Aug 20, 2024
2 parents 8a0ab78 + f2ec970 commit 046271a
Show file tree
Hide file tree
Showing 68 changed files with 415 additions and 297 deletions.
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ install-node:
cd sandbox && npm install --legacy-peer-deps

#Configures Git Hooks, which are scripts that run given a specified event.
.git/hooks/pre-commit:
git/hooks/pre-commit:
cp scripts/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

#Condensed Target to run all targets above.
install: install-node install-python .git/hooks/pre-commit
install: install-node install-python git/hooks/pre-commit

#Referenced within readme
install-hooks: .git/hooks/pre-commit
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Build](https://github.com/NHSDigital/communications-manager-api/workflows/Build/badge.svg?branch=release)

This is the RESTful API for the [*Communications Manager Service*](https://digital.nhs.uk/developer/api-catalogue/communications-manager).
This is the RESTful API for the [*NHS Notify Service*](https://digital.nhs.uk/developer/api-catalogue/nhs-notify).

It includes:

Expand All @@ -16,7 +16,7 @@ It includes:
* `postman/` - Postman collections.
* `docs/` - [Documentation for the project](docs/index.md)

Consumers of the API will find developer documentation on the [Communications Manager API entry](https://digital.nhs.uk/developer/api-catalogue/communications-manager).
Consumers of the API will find developer documentation on the [NHS Notify API entry](https://digital.nhs.uk/developer/api-catalogue/nhs-notify).

This repo does not include the Communications Manager back-end that is not currently open source.

Expand Down
2 changes: 1 addition & 1 deletion azure/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ variables:
- name: hosted_target_connection_path_suffix
value: '{requestpath}'
- name: error_about_link
value: 'https://digital.nhs.uk/developer/api-catalogue/communications-manager'
value: 'https://digital.nhs.uk/developer/api-catalogue/nhs-notify'
1 change: 1 addition & 0 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ register_aws() {
add_config 'secrets.patterns' "${opt_quote}${aws}(ACCOUNT|account|Account)_?(ID|id|Id)?${opt_quote}${connect}${opt_quote}[0-9]{4}\-?[0-9]{4}\-?[0-9]{4}${opt_quote}"
add_config 'secrets.allowed' 'AKIAIOSFODNN7EXAMPLE'
add_config 'secrets.allowed' "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
add_config 'secrets.allowed' "UAT_NHS_APP_PASSWORD"

if [[ $? == 0 ]]; then
echo 'OK'
Expand Down
5 changes: 3 additions & 2 deletions nhsd-git-secrets/pre-commit-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Note that this will be invoked by the git hook from the repo root, so cd .. isn't required

# These only need to be run once per workstation but are included to try and ensure they are present
./git-secrets --register-aws
./git-secrets --add-provider -- cat nhsd-git-secrets/nhsd-rules-deny.txt

# Just scan the files changed in this commit
./git-secrets --pre_commit_hook
# Scan all files within this repo for this commit
./git-secrets --scan
316 changes: 166 additions & 150 deletions poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"info" : {
"_postman_id" : "fbe32763-302e-4a0b-b6e9-3a20f1bde923",
"createdAt" : null,
"description" : "This collection enables you to make requests against our integration test environment.\n\nThis environment requires you to be authenticated and authorised to make these requests, plus you must have completed (or be in the progress of) onboarding onto the Communications Manager Service.\n\nFor more information on the Communications Manager API please refer to [the documentation](https://digital.nhs.uk/developer/api-catalogue/communications-manager).\n\n## Authentication\n\nThis collection will carry out the [signed JWT authentication flow](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication) for you automatically.\n\nYou must provide your API key and private key within the environment variables.\n\nIf you have not yet created an API client with an API key and private key, then please [refer to the documentation](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication). Instructions are given here on how to create an application and how to generate a key pair for generating bearer tokens.\n\nMake sure to create your API application in the `Integration Testing` environment, and to request access to the `Communications Manager (Integration Testing)` API. Your API application will be granted access to this API automatically.\n\nOnce you have your API key and your private key, put these into the `api_key` and `private_key` variables within the `Integration` environment.\n\nRequests will now have a bearer token attached to them automatically, authenticating your requests.\n\nIf you have not yet started the onboarding process with the Communications Manager service then your requests, although authenticated, will return a `403 - Forbidden` response.\n\n**Ensure that your API key and private key are kept secret at all times!**\n\n**If you publish/share your API key or private key you must revoke them via the** [NHS onboarding portal](https://onboarding.prod.api.platform.nhs.uk/) **immediately.**\n\nLeaking these credentials will allow other people to generate tokens to call the API on your behalf.",
"description" : "This collection enables you to make requests against our integration test environment.\n\nThis environment requires you to be authenticated and authorised to make these requests, plus you must have completed (or be in the progress of) onboarding onto the Communications Manager Service.\n\nFor more information on the Communications Manager API please refer to [the documentation](https://digital.nhs.uk/developer/api-catalogue/nhs-notify).\n\n## Authentication\n\nThis collection will carry out the [signed JWT authentication flow](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication) for you automatically.\n\nYou must provide your API key and private key within the environment variables.\n\nIf you have not yet created an API client with an API key and private key, then please [refer to the documentation](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-signed-jwt-authentication). Instructions are given here on how to create an application and how to generate a key pair for generating bearer tokens.\n\nMake sure to create your API application in the `Integration Testing` environment, and to request access to the `Communications Manager (Integration Testing)` API. Your API application will be granted access to this API automatically.\n\nOnce you have your API key and your private key, put these into the `api_key` and `private_key` variables within the `Integration` environment.\n\nRequests will now have a bearer token attached to them automatically, authenticating your requests.\n\nIf you have not yet started the onboarding process with the Communications Manager service then your requests, although authenticated, will return a `403 - Forbidden` response.\n\n**Ensure that your API key and private key are kept secret at all times!**\n\n**If you publish/share your API key or private key you must revoke them via the** [NHS onboarding portal](https://onboarding.prod.api.platform.nhs.uk/) **immediately.**\n\nLeaking these credentials will allow other people to generate tokens to call the API on your behalf.",
"lastUpdatedBy" : null,
"name" : "Communications Manager - Integration",
"schema" : "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
Expand All @@ -142,7 +142,7 @@
},
"item" : [
{
"description" : "These example calls show how to use the send messages endpoint. This endpoint allows you to create a `MessageBatch`.\n\nFor more information on this endpoint [refer to the documentation](https://digital.nhs.uk/developer/api-catalogue/communications-manager#post-/v1/message-batches).",
"description" : "These example calls show how to use the send messages endpoint. This endpoint allows you to create a `MessageBatch`.\n\nFor more information on this endpoint [refer to the documentation](https://digital.nhs.uk/developer/api-catalogue/nhs-notify#post-/v1/message-batches).",
"id" : "f5ca3438-8247-4f80-a0f2-29dfb6ee85d3",
"item" : [
{
Expand Down Expand Up @@ -197,7 +197,7 @@
},
"raw" : "{\r\n \"data\": {\r\n \"type\": \"MessageBatch\",\r\n \"attributes\": {\r\n \"routingPlanId\": \"{{routing_plan_id}}\",\r\n \"messageBatchReference\": \"{{message_batch_reference}}\",\r\n \"messages\": [\r\n {\r\n \"messageReference\": \"703b8008-545d-4a04-bb90-1f2946ce1575\",\r\n \"recipient\": {\r\n \"nhsNumber\": \"9990548609\",\r\n \"dateOfBirth\": \"1932-01-06\"\r\n },\r\n \"originator\": {\r\n \"odsCode\": \"X26\"\r\n },\r\n \"personalisation\": {\r\n \"custom\" : \"value\"\r\n }\r\n }\r\n ]\r\n }\r\n }\r\n}"
},
"description" : "Sends a request to create a message batch.\n\nIt is possible to toggle the mime type used for sending and receiving data by changing the `mime_type` environment variable. Valid values for this can be found in [the documentation](https://digital.nhs.uk/developer/api-catalogue/communications-manager#post-/v1/message-batches).\n\nA random `X-Correlation-Id` header and `messageBatchReference` body value will be generated for each request in the pre-request script.",
"description" : "Sends a request to create a message batch.\n\nIt is possible to toggle the mime type used for sending and receiving data by changing the `mime_type` environment variable. Valid values for this can be found in [the documentation](https://digital.nhs.uk/developer/api-catalogue/nhs-notify#post-/v1/message-batches).\n\nA random `X-Correlation-Id` header and `messageBatchReference` body value will be generated for each request in the pre-request script.",
"header" : [
{
"key" : "Content-Type",
Expand Down Expand Up @@ -287,7 +287,7 @@
},
"raw" : "{\r\n \"data\": {\r\n \"type\": \"Message\",\r\n \"attributes\": {\r\n \"routingPlanId\": \"{{routing_plan_id}}\",\r\n \"messageReference\": \"{{message_reference}}\",\r\n \"recipient\": {\r\n \"nhsNumber\": \"9990548609\",\r\n \"dateOfBirth\": \"1932-01-06\"\r\n },\r\n \"originator\": {\r\n \"odsCode\": \"X26\"\r\n },\r\n \"personalisation\": {\r\n \"custom\": \"value\"\r\n }\r\n }\r\n }\r\n}"
},
"description" : "Sends a request to send a single message.\n\nIt is possible to toggle the mime type used for sending and receiving data by changing the `mime_type` environment variable. Valid values for this can be found in [the documentation](https://digital.nhs.uk/developer/api-catalogue/communications-manager#post-/v1/message-batches).\n\nA random `X-Correlation-Id` header and `messageReference` body value will be generated for each request in the pre-request script.",
"description" : "Sends a request to send a single message.\n\nIt is possible to toggle the mime type used for sending and receiving data by changing the `mime_type` environment variable. Valid values for this can be found in [the documentation](https://digital.nhs.uk/developer/api-catalogue/nhs-notify#post-/v1/message-batches).\n\nA random `X-Correlation-Id` header and `messageReference` body value will be generated for each request in the pre-request script.",
"header" : [
{
"key" : "Content-Type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"info" : {
"_postman_id" : "ec078d1e-d4d7-4460-92b9-7d79d51f967a",
"createdAt" : "2023-07-25T06:43:37.000Z",
"description" : "This collection allows you to run a number of pre-generated requests to simulate responses from our sandbox environment.\n\nThis environment requires no authentication and no upfront setup for you to use.\n\nFor more information on the Communications Manager API please refer to [the documentation](https://digital.nhs.uk/developer/api-catalogue/communications-manager).",
"description" : "This collection allows you to run a number of pre-generated requests to simulate responses from our sandbox environment.\n\nThis environment requires no authentication and no upfront setup for you to use.\n\nFor more information on the NHS Notify API please refer to [the documentation](https://digital.nhs.uk/developer/api-catalogue/nhs-notify).",
"lastUpdatedBy" : "35992763",
"name" : "Communications Manager - Sandbox",
"schema" : "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
Expand Down
2 changes: 1 addition & 1 deletion proxies/shared/resources/jsc/helpers/validationErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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), // NOSONAR
"links": Object.assign({}, { "about": "https://digital.nhs.uk/developer/api-catalogue/nhs-notify" }, links), // NOSONAR
"status": "400",
"title": title,
"detail": detail,
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
readme = "README.md"
license = "MIT"
repository = "https://github.com/NHSDigital/communications-manager-api"
homepage = "https://digital.nhs.uk/developer/api-catalogue/communications-manager"
homepage = "https://digital.nhs.uk/developer/api-catalogue/nhs-notify"
keywords = ["healthcare", "uk", "nhs", "communications", "email", "sms", "letter"]


Expand All @@ -25,8 +25,8 @@ sphinx = "7.1.2"
sphinx-markdown-builder = "^0.6.6"
notifications-python-client = "^9.0.0"
polling = "^0.3.2"
playwright = "^1.42.0"
install-playwright = "^0.0.1"
playwright = "^1.45.0"
install_playwright = "^0.1.0"

[tool.poetry.dev-dependencies]
flake8 = "^5.0.4"
Expand Down
2 changes: 2 additions & 0 deletions scripts/check_licences.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npm run check-licenses && scripts/check_python_licenses.sh && cd sandbox && npm run check-licenses
4 changes: 4 additions & 0 deletions scripts/ensure_docs_validity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
cd tests/docs
./build-docs.sh --verify
cd ../../
2 changes: 2 additions & 0 deletions scripts/lint_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
find . -name "*.py" -not -path "**/.venv/*" | xargs poetry run flake8
101 changes: 99 additions & 2 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,99 @@
#!/bin/sh
make lint
#!/bin/bash

# Check if there are unstaged changes
if git diff --quiet; then
echo -e "No unstaged changes to stash...\n"
STASH_CREATED=false
else
# Unstaged changes detected
git stash --keep-index -u
echo -e "Stashing unstaged changes...\n"
STASH_CREATED=true
fi

# Find all changed files for this commit
# Compute the diff only once to save a small amount of time.
CHANGED_FILES=$(git diff --name-only --cached --diff-filter=ACMR)
# Get only changed files that match our file suffix pattern
get_pattern_files() {
pattern=$(echo "$*" | sed "s/ /\$\\\|/g")
echo "$CHANGED_FILES" | { grep "$pattern$" || true; }
}
# Get all changed python files
PY_FILES=$(get_pattern_files .py)
JS_FILES=$(get_pattern_files .js)

# Tracks if any checks fail
FAIL=0

# Git Secrets
echo "Running Git Secrets..."
./nhsd-git-secrets/pre-commit-mac.sh
if [ $? -ne 0 ]; then
echo -e "Git Secrets failed. Commit aborted. \n"
FAIL=1
else
echo -e "Git Secrets check passed.\n"
fi


# Lint JavaScript files in the sandbox folder
echo "Linting JavaScript files..."
if [[ -n "$JS_FILES" ]]; then
node_modules/.bin/eslint 'sandbox/**/*.{js,jsx}'
if [ $? -ne 0 ]; then
echo -e "JavaScript linting failed. Commit aborted. \n"
FAIL=1
else
echo -e "JavaScript linting passed.\n"
fi
else
echo -e "No JavaScript files to lint. Skipping JavaScript linting. \n"
fi


# Lint Python files in the project
echo "Linting Python files..."
if [[ -n "$PY_FILES" ]]; then
./scripts/lint_python.sh
if [ $? -ne 0 ]; then
echo -e "Python linting failed. Commit aborted. \n"
FAIL=1
else
echo -e "Python linting passed.\n"
fi
else
echo -e "No Python files to lint. Skipping Python linting. \n"
fi

# Ensure Test Documentation Validity
echo "Ensuring test documentation validity..."
if ./scripts/ensure_docs_validity.sh > /dev/null 2>&1; then
echo -e "Documentation check passed. \n"
else
echo -e "Test documentation validation failed. Commit aborted. \n"
FAIL=1
fi

# Check Licences
echo "Checking licenses..."
if ./scripts/check_licences.sh > /dev/null 2>&1; then
echo -e "License check passed. \n"
else
echo -e "License check failed. Commit aborted. \n"
FAIL=1
fi

# Pop the stash only if a stash was created
if [ "$STASH_CREATED" = true ]; then
echo "Restoring unstaged changes..."
git stash pop -q
fi

# Exit with failure if any checks failed
if [ $FAIL -ne 0 ]; then
exit 1
fi

echo -e "All checks passed. Proceeding with commit. \n"
exit 0
4 changes: 2 additions & 2 deletions scripts/publish_zap_compatible.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def scan_and_remove(obj, mappings):
(
("format", "date"),
("personalisation", None),
("/callbacks/message-status", None),
("/<client-provided-URI>", None),
("/<client-provided-message-status-URI>", None),
("/<client-provided-channel-status-URI>", None),
)
),
f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@
"format": "date-time"
},
"retryCount": {
"type": "number",
"description": "Contains the amount of times that we have attempted to send this channel."
"$ref": "../snippets/RetryCount.yaml"
}
},
"required": [
Expand All @@ -143,7 +142,7 @@
"type": "string",
"format": "uri",
"examples": [
"https://api.service.nhs.uk/comms/v1/messages/0ujsszwN8NRY24YaXiTIE2VWDTS"
"https://api.service.nhs.uk/comms/v1/messages/2WL3qFTEFM0qMY8xjRbt1LIKCzM"
]
}
},
Expand Down Expand Up @@ -178,7 +177,7 @@
"minLength": 27,
"maxLength": 27,
"examples": [
"0ujsszwN8NRY24YaXiTIE2VWDTS"
"2WL3qFTEFM0qMY8xjRbt1LIKCzM"
]
},
"Enum_ChannelStatus": {
Expand Down
2 changes: 1 addition & 1 deletion specification/callbacks/channel_status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
summary: Channel Status
description: |-
NHS Notify can send a supplier status callback when:
NHS Notify can send a channel status callback when:
* the channel status has changed - This refers to the internal statuses used by NHS Notify, which are consistent across all channels
* the supplier status has changed - This is the raw status value specified by the underlying channel supplier. The possible values are listed [here](#overview--supplier-statuses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"type": "string",
"format": "uri",
"examples": [
"https://api.service.nhs.uk/comms/v1/messages/0ujsszwN8NRY24YaXiTIE2VWDTS"
"https://api.service.nhs.uk/comms/v1/messages/2WL3qFTEFM0qMY8xjRbt1LIKCzM"
]
}
},
Expand Down Expand Up @@ -168,7 +168,7 @@
"minLength": 27,
"maxLength": 27,
"examples": [
"0ujsszwN8NRY24YaXiTIE2VWDTS"
"2WL3qFTEFM0qMY8xjRbt1LIKCzM"
]
},
"Enum_MessageStatus": {
Expand Down
Loading

0 comments on commit 046271a

Please sign in to comment.