Another test
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/62130bce Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/62130bce Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/62130bce Branch: refs/heads/master-jaxrs-2.1 Commit: 62130bce80cd5615bfd5e901a35beba50c10be69 Parents: be273b0 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Wed May 18 17:04:49 2016 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Wed May 18 17:04:49 2016 +0100 ---------------------------------------------------------------------- .../jaxrs/security/oidc/OIDCFlowTest.java | 1 - .../jaxrs/security/oidc/OIDCNegativeTest.java | 54 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/62130bce/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java index 16a37ec..d4ebb9c 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCFlowTest.java @@ -480,7 +480,6 @@ public class OIDCFlowTest extends AbstractBusClientServerTestBase { // JwsJwtCompactConsumer jwtConsumer = new JwsJwtCompactConsumer(idToken); // JwtToken jwt = jwtConsumer.getJwtToken(); // TODO Assert.assertNotNull(jwt.getClaims().getClaim(IdToken.AUTH_CODE_HASH_CLAIM)); - // TODO Assert.assertNull(jwt.getClaims().getClaim(IdToken.ACCESS_TOKEN_HASH_CLAIM)); } @org.junit.Test http://git-wip-us.apache.org/repos/asf/cxf/blob/62130bce/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java ---------------------------------------------------------------------- diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java index ce3dd30..3f5d247 100644 --- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java +++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oidc/OIDCNegativeTest.java @@ -181,6 +181,60 @@ public class OIDCNegativeTest extends AbstractBusClientServerTestBase { } @org.junit.Test + public void testImplicitFlowNoATHash() throws Exception { + URL busFile = OIDCFlowTest.class.getResource("client.xml"); + + String address = "https://localhost:" + PORT + "/services/"; + WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(), + "alice", "security", busFile.toString()); + // Save the Cookie for the second request... + WebClient.getConfig(client).getRequestContext().put( + org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE); + + // Get Access Token + client.type("application/json").accept("application/json"); + client.query("client_id", "consumer-id"); + client.query("redirect_uri", "http://www.blah.apache.org"); + client.query("scope", "openid"); + client.query("response_type", "id_token"); + client.query("nonce", "1234565635"); + client.query("max_age", "300"); + client.path("authorize-implicit/"); + Response response = client.get(); + + OAuthAuthorizationData authzData = response.readEntity(OAuthAuthorizationData.class); + + // Now call "decision" to get the access token + client.path("decision"); + client.type("application/x-www-form-urlencoded"); + + Form form = new Form(); + form.param("session_authenticity_token", authzData.getAuthenticityToken()); + form.param("client_id", authzData.getClientId()); + form.param("redirect_uri", authzData.getRedirectUri()); + form.param("scope", authzData.getProposedScope()); + if (authzData.getResponseType() != null) { + form.param("response_type", authzData.getResponseType()); + } + if (authzData.getNonce() != null) { + form.param("nonce", authzData.getNonce()); + } + form.param("oauthDecision", "allow"); + + response = client.post(form); + + String location = response.getHeaderString("Location"); + + // Check IdToken + String idToken = OAuth2TestUtils.getSubstring(location, "id_token"); + assertNotNull(idToken); + + JwsJwtCompactConsumer jwtConsumer = new JwsJwtCompactConsumer(idToken); + JwtToken jwt = jwtConsumer.getJwtToken(); + Assert.assertNull(jwt.getClaims().getClaim(IdToken.ACCESS_TOKEN_HASH_CLAIM)); + } + + @org.junit.Test public void testJWTRequestNonmatchingResponseType() throws Exception { URL busFile = OIDCNegativeTest.class.getResource("client.xml");