Skip to content

Commit c3c5df3

Browse files
authored
Merge pull request #83 from NHSDigital/apm-3713-refactor-tests-to-use-pytest-nhsd-apim-package
APM-3713 refactor tests to use pytest nhsd apim package
2 parents b0ccffa + 66c67a1 commit c3c5df3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1015
-2229
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ jobs:
2323
- name: Install Java
2424
run: sudo apt-get install --yes default-jre default-jdk
2525

26-
- name: Install node
27-
run: |
28-
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
29-
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
30-
sudo apt-get install -y nodejs
31-
3226
- name: Upgrade python packaging tools
3327
run: python -m pip install --upgrade pip setuptools wheel
3428

.github/workflows/pr-lint.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,3 @@ jobs:
66
steps:
77
- name: Check ticket name conforms to requirements
88
run: echo ${{ github.event.pull_request.head.ref }} | grep -i -E -q "(apm-[0-9]+)|(apmspii-[0-9]+)|(adz-[0-9]+)|(amb-[0-9]+)|(dependabot\/)"
9-
10-
- name: Grab ticket name
11-
if: contains(github.event.pull_request.head.ref, 'apm-') || contains(github.event.pull_request.head.ref, 'APM-') || contains(github.event.pull_request.head.ref, 'apmspii-') || contains(github.event.pull_request.head.ref, 'APMSPII-') || contains(github.event.pull_request.head.ref, 'adz-') || contains(github.event.pull_request.head.ref, 'ADZ-') || contains(github.event.pull_request.head.ref, 'amb-') || contains(github.event.pull_request.head.ref, 'AMB-')
12-
run: echo ::set-env name=TICKET_NAME::$(echo ${{ github.event.pull_request.head.ref }} | grep -i -o '\(apm-[0-9]\+\)\|\(apmspii-[0-9]\+\)\|\(adz-[0-9]\+\)|\(amb-[0-9]\+\)' | tr '[:lower:]' '[:upper:]')
13-
env:
14-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
15-
16-
- name: Comment on PR with link to JIRA ticket
17-
if: contains(github.event.pull_request.head.ref, 'apm-') || contains(github.event.pull_request.head.ref, 'APM-') || contains(github.event.pull_request.head.ref, 'apmspii-') || contains(github.event.pull_request.head.ref, 'APMSPII-') || contains(github.event.pull_request.head.ref, 'adz-') || contains(github.event.pull_request.head.ref, 'ADZ-') || contains(github.event.pull_request.head.ref, 'amb-') || contains(github.event.pull_request.head.ref, 'AMB-')
18-
uses: unsplash/comment-on-pr@master
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
with:
22-
msg: |
23-
This branch is work on a ticket in the NHS Digital APM JIRA Project. Here's a handy link to the ticket:
24-
# [${{ env.TICKET_NAME }}](https://nhsd-jira.digital.nhs.uk/browse/${{ env.TICKET_NAME}})

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ __pycache__/
1616
.idea/
1717
.venv/
1818
.env
19+
.env*
20+
.vscode/
1921

2022
smoketest-report.xml

azure/azure-pr-pipeline.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,10 @@ extends:
3232
service_name: ${{ variables.service_name }}
3333
short_service_name: ${{ variables.short_service_name }}
3434
service_base_path: ${{ variables.service_base_path }}
35-
secret_file_ids:
36-
- ptl/app-credentials/jwt_testing/non-prod/JWT_TESTING_PRIVATE_KEY
37-
- ptl/app-credentials/jwt_testing/non-prod/ID_TOKEN_TESTING_PRIVATE_KEY
38-
- ptl/app-credentials/jwt_testing/non-prod/ID_TOKEN_NHS_LOGIN_PRIVATE_KEY
3935
secret_ids:
40-
- ptl/monitoring/status-endpoint-api-key
4136
- ptl/app-credentials/identity-service/non-prod/ACCESS_TOKEN_SECRET
42-
config_ids:
43-
- /ptl/azure-devops/env-internal-dev/test-app/internal-testing-internal-dev/CLIENT_ID
4437
apigee_deployments:
4538
- environment: internal-dev
46-
# Comment out the tests before merging to master if the shared flow updates isn't released from infra
47-
# post_deploy:
48-
# - template: ./templates/run-integration-tests.yml
39+
# Comment out the tests before merging to master if the shared flow updates needed aren't released from infra
40+
post_deploy:
41+
- template: ./templates/run-integration-tests.yml

azure/azure-release-pipeline.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,8 @@ extends:
3030
service_name: ${{ variables.service_name }}
3131
short_service_name: ${{ variables.short_service_name }}
3232
service_base_path: ${{ variables.service_base_path }}
33-
secret_file_ids:
34-
- ptl/app-credentials/jwt_testing/non-prod/JWT_TESTING_PRIVATE_KEY
35-
- ptl/app-credentials/jwt_testing/non-prod/ID_TOKEN_TESTING_PRIVATE_KEY
36-
- ptl/app-credentials/jwt_testing/non-prod/ID_TOKEN_NHS_LOGIN_PRIVATE_KEY
3733
secret_ids:
38-
- ptl/monitoring/status-endpoint-api-key
3934
- ptl/app-credentials/identity-service/non-prod/ACCESS_TOKEN_SECRET
40-
config_ids:
41-
- /ptl/azure-devops/env-internal-dev/test-app/internal-testing-internal-dev/CLIENT_ID
4235
apigee_deployments:
4336
- environment: internal-dev
4437
post_deploy:

azure/project.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ variables:
22
service_name: shared-flow-testing
33
short_service_name: sft
44
service_base_path: shared-flow-testing
5-
product_display_name: Shared Flow Testing
6-
product_description: This proxy only consumes shared flows.
7-
spec_file: shared-flow-testing.json

