use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method testClientWithRefreshToken.
@Test
public void testClientWithRefreshToken() throws Exception {
OIDCClientRepresentation clientRep = null;
OIDCClientRepresentation response = null;
clientRep = createRep();
clientRep.setGrantTypes(Arrays.asList(OAuth2Constants.AUTHORIZATION_CODE, OAuth2Constants.REFRESH_TOKEN));
response = reg.oidc().create(clientRep);
// Test Keycloak representation
ClientRepresentation kcClient = getClient(response.getClientId());
OIDCAdvancedConfigWrapper config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertTrue(config.isUseRefreshToken());
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method createPublicClient.
@Test
public void createPublicClient() throws ClientRegistrationException {
OIDCClientRepresentation clientRep = createRep();
clientRep.setTokenEndpointAuthMethod("none");
OIDCClientRepresentation response = reg.oidc().create(clientRep);
Assert.assertEquals("none", response.getTokenEndpointAuthMethod());
String clientId = response.getClientId();
ClientRepresentation kcClientRep = getKeycloakClient(clientId);
Assert.assertTrue(kcClientRep.isPublicClient());
Assert.assertNull(kcClientRep.getSecret());
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method getClient.
@Test
public void getClient() throws ClientRegistrationException {
OIDCClientRepresentation response = create();
reg.auth(Auth.token(response));
OIDCClientRepresentation rep = reg.oidc().get(response.getClientId());
assertNotNull(rep);
assertEquals(response.getRegistrationAccessToken(), rep.getRegistrationAccessToken());
assertTrue(CollectionUtil.collectionEquals(Arrays.asList("code", "none"), response.getResponseTypes()));
assertTrue(CollectionUtil.collectionEquals(Arrays.asList(OAuth2Constants.AUTHORIZATION_CODE, OAuth2Constants.REFRESH_TOKEN), response.getGrantTypes()));
assertNotNull(response.getClientSecret());
assertEquals(0, response.getClientSecretExpiresAt().intValue());
assertEquals(OIDCLoginProtocol.CLIENT_SECRET_BASIC, response.getTokenEndpointAuthMethod());
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method deleteClient.
@Test
public void deleteClient() throws ClientRegistrationException {
OIDCClientRepresentation response = create();
reg.auth(Auth.token(response));
reg.oidc().delete(response);
}
use of org.keycloak.representations.oidc.OIDCClientRepresentation in project keycloak by keycloak.
the class OIDCClientRegistrationTest method testAuthorizationEncryptedResponse.
@Test
public void testAuthorizationEncryptedResponse() throws Exception {
OIDCClientRepresentation response = null;
OIDCClientRepresentation updated = null;
try {
OIDCClientRepresentation clientRep = createRep();
clientRep.setAuthorizationEncryptedResponseAlg(JWEConstants.RSA1_5);
clientRep.setAuthorizationEncryptedResponseEnc(JWEConstants.A128CBC_HS256);
// create
response = reg.oidc().create(clientRep);
Assert.assertEquals(JWEConstants.RSA1_5, response.getAuthorizationEncryptedResponseAlg());
Assert.assertEquals(JWEConstants.A128CBC_HS256, response.getAuthorizationEncryptedResponseEnc());
// Test Keycloak representation
ClientRepresentation kcClient = getClient(response.getClientId());
OIDCAdvancedConfigWrapper config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertEquals(JWEConstants.RSA1_5, config.getAuthorizationEncryptedResponseAlg());
Assert.assertEquals(JWEConstants.A128CBC_HS256, config.getAuthorizationEncryptedResponseEnc());
// update
reg.auth(Auth.token(response));
response.setAuthorizationEncryptedResponseAlg(null);
response.setAuthorizationEncryptedResponseEnc(null);
updated = reg.oidc().update(response);
Assert.assertNull(updated.getAuthorizationEncryptedResponseAlg());
Assert.assertNull(updated.getAuthorizationEncryptedResponseEnc());
// Test Keycloak representation
kcClient = getClient(updated.getClientId());
config = OIDCAdvancedConfigWrapper.fromClientRepresentation(kcClient);
Assert.assertNull(config.getAuthorizationEncryptedResponseAlg());
Assert.assertNull(config.getAuthorizationEncryptedResponseEnc());
} finally {
// revert
reg.auth(Auth.token(updated));
updated.setAuthorizationEncryptedResponseAlg(null);
updated.setAuthorizationEncryptedResponseEnc(null);
reg.oidc().update(updated);
}
}
Aggregations