Skip to content

Commit 34ebb6a

Browse files
author
Chris Wiechmann
committed
Improved integration test to validate application-subscriptions
#114
1 parent c766a3d commit 34ebb6a

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionTestIT.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
5858
createVariable("extClientId", RandomNumberFunction.getRandomNumber(15, true));
5959
createVariable("app2Name", "Test-SubApp 2 ${apiNumber}");
6060
http(builder -> builder.client("apiManager").send().post("/applications").header("Content-Type", "application/json")
61-
.payload("{\"name\":\"${app2Name}\",\"apis\":[],\"organizationId\":\"${orgId}\"}"));
61+
.payload("{\"name\":\"${app2Name}\",\"apis\":[],\"organizationId\":\"${orgId2}\"}"));
6262

6363
http(builder -> builder.client("apiManager").receive().response(HttpStatus.CREATED).messageType(MessageType.JSON)
6464
.extractFromPayload("$.id", "consumingTestApp2Id")
@@ -77,7 +77,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
7777
// ############## Creating Test-Application 3 #################
7878
createVariable("app3Name", "Test-SubApp 3 ${apiNumber}");
7979
http(builder -> builder.client("apiManager").send().post("/applications").header("Content-Type", "application/json")
80-
.payload("{\"name\":\"${app3Name}\",\"apis\":[],\"organizationId\":\"${orgId}\"}"));
80+
.payload("{\"name\":\"${app3Name}\",\"apis\":[],\"organizationId\":\"${orgId2}\"}"));
8181

8282
http(builder -> builder.client("apiManager").receive().response(HttpStatus.CREATED).messageType(MessageType.JSON)
8383
.extractFromPayload("$.id", "consumingTestApp3Id")
@@ -91,6 +91,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
9191
createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/applications/1_api-with-1-org-some-apps.json");
9292
createVariable("state", "published");
9393
createVariable("orgName", "${orgName}");
94+
createVariable("version", "1.0.0");
9495
createVariable("expectedReturnCode", "0");
9596
swaggerImport.doExecute(context);
9697

@@ -139,8 +140,43 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
139140
.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
140141
.validate("$.[?(@.path=='${apiPath}')].id", "${apiId}")); // Must be the same API-ID as before!
141142

143+
echo("####### Changin FE-API Settings only for: '${apiName}' - Mode: Unpublish/Publish and make sure subscriptions stay #######");
144+
createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json");
145+
createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/applications/1_api-with-1-org-some-apps.json");
146+
createVariable("state", "published");
147+
createVariable("orgName", "${orgName}");
148+
createVariable("version", "2.0.0");
149+
createVariable("expectedReturnCode", "0");
150+
swaggerImport.doExecute(context);
151+
152+
echo("####### Validate API: '${apiName}' has been reconfigured (Unpublich/Publish) and appscriptions are recreated #######");
153+
http(builder -> builder.client("apiManager").send().get("/proxies/${apiId}").header("Content-Type", "application/json"));
154+
155+
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
156+
.validate("$.[?(@.id=='${apiId}')].name", "${apiName}")
157+
.validate("$.[?(@.id=='${apiId}')].state", "published"));
158+
159+
echo("####### Validate Application 3 still has an active subscription to the API (Based on the name) #######");
160+
http(builder -> builder.client("apiManager").send().get("/applications/${consumingTestApp3Id}/apis").header("Content-Type", "application/json"));
161+
162+
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
163+
.validate("$.*.apiId", "${apiId}"));
164+
165+
echo("####### Validate Application 1 still has an active subscription to the API (based on the API-Key) #######");
166+
http(builder -> builder.client("apiManager").send().get("/applications/${consumingTestApp1Id}/apis").header("Content-Type", "application/json"));
167+
168+
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
169+
.validate("$.*.apiId", "${apiId}"));
170+
171+
echo("####### Validate Application 2 still has an active subscription to the API (based on the Ext-Client-Id) #######");
172+
http(builder -> builder.client("apiManager").send().get("/applications/${consumingTestApp2Id}/apis")
173+
.header("Content-Type", "application/json"));
174+
175+
http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
176+
.validate("$.*.apiId", "${apiId}"));
177+
142178
echo("####### Re-Importing same API: '${apiName}' - Without applications subscriptions and mode replace #######");
143-
createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore2.json");
179+
createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json");
144180
createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
145181
createVariable("state", "published");
146182
createVariable("orgName", "${orgName}");

modules/apis/src/test/resources/com/axway/apim/test/files/applications/1_api-with-1-org-some-apps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name":"${apiName}",
33
"path":"${apiPath}",
44
"state":"${state}",
5-
"version":"1.0.1",
5+
"version":"${version}",
66
"organization":"API Development ${orgNumber}",
77
"clientOrganizations":[
88
"${orgName2}"

0 commit comments

Comments
 (0)