Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a85ae8b
[CDAPI-85]: Initial introduction of APIM Authenticator class
nhsd-jack-wainwright Feb 16, 2026
ee5245a
[CDAPI-85]: Added initial plumbing for lambda to utilise provided env…
nhsd-jack-wainwright Mar 4, 2026
6c58ba4
[CDAPI-85]: Moved requests to be a main dependency
nhsd-jack-wainwright Mar 6, 2026
c6fd116
[CDAPI-85]: Minor fix to type conditions within config.py
nhsd-jack-wainwright Mar 6, 2026
67ab6d1
[CDAPI-85]: Minor Duration class fix
nhsd-jack-wainwright Mar 6, 2026
7ef6841
[CDAPI-85]: Minor lambda environment variable fix
nhsd-jack-wainwright Mar 6, 2026
3687f94
[CDAPI-85]: Initial unit test fixes WIP
nhsd-jack-wainwright Mar 10, 2026
87dcdc9
[CDAPI-85]: Moved SessionManager directory to use top level /tmp
nhsd-jack-wainwright Mar 10, 2026
f38c57d
[CDAPI-85]: Added additional logging to APIM authentication
nhsd-jack-wainwright Mar 10, 2026
7115455
[CDAPI-85]: Minor poetry.lock fix post rebase
nhsd-jack-wainwright Mar 10, 2026
2810955
[CDAPI-85]: Increased client timeout
nhsd-jack-wainwright Mar 10, 2026
80f4ea1
[CDAPI-85]: Added additional logging around APIM authentication
nhsd-jack-wainwright Mar 10, 2026
f5bb920
[CDAPI-85]: Fixed test_handler unit tests
nhsd-jack-wainwright Mar 12, 2026
43300ef
[CDAPI-85]: Bumped pathology-api lambda timeout to 30 seconds
nhsd-jack-wainwright Mar 12, 2026
8b58293
[CDAPI-85]: Added type conversion for expiry time within ApimAuthenti…
nhsd-jack-wainwright Mar 12, 2026
319d75c
[CDAPI-85]: Increase memory for pathology-api lambda
nhsd-jack-wainwright Mar 12, 2026
799a6ea
[CDAPI-85]: Increased pathology-api lambda memory to 512MB
nhsd-jack-wainwright Mar 12, 2026
9f28ab9
[CDAPI-85]: Minor unit test path fix
nhsd-jack-wainwright Mar 12, 2026
ff2c92b
[CDAPI-85]: Added unit tests for config.py
nhsd-jack-wainwright Mar 12, 2026
48a53c0
[CDAPI-85]: Added unit tests for apim.py
nhsd-jack-wainwright Mar 13, 2026
8b9e474
[CDAPI-85]: Added additional assertions to test_handler.py
nhsd-jack-wainwright Mar 13, 2026
f197af9
[CDAPI-85]: Added unit tests for http.py
nhsd-jack-wainwright Mar 13, 2026
a7db97e
[CDAPI-85]: Increased request timeout for integration, acceptance, co…
nhsd-jack-wainwright Mar 16, 2026
cf23ece
[CDAPI-85]: Added additional test coverage for handler.py
nhsd-jack-wainwright Mar 16, 2026
41acb90
[CDAPI-85]: Removed contract, integration, schema and acceptance test…
nhsd-jack-wainwright Mar 16, 2026
ec4bca0
[CDAPI-85]: Increased preview-env fetch depth for SonarQube analysis
nhsd-jack-wainwright Mar 17, 2026
730f22c
[CDAPI-85]: Minor review comment fixes
nhsd-jack-wainwright Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/preview-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0 # Full history required for accurate sonar analysis.

- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
Expand Down Expand Up @@ -124,6 +126,8 @@ jobs:
APIM_APIKEY: ${{ secrets.APIM_APIKEY }}
API_MTLS_CERT: ${{ secrets.API_MTLS_CERT }}
API_MTLS_KEY: ${{ secrets.API_MTLS_KEY }}
APIM_KEY_ID: ${{ secrets.APIM_KEY_ID }}
CLIENT_REQUEST_TIMEOUT: ${{ secrets.CLIENT_REQUEST_TIMEOUT }}
run: |
cd pathology-api/target/
FN="${{ steps.names.outputs.function_name }}"
Expand All @@ -133,6 +137,8 @@ jobs:
API_KEY="${APIM_APIKEY:-/cds/pathology/dev/apim/api-key}"
MTLS_CERT="${API_MTLS_CERT:-/cds/pathology/dev/mtls/client1-key-public}"
MTLS_KEY="${API_MTLS_KEY:-/cds/pathology/dev/mtls/client1-key-secret}"
KEY_ID="${APIM_KEY_ID:-DEV-1}"
CLIENT_TIMEOUT="${CLIENT_REQUEST_TIMEOUT:-10s}"
echo "Deploying preview function: $FN"
wait_for_lambda_ready() {
while true; do
Expand All @@ -154,14 +160,18 @@ jobs:
wait_for_lambda_ready
aws lambda update-function-configuration --function-name "$FN" \
--handler "${{ env.LAMBDA_HANDLER }}" \
--memory-size 512 \
--timeout 30 \
--environment "Variables={APIM_TOKEN_EXPIRY_THRESHOLD=$EXPIRY_THRESHOLD, \
APIM_PRIVATE_KEY_NAME=$PRIVATE_KEY, \
APIM_API_KEY_NAME=$API_KEY, \
APIM_MTLS_CERT_NAME=$MTLS_CERT, \
APIM_MTLS_KEY_NAME=$MTLS_KEY, \
APIM_TOKEN_URL=$MOCK_URL/apim, \
PDM_BUNDLE_URL=$MOCK_URL/pdm, \
APIM_KEY_ID=$KEY_ID, \
APIM_TOKEN_URL=$MOCK_URL/apim/oauth2/token, \
PDM_BUNDLE_URL=$MOCK_URL/apim/check_auth, \
MNS_EVENT_URL=$MOCK_URL/mns, \
CLIENT_TIMEOUT=$CLIENT_TIMEOUT, \
JWKS_SECRET_NAME=$JWKS_SECRET}" || true
wait_for_lambda_ready
aws lambda update-function-code --function-name "$FN" \
Expand All @@ -173,14 +183,18 @@ jobs:
--handler "${{ env.LAMBDA_HANDLER }}" \
--zip-file "fileb://artifact.zip" \
--role "${{ steps.role-select.outputs.lambda_role }}" \
--memory-size 512 \
--timeout 30 \
--environment "Variables={APIM_TOKEN_EXPIRY_THRESHOLD=$EXPIRY_THRESHOLD, \
APIM_PRIVATE_KEY_NAME=$PRIVATE_KEY, \
APIM_API_KEY_NAME=$API_KEY, \
APIM_KEY_ID=$KEY_ID, \
APIM_MTLS_CERT_NAME=$MTLS_CERT, \
APIM_MTLS_KEY_NAME=$MTLS_KEY, \
APIM_TOKEN_URL=$MOCK_URL/apim, \
PDM_BUNDLE_URL=$MOCK_URL/pdm, \
APIM_TOKEN_URL=$MOCK_URL/apim/oauth2/token, \
PDM_BUNDLE_URL=$MOCK_URL/apim/check_auth, \
MNS_EVENT_URL=$MOCK_URL/mns, \
CLIENT_TIMEOUT=$CLIENT_TIMEOUT, \
JWKS_SECRET_NAME=$JWKS_SECRET}" \
--publish
wait_for_lambda_ready
Expand Down
92 changes: 1 addition & 91 deletions .github/workflows/stage-2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
retention-days: 30
- name: "Upload unit test results for mocks"
if: always()
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: mock-unit-test-results
path: mocks/test-artefacts/
Expand All @@ -60,93 +60,3 @@ jobs:
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: pathology-api/test-artefacts/unit-tests.xml

test-contract:
name: "Contract tests"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: "Checkout code"
uses: actions/checkout@v6
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
with:
python-version: ${{ inputs.python_version }}
- name: "Run contract tests"
run: make test-contract
- name: "Upload contract test results"
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: contract-test-results
path: pathology-api/test-artefacts/
retention-days: 30
- name: "Publish contract test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: pathology-api/test-artefacts/contract-tests.xml

test-schema:
name: "Schema validation tests"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v6
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
with:
python-version: ${{ inputs.python_version }}
- name: "Run schema validation tests"
run: make test-schema
- name: "Upload schema test results"
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: schema-test-results
path: pathology-api/test-artefacts/
retention-days: 30
- name: "Publish schema test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: pathology-api/test-artefacts/schema-tests.xml

test-integration:
name: "Integration tests"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "Checkout code"
uses: actions/checkout@v6
- name: "Setup Python project"
uses: ./.github/actions/setup-python-project
with:
python-version: ${{ inputs.python_version }}
- name: "Start local Lambda"
uses: ./.github/actions/start-local-lambda
with:
python-version: ${{ inputs.python_version }}
- name: "Run integration test"
run: make test-integration
- name: "Upload integration test results"
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
with:
name: integration-test-results
path: pathology-api/test-artefacts/
retention-days: 30
- name: "Publish integration test results to summary"
if: always()
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: pathology-api/test-artefacts/integration-tests.xml
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"gitlens.ai.enabled": false,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"pathology-api",
"mocks"
],
"git.enableCommitSigning": true,
"sonarlint.connectedMode.project": {
"connectionId": "nhsdigital",
Expand Down
1 change: 0 additions & 1 deletion pathology-api/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pathology_api.logging import get_logger

_logger = get_logger(__name__)

app = APIGatewayHttpResolver()

type _ExceptionHandler[T: Exception] = Callable[[T], Response[str]]
Expand Down
Loading
Loading