Skip to content

Commit

Permalink
Fix other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmiccoli committed Oct 24, 2023
1 parent bd69d32 commit 47c7246
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void testAuthzCodeAudienceSupport()
// @formatter:on

// @formatter:off
ValidatableResponse resp2 = RestAssured.given()
RestAssured.given()
.formParam("username", "test")
.formParam("password", "password")
.formParam("submit", "Login")
Expand All @@ -125,7 +125,7 @@ public void testAuthzCodeAudienceSupport()

// @formatter:off
RestAssured.given()
.cookie(resp2.extract().detailedCookie("JSESSIONID"))
.cookie(resp1.extract().detailedCookie("JSESSIONID"))
.queryParam("response_type", RESPONSE_TYPE_CODE)
.queryParam("client_id", TEST_CLIENT_ID)
.queryParam("redirect_uri", TEST_CLIENT_REDIRECT_URI)
Expand All @@ -142,8 +142,8 @@ public void testAuthzCodeAudienceSupport()
// @formatter:on

// @formatter:off
ValidatableResponse resp4 = RestAssured.given()
.cookie(resp2.extract().detailedCookie("JSESSIONID"))
ValidatableResponse resp2 = RestAssured.given()
.cookie(resp1.extract().detailedCookie("JSESSIONID"))
.formParam("user_oauth_approval", "true")
.formParam("authorize", "Authorize")
.formParam("scope_openid", "openid")
Expand All @@ -156,14 +156,14 @@ public void testAuthzCodeAudienceSupport()
.statusCode(HttpStatus.SEE_OTHER.value());
// @formatter:on

String authzCode = UriComponentsBuilder.fromHttpUrl(resp4.extract().header("Location"))
String authzCode = UriComponentsBuilder.fromHttpUrl(resp2.extract().header("Location"))
.build()
.getQueryParams()
.get("code")
.get(0);

// @formatter:off
ValidatableResponse resp5= RestAssured.given()
ValidatableResponse resp3= RestAssured.given()
.formParam("grant_type", "authorization_code")
.formParam("redirect_uri", TEST_CLIENT_REDIRECT_URI)
.formParam("code", authzCode)
Expand All @@ -178,9 +178,9 @@ public void testAuthzCodeAudienceSupport()
// @formatter:on

String accessToken =
mapper.readTree(resp5.extract().body().asString()).get("access_token").asText();
mapper.readTree(resp3.extract().body().asString()).get("access_token").asText();

String idToken = mapper.readTree(resp5.extract().body().asString()).get("id_token").asText();
String idToken = mapper.readTree(resp3.extract().body().asString()).get("id_token").asText();

JWT atJwt = JWTParser.parse(accessToken);
JWT itJwt = JWTParser.parse(idToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void testConsentPageReturnsFilteredScopes()
// @formatter:on

// @formatter:off
ValidatableResponse loginResponse = RestAssured.given()
RestAssured.given()
.cookie(authzResponse.extract().detailedCookie(SESSION))
.formParam("username", "test")
.formParam("password", "password")
Expand All @@ -155,7 +155,7 @@ public void testConsentPageReturnsFilteredScopes()

// @formatter:off
String responseBody = RestAssured.given()
.cookie(loginResponse.extract().detailedCookie(SESSION))
.cookie(authzResponse.extract().detailedCookie(SESSION))
.queryParam("response_type", RESPONSE_TYPE_CODE)
.queryParam("client_id", TEST_CLIENT_ID)
.queryParam("redirect_uri", TEST_CLIENT_REDIRECT_URI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ public void authzCodeFlowScopeFilteringByAccountWorks() throws Exception {
.getRequest()
.getSession();

session = (MockHttpSession) mvc.perform(get("/authorize").session(session))
mvc.perform(get("/authorize").session(session)
.param("scope", "openid profile read-tasks")
.param("response_type", "code")
.param("client_id", clientId)
.param("redirect_uri", "https://iam.local.io/iam-test-client/openid_connect_login")
.param("state", "1234567"))
.andExpect(status().isOk())
.andExpect(forwardedUrl("/oauth/confirm_access"))
.andExpect(model().attribute("scope", equalTo("openid profile")))
Expand Down Expand Up @@ -207,7 +212,12 @@ public void matchingPolicyFilteringWorks() throws Exception {
.getRequest()
.getSession();

session = (MockHttpSession) mvc.perform(get("/authorize").session(session))
session = (MockHttpSession) mvc.perform(get("/authorize").session(session)
.param("scope", "openid profile read:/ read:/that/thing write:/")
.param("response_type", "code")
.param("client_id", clientId)
.param("redirect_uri", "https://iam.local.io/iam-test-client/openid_connect_login")
.param("state", "1234567"))
.andExpect(status().isOk())
.andExpect(forwardedUrl("/oauth/confirm_access"))
.andExpect(model().attribute("scope", equalTo("openid profile")))
Expand Down

0 comments on commit 47c7246

Please sign in to comment.