Skip to content

Commit

Permalink
Diversified tests state decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jun 7, 2024
1 parent 1e37b3d commit 77dbe01
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/test/java/oidc/endpoints/AuthorizationEndpointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,13 @@ public void authorizeCodeFlowWithNonce() throws IOException, BadJOSEException, P

@Test
public void oauth2NonOidcImplicitFlow() throws IOException {
String state = "https://example.com";
Response response = doAuthorizeWithClaimsAndScopes("mock-sp", "token",
null, null, null, null, "groups", state);
null, null, null, null, "groups", "https%3A%2F%2Fexample.com");
String url = response.getHeader("Location");
String fragment = url.substring(url.indexOf("#") + 1);
Map<String, String> fragmentParameters = fragmentToMap(fragment);
assertFalse(fragmentParameters.containsKey("id_token"));
assertEquals(state, fragmentParameters.get("state"));
assertEquals("https://example.com", fragmentParameters.get("state"));
}

@Test
Expand Down Expand Up @@ -312,12 +311,11 @@ public void hybridFlowFragment() throws IOException, BadJOSEException, ParseExce

@Test
public void implicitFlowQuery() throws IOException, BadJOSEException, ParseException, JOSEException {
String state = "https://example.com";
Response response = doAuthorizeWithClaimsAndScopes("mock-sp", "id_token token", ResponseMode.QUERY.getValue(), "nonce", null,
Collections.emptyList(), "openid", state);
Collections.emptyList(), "openid", "https%3A%2F%2Fexample.com");
String url = response.getHeader("Location");
Map<String, String> queryParameters = UriComponentsBuilder.fromUriString(url).build().getQueryParams().toSingleValueMap();
assertEquals(state, queryParameters.get("state"));
assertEquals("https://example.com", queryParameters.get("state"));
assertImplicitFlowResponse(queryParameters);
}

Expand Down

0 comments on commit 77dbe01

Please sign in to comment.