From 77dbe0151c11023d3d4f4d93316809f9158e1f4b Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Fri, 7 Jun 2024 14:04:38 +0200 Subject: [PATCH] Diversified tests state decoding --- .../java/oidc/endpoints/AuthorizationEndpointTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/test/java/oidc/endpoints/AuthorizationEndpointTest.java b/src/test/java/oidc/endpoints/AuthorizationEndpointTest.java index 6c4f1b0e..7b8d651b 100644 --- a/src/test/java/oidc/endpoints/AuthorizationEndpointTest.java +++ b/src/test/java/oidc/endpoints/AuthorizationEndpointTest.java @@ -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 fragmentParameters = fragmentToMap(fragment); assertFalse(fragmentParameters.containsKey("id_token")); - assertEquals(state, fragmentParameters.get("state")); + assertEquals("https://example.com", fragmentParameters.get("state")); } @Test @@ -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 queryParameters = UriComponentsBuilder.fromUriString(url).build().getQueryParams().toSingleValueMap(); - assertEquals(state, queryParameters.get("state")); + assertEquals("https://example.com", queryParameters.get("state")); assertImplicitFlowResponse(queryParameters); }