azure/templates/run-integration-tests.yml

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,20 @@ steps:
66

77
- bash: |
88
poetry install
9-
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/tests
9+
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)
1010
displayName: Setup integration tests
1111
1212
- bash: |
13-
export RELEASE_RELEASEID=$(Build.BuildId)
1413
export SOURCE_COMMIT_ID=$(Build.SourceVersion)
15-
export APIGEE_ENVIRONMENT="$(ENVIRONMENT)"
16-
export SERVICE_BASE_PATH="$(SERVICE_BASE_PATH)"
17-
export SERVICE_NAME="$(FULLY_QUALIFIED_SERVICE_NAME)"
18-
export STATUS_ENDPOINT_API_KEY="$(status-endpoint-api-key)"
19-
export JWT_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(JWT_TESTING_PRIVATE_KEY)"
20-
export ID_TOKEN_NHS_LOGIN_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(ID_TOKEN_NHS_LOGIN_PRIVATE_KEY)"
21-
export ID_TOKEN_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(ID_TOKEN_TESTING_PRIVATE_KEY)"
22-
export STATUS_ENDPOINT_API_KEY="$(status-endpoint-api-key)"
23-
export APIGEE_API_TOKEN="$(secret.AccessToken)"
24-
export OAUTH_PROXY="oauth2"
25-
export APP_CLIENT_ID="$(CLIENT_ID)"
26-
export OAUTH_BASE_URI="https://$(APIGEE_ENVIRONMENT).api.service.nhs.uk"
14+
export APIGEE_ACCESS_TOKEN="$(secret.AccessToken)"
15+
export PROXY_NAME="$(FULLY_QUALIFIED_SERVICE_NAME)"
16+
export API_NAME="shared-flow-testing"
17+
export OAUTH_BASE_URI="https://$(APIGEE_ENVIRONMENT).api.service.nhs.uk/oauth2-mock"
2718
export ACCESS_TOKEN_HASH_SECRET="$(ACCESS_TOKEN_SECRET)"
2819
29-
poetry run pytest --reruns 2 --reruns-delay 1 -v -m "not mock_auth" --junitxml=test-report.xml
30-
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/tests
31-
displayName: run simulated auth smoketests
32-
33-
- bash: |
34-
export RELEASE_RELEASEID=$(Build.BuildId)
35-
export SOURCE_COMMIT_ID=$(Build.SourceVersion)
36-
export APIGEE_ENVIRONMENT="$(ENVIRONMENT)"
37-
export SERVICE_BASE_PATH="$(SERVICE_BASE_PATH)"
38-
export SERVICE_NAME="$(FULLY_QUALIFIED_SERVICE_NAME)"
39-
export STATUS_ENDPOINT_API_KEY="$(status-endpoint-api-key)"
40-
export JWT_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(JWT_TESTING_PRIVATE_KEY)"
41-
export ID_TOKEN_NHS_LOGIN_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(ID_TOKEN_NHS_LOGIN_PRIVATE_KEY)"
42-
export ID_TOKEN_PRIVATE_KEY_ABSOLUTE_PATH="$(Pipeline.Workspace)/secrets/$(ID_TOKEN_TESTING_PRIVATE_KEY)"
43-
export STATUS_ENDPOINT_API_KEY="$(status-endpoint-api-key)"
44-
export APIGEE_API_TOKEN="$(secret.AccessToken)"
45-
export OAUTH_PROXY="oauth2-mock"
46-
export APP_CLIENT_ID="$(CLIENT_ID)"
47-
export OAUTH_BASE_URI="https://$(APIGEE_ENVIRONMENT).api.service.nhs.uk"
48-
export ACCESS_TOKEN_HASH_SECRET="$(ACCESS_TOKEN_SECRET)"
49-
50-
poetry run pytest --reruns 2 --reruns-delay 1 -v -m "not simulated_auth" --junitxml=test-report.xml
51-
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/tests
52-
displayName: run mock auth smoketests
20+
poetry run pytest --reruns 2 --reruns-delay 1 -v --junitxml=test-report.xml
21+
workingDirectory: $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)
22+
displayName: Run integration tests
5323
5424
- task: PublishTestResults@2
5525
displayName: 'Publish smoketest results'

manifest_template.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@ DESCRIPTION: This proxy only consumes shared flows.
44
APIGEE_ENVIRONMENTS:
55
- name: internal-dev
66
display_name: Internal Development
7-
- name: internal-dev-sandbox
8-
display_name: Internal Development Sandbox
9-
- name: internal-qa
10-
display_name: Internal QA
11-
- name: internal-qa-sandbox
12-
display_name: Internal QA Sandbox
13-
- name: ref
14-
display_name: Reference
15-
- name: sandbox
16-
display_name: Sandbox
17-
# Enable int environment when ready by uncommenting:
18-
# - name: int
19-
# display_name: Integration Testing
207
---
218
meta:
229
api:
@@ -45,9 +32,11 @@ apigee:
4532
proxies:
4633
- {{ SERVICE_NAME }}-{{ ENV.name }}
4734
- identity-service-{{ ENV.name }}
35+
- identity-service-mock-{{ ENV.name }}
4836
scopes:
4937
- 'urn:nhsd:apim:app:level3:{{ SERVICE_NAME }}'
50-
- 'urn:nhsd:apim:user-nhs-id:aal3:{{ SERVICE_NAME }}'
38+
- 'urn:nhsd:apim:user-nhs-cis2:aal3:{{ SERVICE_NAME }}'
39+
- 'urn:nhsd:apim:user-nhs-login:P9:{{ SERVICE_NAME }}'
5140
quota: '300'
5241
quotaInterval: '1'
5342
quotaTimeUnit: minute

0 commit comments

Comments
 (0)