Skip to content

Commit 25b5be6

Browse files
Update OpenAPI spec to 2.12.0 (#730)
* Update OpenApi spec to 2.12.0 * updates to IT * minor refactor * Update SignOnPoliciesIT.groovy
1 parent 223c5ca commit 25b5be6

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,73 @@ class SignOnPoliciesIT implements CrudTestSupport {
221221
assertThat(updateProfileEnrollmentPolicyRuleActions.getProfileEnrollment().getProfileAttributes().first().getRequired(), is(true))
222222
}
223223

224+
@Test (groups = "bacon")
225+
void applyPolicyToApplicationTest() {
226+
227+
String name = "java-sdk-it-" + UUID.randomUUID().toString()
228+
229+
Application oidcApp = OIDCApplicationBuilder.instance()
230+
.setName(name)
231+
.setLabel(name)
232+
.addRedirectUris("https://www.example.com")
233+
.setPostLogoutRedirectUris(Collections.singletonList("https://www.example.com/logout"))
234+
.setResponseTypes(Arrays.asList(OAuthResponseType.TOKEN, OAuthResponseType.CODE))
235+
.setGrantTypes(Arrays.asList(OAuthGrantType.IMPLICIT, OAuthGrantType.AUTHORIZATION_CODE))
236+
.setApplicationType(OpenIdConnectApplicationType.WEB)
237+
.setClientId(UUID.randomUUID().toString())
238+
.setClientSecret(UUID.randomUUID().toString())
239+
.setAutoKeyRotation(true)
240+
.setTokenEndpointAuthMethod(OAuthEndpointAuthenticationMethod.CLIENT_SECRET_BASIC)
241+
.setIOS(false)
242+
.setWeb(true)
243+
.setLoginRedirectUrl("https://www.myapp.com")
244+
.setErrorRedirectUrl("https://www.myapp.com/error")
245+
.buildAndCreate(client)
246+
registerForCleanup(oidcApp)
247+
248+
Policy policy1 = client.instantiate(Policy)
249+
.setName(name + "-1")
250+
.setType(PolicyType.ACCESS_POLICY)
251+
.setStatus(Policy.StatusEnum.ACTIVE)
252+
.setDescription("IT created Policy - applyPolicyToApplicationTest")
253+
254+
Policy createdPolicy1 = client.createPolicy(policy1)
255+
registerForCleanup(createdPolicy1)
256+
257+
assertThat(createdPolicy1, notNullValue())
258+
259+
Policy policy2 = client.instantiate(Policy)
260+
.setName(name + "-2")
261+
.setType(PolicyType.ACCESS_POLICY)
262+
.setStatus(Policy.StatusEnum.ACTIVE)
263+
.setDescription("IT created Policy - applyPolicyToApplicationTest")
264+
265+
Policy createdPolicy2 = client.createPolicy(policy2)
266+
registerForCleanup(createdPolicy2)
267+
268+
assertThat(createdPolicy2, notNullValue())
269+
270+
// update app policy to createdPolicy1
271+
oidcApp.updateApplicationPolicy(createdPolicy1.getId())
272+
273+
Application updatedApp = client.getApplication(oidcApp.getId())
274+
assertThat(updatedApp, notNullValue())
275+
276+
// assert if the app access policy resource id matches createdPolicy1 resource id
277+
String policyResourceId = extractAccessPolicyResourceIdFromApplication(updatedApp)
278+
assertThat(policyResourceId, equalTo(createdPolicy1.getId()))
279+
280+
// Now, update app policy to createdPolicy2
281+
oidcApp.updateApplicationPolicy(createdPolicy2.getId())
282+
283+
updatedApp = client.getApplication(oidcApp.getId())
284+
assertThat(updatedApp, notNullValue())
285+
286+
// assert if the app app policy resource id matches createdPolicy2 resource id
287+
policyResourceId = extractAccessPolicyResourceIdFromApplication(updatedApp)
288+
assertThat(policyResourceId, equalTo(createdPolicy2.getId()))
289+
}
290+
224291
@Test
225292
void signOnActionsTest() {
226293

@@ -318,4 +385,13 @@ class SignOnPoliciesIT implements CrudTestSupport {
318385
static void assertRulesExpanded(AuthorizationServerPolicy policy) {
319386
assertThat policy.getEmbedded(), allOf(notNullValue(), hasKey("rules"))
320387
}
388+
389+
static String extractAccessPolicyResourceIdFromApplication(Application application) {
390+
assertThat(application, notNullValue())
391+
assertThat(application.getLinks(), notNullValue())
392+
assertThat(application.getLinks().get("accessPolicy"), notNullValue())
393+
String accessPolicyHref = application.getLinks().get("accessPolicy").toString()
394+
String accessPolicyResourceId = accessPolicyHref.substring(accessPolicyHref.lastIndexOf("/") + 1).replaceAll("]", "")
395+
return accessPolicyResourceId
396+
}
321397
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"dependencies": {
3-
"@okta/openapi": "2.11.2"
3+
"@okta/openapi": "2.12.0"
44
}
55
}

0 commit comments

Comments
 (0)