Search in sources :

Example 21 with TestOIDCEndpointsApplicationResource

use of org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource in project keycloak by keycloak.

the class ClientPoliciesTest method signRequestObject.

private String signRequestObject(AuthorizationEndpointRequestObject requestObject) throws IOException {
    byte[] contentBytes = JsonSerialization.writeValueAsBytes(requestObject);
    String encodedRequestObject = Base64Url.encode(contentBytes);
    TestOIDCEndpointsApplicationResource client = testingClient.testApp().oidcClientEndpoints();
    // use and set jwks_url
    ClientResource clientResource = ApiUtil.findClientByClientId(adminClient.realm(oauth.getRealm()), oauth.getClientId());
    ClientRepresentation clientRep = clientResource.toRepresentation();
    OIDCAdvancedConfigWrapper.fromClientRepresentation(clientRep).setUseJwksUrl(true);
    OIDCAdvancedConfigWrapper.fromClientRepresentation(clientRep).setJwksUrl(TestApplicationResourceUrls.clientJwksUri());
    clientResource.update(clientRep);
    client.generateKeys(org.keycloak.crypto.Algorithm.PS256);
    client.registerOIDCRequest(encodedRequestObject, org.keycloak.crypto.Algorithm.PS256);
    // do not send any other parameter but the request request parameter
    String oidcRequest = client.getOIDCRequest();
    return oidcRequest;
}
Also used : TestOIDCEndpointsApplicationResource(org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource) ClientResource(org.keycloak.admin.client.resource.ClientResource) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation)

Example 22 with TestOIDCEndpointsApplicationResource

use of org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource in project keycloak by keycloak.

the class OIDCPairwiseClientRegistrationTest method updateSectorIdentifierUri.

