@@ -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
@@ -104,6 +105,13 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
104105
105106 echo ("####### API has been created with ID: '${apiId}' #######" );
106107
108+ echo ("####### Validate API with ID: '${apiId}' is granted to Org2: ${orgName2} (${orgId2}) #######" );
109+ http (builder -> builder .client ("apiManager" ).send ().get ("/organizations/${orgId2}/apis" ).header ("Content-Type" , "application/json" ));
110+
111+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
112+ .validate ("$.[?(@.apiId=='${apiId}')].state" , "approved" )
113+ .validate ("$.[?(@.apiId=='${apiId}')].enabled" , "true" ));
114+
107115 echo ("####### Validate created application 3 has an active subscription to the API (Based on the name) #######" );
108116 http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp3Id}/apis" ).header ("Content-Type" , "application/json" ));
109117
@@ -139,8 +147,50 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
139147 .validate ("$.[?(@.path=='${apiPath}')].name" , "${apiName}" )
140148 .validate ("$.[?(@.path=='${apiPath}')].id" , "${apiId}" )); // Must be the same API-ID as before!
141149
150+ echo ("####### Changing FE-API Settings only for: '${apiName}' - Mode: Unpublish/Publish and make sure subscriptions stay #######" );
151+ createVariable (ImportTestAction .API_DEFINITION , "/com/axway/apim/test/files/basic/petstore.json" );
152+ createVariable (ImportTestAction .API_CONFIG , "/com/axway/apim/test/files/applications/1_api-with-1-org-some-apps.json" );
153+ createVariable ("state" , "published" );
154+ createVariable ("orgName" , "${orgName}" );
155+ createVariable ("version" , "2.0.0" );
156+ createVariable ("expectedReturnCode" , "0" );
157+ swaggerImport .doExecute (context );
158+
159+ echo ("####### Validate API: '${apiName}' has been reconfigured (Unpublich/Publish) and appscriptions are recreated #######" );
160+ http (builder -> builder .client ("apiManager" ).send ().get ("/proxies/${apiId}" ).header ("Content-Type" , "application/json" ));
161+
162+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
163+ .validate ("$.[?(@.id=='${apiId}')].name" , "${apiName}" )
164+ .validate ("$.[?(@.id=='${apiId}')].state" , "published" ));
165+
166+ echo ("####### Validate Re-Puslished API with ID: '${apiId}' is still granted to Org2: ${orgName2} (${orgId2}) #######" );
167+ http (builder -> builder .client ("apiManager" ).send ().get ("/organizations/${orgId2}/apis" ).header ("Content-Type" , "application/json" ));
168+
169+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
170+ .validate ("$.[?(@.apiId=='${apiId}')].state" , "approved" )
171+ .validate ("$.[?(@.apiId=='${apiId}')].enabled" , "true" ));
172+
173+ echo ("####### Validate Application 3 still has an active subscription to the API (Based on the name) #######" );
174+ http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp3Id}/apis" ).header ("Content-Type" , "application/json" ));
175+
176+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
177+ .validate ("$.*.apiId" , "${apiId}" ));
178+
179+ echo ("####### Validate Application 1 still has an active subscription to the API (based on the API-Key) #######" );
180+ http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp1Id}/apis" ).header ("Content-Type" , "application/json" ));
181+
182+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
183+ .validate ("$.*.apiId" , "${apiId}" ));
184+
185+ echo ("####### Validate Application 2 still has an active subscription to the API (based on the Ext-Client-Id) #######" );
186+ http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp2Id}/apis" )
187+ .header ("Content-Type" , "application/json" ));
188+
189+ http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
190+ .validate ("$.*.apiId" , "${apiId}" ));
191+
142192 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" );
193+ createVariable (ImportTestAction .API_DEFINITION , "/com/axway/apim/test/files/basic/petstore .json" );
144194 createVariable (ImportTestAction .API_CONFIG , "/com/axway/apim/test/files/basic/4_flexible-status-config.json" );
145195 createVariable ("state" , "published" );
146196 createVariable ("orgName" , "${orgName}" );
@@ -203,23 +253,24 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
203253
204254 echo ("####### API has been RE-CREATED with ID: '${newApiId}' #######" );
205255
206- echo ("####### Validate created application 3 STILL has an active subscription to the API (Based on the name ) #######" );
207- http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp3Id }/apis" ).header ("Content-Type" , "application/json" ));
256+ echo ("####### Validate Application 1 STILL has an active subscription to the API (based on the API-Key ) #######" );
257+ http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp1Id }/apis" ).header ("Content-Type" , "application/json" ));
208258
209259 http (builder -> builder .client ("apiManager" ).receive ().response (HttpStatus .OK ).messageType (MessageType .JSON )
210260 .validate ("$.*.apiId" , "${newApiId}" ));
211261
212- echo ("####### Validate Application 1 STILL has an active subscription to the API (based on the API-Key) #######" );
213- http (builder -> builder .client ("apiManager" ).send ().get ("/applications/${consumingTestApp1Id}/apis" ).header ("Content-Type" , "application/json" ));
262+ // As the apps 3 & 2 now belong to a different organization the org-admin cannot see / re-subscribe them
263+ /*
264+ echo("####### Validate created application 3 STILL has an active subscription to the API (Based on the name) #######");
265+ http(builder -> builder.client("apiManager").send().get("/applications/${consumingTestApp3Id}/apis").header("Content-Type", "application/json"));
214266
215267 http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
216268 .validate("$.*.apiId", "${newApiId}"));
217-
218- echo ("####### Validate Application 2 STILL has an active subscription to the API (based on the Ext-Client-Id) #######" );
269+ echo("####### Validate Application 2 STILL has an active subscription to the API (based on the Ext-Client-Id) #######");
219270 http(builder -> builder.client("apiManager").send().get("/applications/${consumingTestApp2Id}/apis")
220271 .header("Content-Type", "application/json"));
221272
222273 http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
223- .validate ("$.*.apiId" , "${newApiId}" ));
274+ .validate("$.*.apiId", "${newApiId}")); */
224275 }
225276}
0 commit comments