Skip to content

Commit ec2362e

Browse files
author
Chris Wiechmann
committed
Also making sure OAuth-Provider profile isn't exported with internal ID
1 parent 3719190 commit ec2362e

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

modules/apis/src/main/java/com/axway/apim/api/export/ExportAPI.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ public List<AuthenticationProfile> getAuthenticationProfiles() {
117117
if(this.actualAPIProxy.getAuthenticationProfiles().get(0).getType()==AuthType.none)
118118
return null;
119119
}
120+
for(AuthenticationProfile profile : this.actualAPIProxy.getAuthenticationProfiles()) {
121+
if(profile.getType()==AuthType.oauth) {
122+
String providerProfile = (String)profile.getParameters().get("providerProfile");
123+
if(providerProfile.startsWith("<key")) {
124+
providerProfile = providerProfile.substring(providerProfile.indexOf("<key type='OAuthAppProfile'>"));
125+
providerProfile = providerProfile.substring(providerProfile.indexOf("value='")+7, providerProfile.lastIndexOf("'/></key>"));
126+
}
127+
profile.getParameters().put("providerProfile", providerProfile);
128+
}
129+
}
120130
return this.actualAPIProxy.getAuthenticationProfiles();
121131
}
122132

modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/CustomPoliciesTestIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.axway.apim.export.test.customPolicies;
22

33
import static org.testng.Assert.assertEquals;
4+
import static org.testng.Assert.assertFalse;
45
import static org.testng.Assert.assertTrue;
56

67
import java.io.File;
@@ -106,6 +107,8 @@ private void exportAPI(TestContext context, boolean ignoreAdminAccount) throws F
106107
Map<String, OutboundProfile> importedOutboundProfiles = mapper.convertValue(importedAPIConfig.get("outboundProfiles"), new TypeReference<Map<String, OutboundProfile>>(){});
107108
Map<String, OutboundProfile> exportedOutboundProfiles = mapper.convertValue(exportedAPIConfig.get("outboundProfiles"), new TypeReference<Map<String, OutboundProfile>>(){});
108109
assertEquals(importedOutboundProfiles, exportedOutboundProfiles, "OutboundProfiles are not equal.");
110+
assertFalse(exportedAPIConfig.get("outboundProfiles").get("_default").get("requestPolicy").asText().startsWith("<key"), "Request policy should not start with <key");
111+
assertFalse(exportedAPIConfig.get("outboundProfiles").get("_default").get("responsePolicy").asText().startsWith("<key"), "Request policy should not start with <key");
109112

110113
TagMap<String, String[]> importedTags = mapper.convertValue(importedAPIConfig.get("tags"), new TypeReference<TagMap<String, String[]>>(){});
111114
TagMap<String, String[]> exportedTags = mapper.convertValue(exportedAPIConfig.get("tags"), new TypeReference<TagMap<String, String[]>>(){});

0 commit comments

Comments
 (0)