Search in sources :

Example 16 with ClientInitialAccessCreatePresentation

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

the class OIDCClientRegistrationTest 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 17 with ClientInitialAccessCreatePresentation

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

the class OIDCJwksClientRegistrationTest 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 18 with ClientInitialAccessCreatePresentation

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

the class InitialAccessTokenResourceTest method testPeriodicExpiration.

@Test
public void testPeriodicExpiration() throws ClientRegistrationException, InterruptedException {
    ClientInitialAccessPresentation response1 = resource.create(new ClientInitialAccessCreatePresentation(1, 1));
    ClientInitialAccessPresentation response2 = resource.create(new ClientInitialAccessCreatePresentation(1000, 1));
    ClientInitialAccessPresentation response3 = resource.create(new ClientInitialAccessCreatePresentation(1000, 0));
    ClientInitialAccessPresentation response4 = resource.create(new ClientInitialAccessCreatePresentation(0, 1));
    List<ClientInitialAccessPresentation> list = resource.list();
    assertEquals(4, list.size());
    setTimeOffset(10);
    testingClient.testing().removeExpired(REALM_NAME);
    list = resource.list();
    assertEquals(2, list.size());
    List<String> remainingIds = list.stream().map(initialAccessPresentation -> initialAccessPresentation.getId()).collect(Collectors.toList());
    Assert.assertNames(remainingIds, response2.getId(), response4.getId());
    setTimeOffset(2000);
    testingClient.testing().removeExpired(REALM_NAME);
    list = resource.list();
    assertEquals(1, list.size());
    Assert.assertEquals(list.get(0).getId(), response4.getId());
    // Cleanup
    realm.clientInitialAccess().delete(response4.getId());
}
Also used : OperationType(org.keycloak.events.admin.OperationType) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) ClientRegistrationException(org.keycloak.client.registration.ClientRegistrationException) ResourceType(org.keycloak.events.admin.ResourceType) Assert(org.keycloak.testsuite.Assert) AuthServerContainerExclude(org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude) AdminEventPaths(org.keycloak.testsuite.util.AdminEventPaths) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) ClientInitialAccessResource(org.keycloak.admin.client.resource.ClientInitialAccessResource) Collectors(java.util.stream.Collectors) Assert.assertThat(org.junit.Assert.assertThat) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) AuthServer(org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer) Time(org.keycloak.common.util.Time) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation) Test(org.junit.Test)

Example 19 with ClientInitialAccessCreatePresentation

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

the class AbstractRegCliTest method issueInitialAccessToken.

String issueInitialAccessToken(String realm) {
    ClientInitialAccessResource resource = adminClient.realm(realm).clientInitialAccess();
    ClientInitialAccessCreatePresentation rep = new ClientInitialAccessCreatePresentation();
    rep.setCount(10);
    rep.setExpiration(100);
    ClientInitialAccessPresentation response = resource.create(rep);
    String token = response.getToken();
    Assert.assertNotNull("Issued initial access token not null", token);
    return token;
}
Also used : ClientInitialAccessResource(org.keycloak.admin.client.resource.ClientInitialAccessResource) ClientInitialAccessCreatePresentation(org.keycloak.representations.idm.ClientInitialAccessCreatePresentation) ClientInitialAccessPresentation(org.keycloak.representations.idm.ClientInitialAccessPresentation)

Example 20 with ClientInitialAccessCreatePresentation

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

the class AbstractClientPoliciesTest method setInitialAccessTokenForDynamicClientRegistration.

protected void setInitialAccessTokenForDynamicClientRegistration() {
    // get initial access token for Dynamic Client Registration with authentication
    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)

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