use of org.keycloak.representations.idm.ClientInitialAccessPresentation 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());
}
}
use of org.keycloak.representations.idm.ClientInitialAccessPresentation 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());
}
}
use of org.keycloak.representations.idm.ClientInitialAccessPresentation 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));
}
use of org.keycloak.representations.idm.ClientInitialAccessPresentation 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));
}
use of org.keycloak.representations.idm.ClientInitialAccessPresentation 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());
}
Aggregations