use of org.keycloak.representations.idm.ClientRepresentation in project keycloak by keycloak.
the class ClientInitiatedAccountLinkTest method addAdapterTestRealms.
@Override
public void addAdapterTestRealms(List<RealmRepresentation> testRealms) {
RealmRepresentation realm = new RealmRepresentation();
realm.setRealm(CHILD_IDP);
realm.setEnabled(true);
ClientRepresentation servlet = new ClientRepresentation();
servlet.setClientId("client-linking");
servlet.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
String uri = "/client-linking";
servlet.setAdminUrl(uri);
servlet.setDirectAccessGrantsEnabled(true);
servlet.setBaseUrl(uri);
servlet.setRedirectUris(new LinkedList<>());
servlet.getRedirectUris().add(uri + "/*");
servlet.setSecret("password");
servlet.setFullScopeAllowed(true);
realm.setClients(new LinkedList<>());
realm.getClients().add(servlet);
testRealms.add(realm);
realm = new RealmRepresentation();
realm.setRealm(PARENT_IDP);
realm.setEnabled(true);
testRealms.add(realm);
}
use of org.keycloak.representations.idm.ClientRepresentation in project keycloak by keycloak.
the class SAMLServletAdapterTest method spMetadataValidation.
@Test
public void spMetadataValidation() throws Exception {
ClientResource clientResource = ApiUtil.findClientResourceByClientId(testRealmResource(), AbstractSamlTest.SAML_CLIENT_ID_SALES_POST_SIG);
ClientRepresentation representation = clientResource.toRepresentation();
Client client = AdminClientUtil.createResteasyClient();
WebTarget target = client.target(authServerPage.toString() + "/admin/realms/" + SAMLSERVLETDEMO + "/clients/" + representation.getId() + "/installation/providers/saml-sp-descriptor");
try (Response response = target.request().header(HttpHeaders.AUTHORIZATION, "Bearer " + adminClient.tokenManager().getAccessToken().getToken()).get()) {
String stringResponse = response.readEntity(String.class);
validateXMLWithSchema(stringResponse, "/adapter-test/keycloak-saml/metadata-schema/saml-schema-metadata-2.0.xsd");
Object descriptor = SAMLParser.getInstance().parse(new ByteArrayInputStream(stringResponse.getBytes(GeneralConstants.SAML_CHARSET)));
assertThat(descriptor, instanceOf(EntityDescriptorType.class));
}
}
use of org.keycloak.representations.idm.ClientRepresentation in project keycloak by keycloak.
the class DemoServletsAdapterTest method testClientNotAuthenticatedInClientSecretJwtBySharedSecretOutOfSync.
@Test
public void testClientNotAuthenticatedInClientSecretJwtBySharedSecretOutOfSync() {
// JWS Client Assertion in client_secret_jwt
// http://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication
String targetClientId = "client-secret-jwt-secure-portal";
String expectedErrorString = "invalid_client_credentials";
ClientResource clientResource = ApiUtil.findClientResourceByClientId(testRealmResource(), targetClientId);
ClientRepresentation client = clientResource.toRepresentation();
client.setSecret("passwordChanged");
clientResource.update(client);
expectResultOfClientNotAuthenticatedInClientSecretJwt(targetClientId, expectedErrorString);
}
use of org.keycloak.representations.idm.ClientRepresentation in project keycloak by keycloak.
the class AbstractServletPolicyEnforcerTest method getClientResource.
private ClientResource getClientResource(String clientId) {
ClientsResource clients = this.realmsResouce().realm(REALM_NAME).clients();
ClientRepresentation resourceServer = clients.findByClientId(clientId).get(0);
return clients.get(resourceServer.getId());
}
use of org.keycloak.representations.idm.ClientRepresentation in project keycloak by keycloak.
the class AppInitiatedActionUpdateProfileTest method updateProfileExpiredCookies.
@Test
public void updateProfileExpiredCookies() {
doAIA();
loginPage.login("john-doh@localhost", "password");
updateProfilePage.assertCurrent();
// Expire cookies and assert the page with "back to application" link present
driver.manage().deleteAllCookies();
updateProfilePage.update("New first", "New last", "keycloak-user@localhost", "test-user@localhost");
errorPage.assertCurrent();
String backToAppLink = errorPage.getBackToApplicationLink();
ClientRepresentation client = ApiUtil.findClientByClientId(adminClient.realm("test"), "test-app").toRepresentation();
Assert.assertEquals(backToAppLink, client.getBaseUrl());
}
Aggregations