Skip to content

Commit 44a6c26

Browse files
authored
Merge pull request #1635 from okta/OKTA-939653-previewSAMLmetadataForApplication-issue
OKTA-939653 - Updating mushtache file
2 parents 8dd6a54 + 8792009 commit 44a6c26

File tree

11 files changed

+62
-27
lines changed

11 files changed

+62
-27
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.okta.sdk</groupId>
2323
<artifactId>okta-sdk-root</artifactId>
24-
<version>23.0.2-SNAPSHOT</version>
24+
<version>24.0.0-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>okta-sdk-api</artifactId>

api/src/main/resources/custom_templates/ApiClient.mustache

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.JavaType;
3333
import org.openapitools.jackson.nullable.JsonNullableModule;
3434
{{/openApiNullable}}
3535

36+
import org.apache.commons.lang3.StringUtils;
3637
import org.apache.hc.client5.http.cookie.BasicCookieStore;
3738
import org.apache.hc.client5.http.cookie.Cookie;
3839
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
@@ -74,6 +75,7 @@ import java.util.concurrent.ConcurrentHashMap;
7475
import java.util.regex.Matcher;
7576
import java.util.regex.Pattern;
7677

78+
7779
import java.net.URLEncoder;
7880

7981
import java.io.File;
@@ -744,18 +746,29 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
744746
* @return The Accept header to use. If the given array is empty,
745747
* null will be returned (not to set the Accept header explicitly).
746748
*/
747-
public String selectHeaderAccept(String[] accepts) {
749+
public String selectHeaderAccept(String[] accepts, String path) {
750+
if (path != null && path.contains("/sso/saml/metadata")) {
751+
for (String accept : accepts) {
752+
if ("text/xml".equalsIgnoreCase(accept)) {
753+
return accept;
754+
}
755+
}
756+
}
757+
748758
if (accepts.length == 0) {
749759
return null;
750760
}
761+
751762
for (String accept : accepts) {
752763
if (isJsonMime(accept)) {
753764
return accept;
754765
}
755766
}
756-
return StringUtil.join(accepts, ",");
767+
768+
return StringUtils.join(accepts, ",");
757769
}
758770

771+
759772
/**
760773
* Select the Content-Type header's value from the given array:
761774
* if JSON exists in the given array, use it;
@@ -934,7 +947,12 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
934947
} else if ("text/plain".equalsIgnoreCase(mimeType)) {
935948
// convert input stream to string
936949
return (T) EntityUtils.toString(entity);
950+
} else if ("text/xml".equalsIgnoreCase(mimeType)) {
951+
952+
return (T) EntityUtils.toString(entity);
953+
937954
} else {
955+
938956
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
939957
throw new ApiException(
940958
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
@@ -1214,7 +1232,12 @@ protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>
12141232
12151233
if (Objects.nonNull(t)) {
12161234
1217-
Map<String, ?> map = getObjectMapper().convertValue(t, LinkedHashMap.class);
1235+
if (t instanceof String && accept != null && accept.contains("xml")) {
1236+
return t;
1237+
}
1238+
1239+
1240+
Map<String, ?> map = getObjectMapper().convertValue(t, LinkedHashMap.class);
12181241

12191242
String href = null;
12201243

api/src/main/resources/custom_templates/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ import org.openapitools.jackson.nullable.JsonNullableModule;
188188
final String[] localVarAccepts = {
189189
{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
190190
};
191-
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
191+
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts, localVarPath);
192192

193193
final String[] localVarContentTypes = {
194-
{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
194+
"text/xml", {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
195195
};
196196
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
197197

coverage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.okta.sdk</groupId>
2323
<artifactId>okta-sdk-root</artifactId>
24-
<version>23.0.2-SNAPSHOT</version>
24+
<version>24.0.0-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>okta-sdk-coverage</artifactId>

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.okta.sdk</groupId>
2323
<artifactId>okta-sdk-root</artifactId>
24-
<version>23.0.2-SNAPSHOT</version>
24+
<version>24.0.0-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>okta-sdk-examples</artifactId>

examples/quickstart/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.okta.sdk</groupId>
2222
<artifactId>okta-sdk-examples</artifactId>
23-
<version>23.0.2-SNAPSHOT</version>
23+
<version>24.0.0-SNAPSHOT</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626

@@ -48,6 +48,11 @@
4848
<artifactId>testng</artifactId>
4949
<scope>test</scope>
5050
</dependency>
51+
<dependency>
52+
<groupId>com.okta.sdk</groupId>
53+
<artifactId>okta-sdk-api</artifactId>
54+
<version>23.0.1</version>
55+
</dependency>
5156
</dependencies>
5257

5358
<build>

impl/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.okta.sdk</groupId>
2323
<artifactId>okta-sdk-root</artifactId>
24-
<version>23.0.2-SNAPSHOT</version>
24+
<version>24.0.0-SNAPSHOT</version>
2525
</parent>
2626

2727
<artifactId>okta-sdk-impl</artifactId>

integration-tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>com.okta.sdk</groupId>
2222
<artifactId>okta-sdk-root</artifactId>
23-
<version>23.0.2-SNAPSHOT</version>
23+
<version>24.0.0-SNAPSHOT</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626

integration-tests/src/test/groovy/com/okta/sdk/tests/it/GroupsIT.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ class GroupsIT extends ITSupport {
151151

152152
// 2. Add user to the group and validate user present in group
153153
groupApi.assignUserToGroup(group.getId(), user.getId())
154-
155-
assertUserInGroup(user, group, groupApi, 5, getTestOperationDelay())
154+
sleep(3000)
155+
assertUserInGroup(user, group, groupApi, 10, getTestOperationDelay())
156156

157157
// 3. Remove user from group and validate user removed
158158
groupApi.unassignUserFromGroup(group.getId(), user.getId())
159159

160-
assertUserNotInGroup(user, group, groupApi,5, getTestOperationDelay())
160+
assertUserNotInGroup(user, group, groupApi,10, getTestOperationDelay())
161161
}
162162
}

integration-tests/src/test/groovy/com/okta/sdk/tests/it/util/Util.groovy

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,29 @@ class Util {
123123
.findFirst().isPresent()
124124
}
125125

126-
static void assertUserNotInGroup(User user, Group group, GroupApi groupApi, int times, long delayInMilliseconds, boolean present=true) {
127-
for (int ii=0; ii<times; ii++) {
126+
static void assertUserNotInGroup(User user, Group group, GroupApi groupApi, int times, long delayInMilliseconds, boolean present = true) {
127+
for (int ii = 0; ii < times; ii++) {
128128

129129
sleep(delayInMilliseconds)
130130

131-
if (present == !StreamSupport.stream(groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false)
132-
.filter{ listUser -> listUser.id == user.id}
133-
.findFirst().isPresent()) {
131+
boolean userIsPresent = StreamSupport.stream(
132+
groupApi.listGroupUsers(group.getId(), null, null).spliterator(), false
133+
).anyMatch { listUser -> listUser.id == user.id }
134+
135+
if ((present && userIsPresent) || (!present && !userIsPresent)) {
134136
return
135137
}
136138
}
137139

138-
if (present) Assert.fail("User not found in group")
139-
if (!present) Assert.fail("User found in group")
140+
141+
if (present) {
142+
Assert.fail("User not found in group after ${times} attempts")
143+
} else {
144+
Assert.fail("User found in group after ${times} attempts")
145+
}
140146
}
141147

148+
142149
static def ignoring = { Class<? extends Throwable> catchMe, Closure callMe ->
143150
try {
144151
callMe.call()

0 commit comments

Comments
 (0)