Skip to content

Commit 53f30ff

Browse files
alex-clayton-1stephhou
authored andcommitted
test: DTOSS 3884 e2e tests utilising WireMock (#1563)
* test: Integrated WireMock into test runner and setup new test file * test: Changed console log message * test: Cleanup WireMock requests after running test * test: Added steps to manual amend runner also * test: Fixed wiremock URLs in compose file * test: Fixed WireMock URL protocol in docker compose * test: Added environment variable to config in env.ts * test: Handles exception in cleanupWireMock
1 parent 11f197c commit 53f30ff

15 files changed

Lines changed: 663 additions & 17 deletions

File tree

application/CohortManager/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CAASFOLDER_STORAGE_CONNECTION_STRING="" # Enter the connection string for azurit
1818
CONTAINER_NAME="" # Name of the container to be used in the test. Example: "inbound".
1919
E2E_TEST_FILES_PATH="" # Path to the end-to-end test files directory. Example: "e2e/testFiles".
2020
API_TEST_FILES_PATH="" # Path to the api test files directory. Example: "api/testFiles".
21+
WIREMOCK_URL=http://localhost:8080/__admin/requests
2122

2223
# Data Service Endpoints to access the APIs built on top of the Entity Framework
2324
# For Local Development & testing, make sure these are mapped using ports option in compose.data-services.yaml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"request": {
3+
"urlPath": "/oauth_token.do",
4+
"method": "POST",
5+
"formParameters": {
6+
"grant_type": {
7+
"equalTo": "refresh_token"
8+
},
9+
"client_id": {
10+
"equalTo": "MockClientId-123"
11+
},
12+
"client_secret": {
13+
"equalTo": "MockClientSecret-123"
14+
},
15+
"refresh_token": {
16+
"equalTo": "MockRefreshToken-123"
17+
}
18+
}
19+
},
20+
"response": {
21+
"jsonBody": {
22+
"access_token": "MockAccessToken-123",
23+
"refresh_token": "MockRefreshToken-123",
24+
"scope": "IntegrationStationAll",
25+
"token_type": "Bearer",
26+
"expires_in": 1800
27+
},
28+
"status": 200
29+
}
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"request": {
3+
"urlPathPattern": "^/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseResolution/.+$",
4+
"method": "PUT",
5+
"headers": {
6+
"Authorization": {
7+
"equalTo": "Bearer MockAccessToken-123"
8+
}
9+
},
10+
"bodyPatterns": [
11+
{
12+
"matchesJsonPath": "$[?(@.state == 6)]"
13+
},
14+
{
15+
"matchesJsonPath": "$[?(@.resolution_code == '28')]"
16+
},
17+
{
18+
"matchesJsonPath": "$.close_notes"
19+
}
20+
]
21+
},
22+
"response": {
23+
"status": 200
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"request": {
3+
"urlPathPattern": "^/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseUpdate/.+$",
4+
"method": "PUT",
5+
"headers": {
6+
"Authorization": {
7+
"equalTo": "Bearer MockAccessToken-123"
8+
}
9+
},
10+
"bodyPatterns": [
11+
{
12+
"matchesJsonPath": "$[?(@.state == 10)]"
13+
},
14+
{
15+
"matchesJsonPath": "$.work_notes"
16+
}
17+
]
18+
},
19+
"response": {
20+
"status": 200
21+
}
22+
}

application/CohortManager/compose.core.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,13 @@ services:
320320
profiles: [service-now]
321321
environment:
322322
- ASPNETCORE_URLS=http://*:9092
323-
- ServiceNowRefreshAccessTokenUrl=https://nhsdigitaldev.service-now.com/oauth_token.do
324-
- ServiceNowUpdateUrl=https://nhsdigitaldev.service-now.com/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseUpdate
325-
- ServiceNowResolutionUrl=https://nhsdigitaldev.service-now.com/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseResolution
323+
- ServiceNowRefreshAccessTokenUrl=http://wiremock:8080/oauth_token.do
324+
- ServiceNowUpdateUrl=http://wiremock:8080/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseUpdate
325+
- ServiceNowResolutionUrl=http://wiremock:8080/api/x_nhsd_intstation/nhs_integration/9c78f87c97912e10dd80f2df9153aff5/CohortCaseResolution
326326
- ServiceNowGrantType=refresh_token
327-
- ServiceNowClientId=${SERVICENOW_CLIENT_ID}
328-
- ServiceNowClientSecret=${SERVICENOW_CLIENT_SECRET}
329-
- ServiceNowRefreshToken=${SERVICENOW_REFRESH_TOKEN}
327+
- ServiceNowClientId=MockClientId-123
328+
- ServiceNowClientSecret=MockClientSecret-123
329+
- ServiceNowRefreshToken=MockRefreshToken-123
330330
- ServiceNowParticipantManagementTopic=servicenow-participant-management-topic
331331
- ServiceBusConnectionString_client_internal=Endpoint=sb://service-bus;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;
332332
ports:

application/CohortManager/compose.deps.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ services:
7272
- SYS_PTRACE
7373
restart: "no"
7474

75+
wiremock:
76+
container_name: wiremock
77+
networks: [cohman-network]
78+
image: wiremock/wiremock
79+
ports:
80+
- "8080:8080"
81+
volumes:
82+
- ./Set-up/wiremock/mappings:/home/wiremock/mappings
83+
command: --verbose --root-dir /home/wiremock
84+
7585
networks:
7686
cohman-network:
7787
name: cohman-network

0 commit comments

Comments
 (0)