Search in sources :

Example 86 with ClientRepresentation

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);
}
Also used : RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation)

Example 87 with ClientRepresentation

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));
    }
}
Also used : Response(javax.ws.rs.core.Response) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ByteArrayInputStream(java.io.ByteArrayInputStream) ClientResource(org.keycloak.admin.client.resource.ClientResource) WebTarget(javax.ws.rs.client.WebTarget) EntityDescriptorType(org.keycloak.dom.saml.v2.metadata.EntityDescriptorType) SamlClient(org.keycloak.testsuite.util.SamlClient) Client(javax.ws.rs.client.Client) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) AbstractSamlTest(org.keycloak.testsuite.saml.AbstractSamlTest) Test(org.junit.Test)

Example 88 with ClientRepresentation

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);
}
Also used : ClientResource(org.keycloak.admin.client.resource.ClientResource) Matchers.containsString(org.hamcrest.Matchers.containsString) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Test(org.junit.Test) AbstractServletsAdapterTest(org.keycloak.testsuite.adapter.AbstractServletsAdapterTest)

Example 89 with ClientRepresentation

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());
}
Also used : ClientsResource(org.keycloak.admin.client.resource.ClientsResource) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation)

Example 90 with ClientRepresentation

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());
}
Also used : ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) Test(org.junit.Test)

Aggregations

ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)576 Test (org.junit.Test)359 ClientResource (org.keycloak.admin.client.resource.ClientResource)189 OIDCClientRepresentation (org.keycloak.representations.oidc.OIDCClientRepresentation)139 OAuthClient (org.keycloak.testsuite.util.OAuthClient)101 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)61 Response (javax.ws.rs.core.Response)59 Matchers.containsString (org.hamcrest.Matchers.containsString)58 RealmResource (org.keycloak.admin.client.resource.RealmResource)58 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)58 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)53 RoleRepresentation (org.keycloak.representations.idm.RoleRepresentation)43 AuthenticationRequestAcknowledgement (org.keycloak.testsuite.util.OAuthClient.AuthenticationRequestAcknowledgement)41 ClientsResource (org.keycloak.admin.client.resource.ClientsResource)38 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)38 ClientPoliciesBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientPoliciesBuilder)37 ClientPolicyBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientPolicyBuilder)37 ClientProfileBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientProfileBuilder)37 ClientProfilesBuilder (org.keycloak.testsuite.util.ClientPoliciesUtil.ClientProfilesBuilder)37 HashMap (java.util.HashMap)33