Skip to content

Commit

Permalink
- Fix integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Oct 23, 2024
1 parent 53189f5 commit 42c4fe4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.axway.apim.adapter.apis.APIManagerAPIAccessAdapter.Type;
import com.axway.apim.api.API;
import com.axway.apim.api.model.APIAccess;
import com.axway.apim.api.model.Organization;
import com.axway.apim.api.model.apps.ClientApplication;
import com.axway.apim.lib.CoreParameters;
import com.axway.apim.lib.error.AppException;
Expand Down Expand Up @@ -48,7 +49,7 @@ public void execute(boolean reCreation) throws AppException {
}
if (desiredState.getApplications() != null) { // Happens, when config-file doesn't contain client apps
// Remove configured apps, for Non-Granted-Orgs!
removeNonGrantedClientApps(desiredState.getApplications());
removeNonGrantedClientApps(desiredState.getApplications(), desiredState.getOrganization());
}
// If an UNPUBLISHED API has been re-created, we have to create App-Subscriptions manually, as API-Manager Upgrade only works on PUBLISHED APIs
// But we only need to do this, if existing App-Subscriptions should be preserved (MODE_ADD).
Expand Down Expand Up @@ -82,12 +83,14 @@ public void execute(boolean reCreation) throws AppException {
}


public void removeNonGrantedClientApps(List<ClientApplication> apps) {
public void removeNonGrantedClientApps(List<ClientApplication> apps, Organization developmentOrganization) {
if (apps == null) return;
ListIterator<ClientApplication> it = apps.listIterator();
ClientApplication app;
while (it.hasNext()) {
app = it.next();
if(app.getOrganization().getName().equals(developmentOrganization.getName()))
continue;
if (hasClientAppPermission(app)) {
LOG.error("Organization of configured application: {} has NO permission to this API. Ignoring this application.", app.getName());
it.remove();
Expand All @@ -98,7 +101,7 @@ public void removeNonGrantedClientApps(List<ClientApplication> apps) {
public boolean hasClientAppPermission(ClientApplication app) {
LOG.info("Checking Application name : {} belong to granted organization : {}", app.getName(), app.getOrganization().getName());
if (actualState.getClientOrganizations() == null) {
LOG.debug("No Client-Orgs configured for this API, therefore other app has NO permission.");
LOG.debug("No Client-Orgs configured for this API");
return true;
}
return !actualState.getClientOrganizations().contains(app.getOrganization());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void run() {
$(echo("####### API has been created with ID: '${apiId}' #######"));
$(echo("####### Validate the application has already an active subscription to the API (Based on the name) #######"));
$(http().client(apiManager).send().get("/applications/${testAppId}/apis"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.*.apiId", "${apiId}")));

$(echo("####### Trigger a Re-Create of the API: '${apiName}' - Subscription must stay #######"));
Expand Down

0 comments on commit 42c4fe4

Please sign in to comment.