@Test
public void updateSectorIdentifierUri() throws Exception {
    OIDCClientRepresentation clientRep = createRep();
    clientRep.setSubjectType("pairwise");
    OIDCClientRepresentation response = reg.oidc().create(clientRep);
    Assert.assertEquals("pairwise", response.getSubjectType());
    Assert.assertNull(response.getSectorIdentifierUri());
    reg.auth(Auth.token(response));
    // Push redirect uris to the sector identifier URI
    List<String> sectorRedirects = new ArrayList<>();
    sectorRedirects.addAll(response.getRedirectUris());
    TestOIDCEndpointsApplicationResource oidcClientEndpointsResource = testingClient.testApp().oidcClientEndpoints();
    oidcClientEndpointsResource.setSectorIdentifierRedirectUris(sectorRedirects);
    response.setSectorIdentifierUri(TestApplicationResourceUrls.pairwiseSectorIdentifierUri());
    OIDCClientRepresentation updated = reg.oidc().update(response);
    Assert.assertEquals("pairwise", updated.getSubjectType());
    Assert.assertEquals(TestApplicationResourceUrls.pairwiseSectorIdentifierUri(), updated.getSectorIdentifierUri());
}
Also used : TestOIDCEndpointsApplicationResource(org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with TestOIDCEndpointsApplicationResource

use of org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource in project keycloak by keycloak.

the class OIDCPairwiseClientRegistrationTest method createPairwiseClientWithSectorIdentifierURIContainingMismatchedRedirectsPublicSubject.

@Test
public void createPairwiseClientWithSectorIdentifierURIContainingMismatchedRedirectsPublicSubject() throws Exception {
    OIDCClientRepresentation clientRep = createRep();
    // Push redirect uris to the sector identifier URI
    List<String> sectorRedirects = new ArrayList<>();
    sectorRedirects.add("http://someotherredirect");
    TestOIDCEndpointsApplicationResource oidcClientEndpointsResource = testingClient.testApp().oidcClientEndpoints();
    oidcClientEndpointsResource.setSectorIdentifierRedirectUris(sectorRedirects);
    clientRep.setSubjectType("public");
    clientRep.setSectorIdentifierUri(TestApplicationResourceUrls.pairwiseSectorIdentifierUri());
    assertCreateFail(clientRep, 400, "Client redirect URIs does not match redirect URIs fetched from the Sector Identifier URI.");
}
Also used : TestOIDCEndpointsApplicationResource(org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 24 with TestOIDCEndpointsApplicationResource

use of org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource in project keycloak by keycloak.

the class OIDCPairwiseClientRegistrationTest method createPairwiseClientWithSectorIdentifierURIContainingMismatchedRedirects.

@Test
public void createPairwiseClientWithSectorIdentifierURIContainingMismatchedRedirects() throws Exception {
    OIDCClientRepresentation clientRep = createRep();
    // Push redirect uris to the sector identifier URI
    List<String> sectorRedirects = new ArrayList<>();
    sectorRedirects.add("http://someotherredirect");
    TestOIDCEndpointsApplicationResource oidcClientEndpointsResource = testingClient.testApp().oidcClientEndpoints();
    oidcClientEndpointsResource.setSectorIdentifierRedirectUris(sectorRedirects);
    clientRep.setSubjectType("pairwise");
    clientRep.setSectorIdentifierUri(TestApplicationResourceUrls.pairwiseSectorIdentifierUri());
    assertCreateFail(clientRep, 400, "Client redirect URIs does not match redirect URIs fetched from the Sector Identifier URI.");
}
Also used : TestOIDCEndpointsApplicationResource(org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 25 with TestOIDCEndpointsApplicationResource

use of org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource in project keycloak by keycloak.

the class OIDCPairwiseClientRegistrationTest method createPairwiseClientWithSectorIdentifierURI.

@Test
public void createPairwiseClientWithSectorIdentifierURI() throws Exception {
    OIDCClientRepresentation clientRep = createRep();
    // Push redirect uris to the sector identifier URI
    List<String> sectorRedirects = new ArrayList<>();
    sectorRedirects.addAll(clientRep.getRedirectUris());
    TestOIDCEndpointsApplicationResource oidcClientEndpointsResource = testingClient.testApp().oidcClientEndpoints();
    oidcClientEndpointsResource.setSectorIdentifierRedirectUris(sectorRedirects);
    clientRep.setSubjectType("pairwise");
    clientRep.setSectorIdentifierUri(TestApplicationResourceUrls.pairwiseSectorIdentifierUri());
    OIDCClientRepresentation response = reg.oidc().create(clientRep);
    Assert.assertEquals("pairwise", response.getSubjectType());
    Assert.assertEquals(TestApplicationResourceUrls.pairwiseSectorIdentifierUri(), response.getSectorIdentifierUri());
}
Also used : TestOIDCEndpointsApplicationResource(org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource) OIDCClientRepresentation(org.keycloak.representations.oidc.OIDCClientRepresentation) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

TestOIDCEndpointsApplicationResource (org.keycloak.testsuite.client.resources.TestOIDCEndpointsApplicationResource)48 Test (org.junit.Test)33 ClientResource (org.keycloak.admin.client.resource.ClientResource)28 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)27 OIDCClientRepresentation (org.keycloak.representations.oidc.OIDCClientRepresentation)22 OAuthClient (org.keycloak.testsuite.util.OAuthClient)21 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)14 AbstractAdminTest (org.keycloak.testsuite.admin.AbstractAdminTest)13 KeyPair (java.security.KeyPair)6 ArrayList (java.util.ArrayList)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 TestingOIDCEndpointsApplicationResource (org.keycloak.testsuite.rest.resource.TestingOIDCEndpointsApplicationResource)6 PrivateKey (java.security.PrivateKey)5 TestAuthenticationChannelRequest (org.keycloak.testsuite.rest.representation.TestAuthenticationChannelRequest)5 JSONWebKeySet (org.keycloak.jose.jwk.JSONWebKeySet)4 IDToken (org.keycloak.representations.IDToken)4 AbstractClientPoliciesTest (org.keycloak.testsuite.client.AbstractClientPoliciesTest)4 ParResponse (org.keycloak.testsuite.util.OAuthClient.ParResponse)4 PublicKey (java.security.PublicKey)3 AuthenticationRequestAcknowledgement (org.keycloak.testsuite.util.OAuthClient.AuthenticationRequestAcknowledgement)3