Search in sources :

Example 11 with ClientInitialAccessCreatePresentation

use of org.keycloak.representations.idm.ClientInitialAccessCreatePresentation in project keycloak by keycloak.

the class SAMLClientRegistrationTest method before.

@Before
public void before() throws Exception {
    super.before();
    ClientInitialAccessPresentation token = adminClient.realm(REALM_NAME).clientInitialAccess().create(new ClientInitialAccessCreatePresentation(0, 10));
    reg.auth(Auth.token(token));
}
Also used : ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) Before(org.junit.Before)

Example 12 with ClientInitialAccessCreatePresentation

use of org.keycloak.representations.idm.ClientInitialAccessCreatePresentation in project keycloak by keycloak.

the class AbstractClientPoliciesTest method restartAuthenticatedClientRegistrationSetting.

// Registration/Initial Access Token acquisition for Dynamic Client Registration
protected void restartAuthenticatedClientRegistrationSetting() throws ClientRegistrationException {
    reg.close();
    reg = ClientRegistration.create().url(suiteContext.getAuthServerInfo().getContextRoot() + "/auth", REALM_NAME).build();
    ClientInitialAccessPresentation token = adminClient.realm(REALM_NAME).clientInitialAccess().create(new ClientInitialAccessCreatePresentation(0, 10));
    reg.auth(Auth.token(token));
}
Also used : ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation)

Example 13 with ClientInitialAccessCreatePresentation

use of org.keycloak.representations.idm.ClientInitialAccessCreatePresentation in project keycloak by keycloak.

the class InitialAccessTokenTest method create.

@Test
public void create() throws ClientRegistrationException, InterruptedException {
    ClientInitialAccessPresentation response = resource.create(new ClientInitialAccessCreatePresentation());
    reg.auth(Auth.token(response));
    ClientRepresentation rep = new ClientRepresentation();
    setTimeOffset(10);
    ClientRepresentation created = reg.create(rep);
    Assert.assertNotNull(created);
    try {
        reg.create(rep);
        Assert.fail("Expected exception");
    } catch (ClientRegistrationException e) {
        assertEquals(401, ((HttpErrorException) e.getCause()).getStatusLine().getStatusCode());
    }
}
Also used : ClientRegistrationException(org.keycloak.client.registration.ClientRegistrationException) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Test(org.junit.Test)

Example 14 with ClientInitialAccessCreatePresentation

use of org.keycloak.representations.idm.ClientInitialAccessCreatePresentation in project keycloak by keycloak.

the class InitialAccessTokenTest method createExpired.

@Test
public void createExpired() throws ClientRegistrationException, InterruptedException {
    ClientInitialAccessPresentation response = resource.create(new ClientInitialAccessCreatePresentation(1, 1));
    reg.auth(Auth.token(response));
    ClientRepresentation rep = new ClientRepresentation();
    setTimeOffset(10);
    try {
        reg.create(rep);
        Assert.fail("Expected exception");
    } catch (ClientRegistrationException e) {
        assertEquals(401, ((HttpErrorException) e.getCause()).getStatusLine().getStatusCode());
    }
}
Also used : ClientRegistrationException(org.keycloak.client.registration.ClientRegistrationException) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Test(org.junit.Test)

Example 15 with ClientInitialAccessCreatePresentation

use of org.keycloak.representations.idm.ClientInitialAccessCreatePresentation in project keycloak by keycloak.

the class InitialAccessTokenTest method createDeleted.

@Test
public void createDeleted() throws ClientRegistrationException, InterruptedException {
    ClientInitialAccessPresentation response = resource.create(new ClientInitialAccessCreatePresentation());
    reg.auth(Auth.token(response));
    resource.delete(response.getId());
    ClientRepresentation rep = new ClientRepresentation();
    try {
        reg.create(rep);
        Assert.fail("Expected exception");
    } catch (ClientRegistrationException e) {
        assertEquals(401, ((HttpErrorException) e.getCause()).getStatusLine().getStatusCode());
    }
}
Also used : ClientRegistrationException(org.keycloak.client.registration.ClientRegistrationException) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Test(org.junit.Test)

Aggregations

ClientInitialAccessCreatePresentation (org.keycloak.representations.idm.ClientInitialAccessCreatePresentation)20 ClientInitialAccessPresentation (org.keycloak.representations.idm.ClientInitialAccessPresentation)20 Test (org.junit.Test)9 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)9 ClientRegistrationException (org.keycloak.client.registration.ClientRegistrationException)6 Before (org.junit.Before)5 ClientRegistration (org.keycloak.client.registration.ClientRegistration)3 JWSInput (org.keycloak.jose.jws.JWSInput)3 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)3 ClientInitialAccessResource (org.keycloak.admin.client.resource.ClientInitialAccessResource)2 JsonWebToken (org.keycloak.representations.JsonWebToken)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 CoreMatchers.allOf (org.hamcrest.CoreMatchers.allOf)1 Matchers.greaterThanOrEqualTo (org.hamcrest.Matchers.greaterThanOrEqualTo)1 Matchers.lessThanOrEqualTo (org.hamcrest.Matchers.lessThanOrEqualTo)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertThat (org.junit.Assert.assertThat)1