Skip to content

Commit ee3e0ed

Browse files
committed
Re-enable end-to-end tests, sourcing status endpoint from github secret, rather than fetching from APIM
1 parent 4fcac1f commit ee3e0ed

6 files changed

Lines changed: 26 additions & 33 deletions

File tree

.github/actions/e2e-tests/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ runs:
1919
export PROXY_NAME=nhs-notify-supplier--internal-dev--nhs-notify-supplier
2020
export API_ENVIRONMENT=internal-dev
2121
export NON_PROD_PRIVATE_KEY="${GITHUB_WORKSPACE}/internal-dev-test-1.pem"
22+
export STATUS_ENDPOINT_API_KEY="${STATUS_ENDPOINT_API_KEY}"
2223
make .internal-dev-test

.github/workflows/stage-4-acceptance.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ jobs:
9090
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
9191

9292
- name: "Run e2e tests"
93-
#uses: ./.github/actions/e2e-tests
93+
uses: ./.github/actions/e2e-tests
9494
env:
9595
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9696
NON_PROD_API_KEY: ${{ secrets.NON_PROD_API_KEY }}
9797
INTERNAL_DEV_TEST_PEM: ${{ secrets.INTERNAL_DEV_TEST_PEM }}
98-
shell: bash
99-
run: |
100-
echo "E2E tests are currently disabled. See CCM-14778"
98+
STATUS_ENDPOINT_API_KEY: ${{ secrets.STATUS_ENDPOINT_API_KEY }}

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ ${VERBOSE}.SILENT: \
131131
#####################
132132

133133
TEST_CMD := APIGEE_ACCESS_TOKEN="$(APIGEE_ACCESS_TOKEN)" \
134+
STATUS_ENDPOINT_API_KEY="$(STATUS_ENDPOINT_API_KEY)" \
134135
PYTHONPATH=. poetry run pytest --disable-warnings -vv \
135136
--color=yes \
136137
-n 4 \

tests/e2e-tests/README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
11
# E2E Tests
22

3-
## Generate An Apigee Access Token
4-
5-
To generate authentication using Apigee, you must have access to an Apigee account and use `get_token` via the command line and generate an Apigee access token.
6-
7-
**Tokens expire once per day and require refreshing.**
8-
9-
* Install [`get_token`](https://docs.apigee.com/api-platform/system-administration/auth-tools#install)
10-
* Run the following command and log in with your Apigee credentials when prompted:
11-
12-
```shell
13-
export APIGEE_ACCESS_TOKEN=$(SSO_LOGIN_URL=https://login.apigee.com get_token)
14-
```
15-
16-
* If your token does not refresh, try clearing the cache:
17-
18-
```shell
19-
export APIGEE_ACCESS_TOKEN=$(SSO_LOGIN_URL=https://login.apigee.com get_token --clear-sso-cache)
20-
```
21-
223
### Set Proxy Name
234

245
Set the `PROXY_NAME` environment variable to specify the environment for test execution. You can find the proxy name by logging into [Apigee](https://apigee.com/edge), navigating to 'API Proxies' and searching for 'supplier-api' for lower environments like internal-dev.
@@ -31,3 +12,14 @@ Available values for `PROXY_NAME` include:
3112

3213
* `nhs-notify-supplier--internal-dev--nhs-notify-supplier`
3314
* `nhs-notify-supplier--internal-dev--nhs-notify-supplier-pr<num>`
15+
16+
### Set Up API Keys
17+
18+
Set the following environment variables to use the Apigee API keys:
19+
20+
```shell
21+
export NON_PROD_API_KEY=******
22+
export STATUS_ENDPOINT_API_KEY=******
23+
```
24+
25+
The values have been redacted here but you can obtain them from another team member.

tests/e2e-tests/api/test_endpoint.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import pytest
22
import requests
3-
from os import getenv
43
from lib.errorhandler import ErrorHandler
5-
6-
def _get(url, headers=None, timeout=10):
7-
return requests.get(url, headers=headers or {}, timeout=timeout)
4+
from lib.fixtures import * # NOSONAR
85

96
@pytest.mark.smoketest
10-
def test_ping(nhsd_apim_proxy_url):
11-
resp = requests.get(nhsd_apim_proxy_url + "/_ping")
7+
def test_ping(url):
8+
resp = requests.get(url + "/_ping")
129
assert resp.status_code == 200
1310

1411
@pytest.mark.smoketest
1512
@pytest.mark.sandboxtest
1613
@pytest.mark.devtest
17-
def test_status(nhsd_apim_proxy_url, status_endpoint_auth_headers):
14+
def test_status(url, status_endpoint_api_key):
1815
resp = requests.get(
19-
f"{nhsd_apim_proxy_url}/_status", headers=status_endpoint_auth_headers
16+
f"{url}/_status", headers={"apikey": status_endpoint_api_key}
2017
)
2118

2219
ErrorHandler.handle_retry(resp)
@@ -25,9 +22,9 @@ def test_status(nhsd_apim_proxy_url, status_endpoint_auth_headers):
2522
@pytest.mark.smoketest
2623
@pytest.mark.sandboxtest
2724
@pytest.mark.devtest
28-
def test_401_status_without_api_key(nhsd_apim_proxy_url):
25+
def test_401_status_without_api_key(url):
2926
resp = requests.get(
30-
f"{nhsd_apim_proxy_url}/_status"
27+
f"{url}/_status"
3128
)
3229

3330
ErrorHandler.handle_retry(resp)

tests/e2e-tests/lib/fixtures.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ def bearer_token(authentication_cache):
6262
else:
6363
url = f"https://{environment}.api.service.nhs.uk/nhs-notify-supplier"
6464
return authentication_cache.generate_authentication(environment, url)
65+
66+
@pytest.fixture(scope='session')
67+
def status_endpoint_api_key():
68+
return os.environ["STATUS_ENDPOINT_API_KEY"]

0 commit comments

Comments
 (0)