Skip to content

Commit a82bba8

Browse files
tests
1 parent d05a624 commit a82bba8

File tree

5 files changed

+1133
-0
lines changed

5 files changed

+1133
-0
lines changed

tests/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules/
99
/target
1010
/playwright/.auth/
1111
/allure-report
12+
/e2e-tests/.pytest_cache
13+
/e2e-tests/__pycache__/
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
import pytest
3+
import requests
4+
import json
5+
import time
6+
from lib import Generators
7+
8+
from pytest_nhsd_apim.apigee_apis import (
9+
DeveloperAppsAPI,
10+
ApigeeClient,
11+
ApigeeNonProdCredentials,
12+
)
13+
14+
@pytest.fixture()
15+
def client():
16+
config = ApigeeNonProdCredentials()
17+
return ApigeeClient(config=config)
18+
19+
@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
20+
def test_app_level0_access(nhsd_apim_proxy_url, nhsd_apim_auth_headers, _create_test_app, client: ApigeeClient ):
21+
headers = {
22+
**nhsd_apim_auth_headers,
23+
"headerauth1": "headervalue1",
24+
"x-request-id": "123456"
25+
}
26+
27+
app_api = DeveloperAppsAPI(client=client)
28+
app_name = _create_test_app["name"]
29+
30+
attributes = app_api.get_app_attributes(
31+
email="[email protected]", app_name=app_name
32+
)
33+
34+
attributes['attribute'].append({'name': 'NHSD-Supplier-ID' , 'value': 'supplier1'})
35+
36+
app_api.post_app_attributes(
37+
38+
app_name=app_name,
39+
body=attributes
40+
)
41+
42+
resp = requests.get(
43+
nhsd_apim_proxy_url + "/letters?limit=10", headers=headers
44+
)
45+
assert resp.status_code == 200
46+
47+
@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
48+
def test_app_level0_access_post(nhsd_apim_proxy_url, nhsd_apim_auth_headers, _create_test_app, client: ApigeeClient ):
49+
headers = {
50+
**nhsd_apim_auth_headers,
51+
"headerauth1": "headervalue1",
52+
"x-request-id": "123456"
53+
}
54+
55+
data = Generators.generate_valid_create_message_body("sandbox")
56+
print(data);
57+
58+
resp = requests.post(
59+
f"{nhsd_apim_proxy_url + "/letters/:id"}", headers=headers,
60+
json = data
61+
)
62+
assert resp.status_code == 200
63+
64+
65+
66+
@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
67+
def test_ping(nhsd_apim_proxy_url):
68+
resp = requests.get(nhsd_apim_proxy_url + "/_ping")
69+
70+
print("\nCalled:\n" + nhsd_apim_proxy_url + "/_ping" )
71+
print("\nResponse status code: ", resp.status_code)
72+
73+
assert resp.status_code == 200
74+
75+
@pytest.mark.nhsd_apim_authorization(access="application", level="level3")
76+
def test_401_status_without_api_key(nhsd_apim_proxy_url):
77+
resp = requests.get(
78+
f"{nhsd_apim_proxy_url}/_status"
79+
)
80+
81+
error_handler.handle_retry(resp)
82+
83+
assert resp.status_code == 401

tests/e2e-tests/lib/generators.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
class Generators():
3+
@staticmethod
4+
def generate_valid_create_message_body(environment="sandbox"):
5+
return {
6+
{
7+
"data": {
8+
"attributes": {
9+
"status": "PENDING"
10+
},
11+
"id": "2WL5eYSWGzCHlGmzNxuqVusPxDg",
12+
"type": "Letter"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)