Search in sources :

Example 21 with ParResponse

use of org.keycloak.testsuite.util.OAuthClient.ParResponse in project keycloak by keycloak.

the class ParTest method testFailureParIncludesInvalidResponseType.

// PAR including invalid response_type
@Test
public void testFailureParIncludesInvalidResponseType() throws Exception {
    // create client dynamically
    String clientId = createClientDynamically(generateSuffixedName(CLIENT_NAME), (OIDCClientRepresentation clientRep) -> {
        clientRep.setRequirePushedAuthorizationRequests(Boolean.FALSE);
        clientRep.setRedirectUris(new ArrayList<String>(Arrays.asList(CLIENT_REDIRECT_URI)));
    });
    OIDCClientRepresentation oidcCRep = getClientDynamically(clientId);
    String clientSecret = oidcCRep.getClientSecret();
    assertEquals(Boolean.FALSE, oidcCRep.getRequirePushedAuthorizationRequests());
    assertTrue(oidcCRep.getRedirectUris().contains(CLIENT_REDIRECT_URI));
    // Pushed Authorization Request
    oauth.clientId(clientId);
    oauth.redirectUri(CLIENT_REDIRECT_URI);
    oauth.responseType(null);
    ParResponse pResp = oauth.doPushedAuthorizationRequest(clientId, clientSecret);
    assertEquals(400, pResp.getStatusCode());
    assertEquals(OAuthErrorException.INVALID_REQUEST, pResp.getError());
    assertEquals("Missing parameter: response_type", pResp.getErrorDescription());
}
Also used : ParResponse(org.keycloak.testsuite.util.OAuthClient.ParResponse) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) AbstractClientPoliciesTest(org.keycloak.testsuite.client.AbstractClientPoliciesTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 OIDCClientRepresentation (org.keycloak.representations.oidc.OIDCClientRepresentation)21 AbstractClientPoliciesTest (org.keycloak.testsuite.client.AbstractClientPoliciesTest)21 ParResponse (org.keycloak.testsuite.util.OAuthClient.ParResponse)21 OAuthClient (org.keycloak.testsuite.util.OAuthClient)10 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)8 ClientResource (org.keycloak.admin.client.resource.ClientResource)5 UriBuilder (javax.ws.rs.core.UriBuilder)4 TestOIDCEndpointsApplicationResource (org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource)4 TestingOIDCEndpointsApplicationResource (org.keycloak.testsuite.rest.resource.TestingOIDCEndpointsApplicationResource)4 AccessToken (org.keycloak.representations.AccessToken)3 IDToken (org.keycloak.representations.IDToken)3 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 RefreshToken (org.keycloak.representations.RefreshToken)1 ClientPoliciesBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientPoliciesBuilder)1 ClientPolicyBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientPolicyBuilder)1 ClientProfileBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientProfileBuilder)1 ClientProfilesBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientProfilesBuilder)1