Search in sources :

Example 1 with KeycloakQuarkusServerDeployableContainer

use of org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer in project keycloak by keycloak.

the class ClientSearchTest method configureSearchableAttributes.

void configureSearchableAttributes(String... searchableAttributes) throws Exception {
    log.infov("Configuring searchableAttributes");
    if (suiteContext.getAuthServerInfo().isUndertow()) {
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        System.setProperty(SEARCHABLE_ATTRS_PROP, String.join(",", searchableAttributes));
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
        searchableAttributes = Arrays.stream(searchableAttributes).map(a -> a.replace("\"", "\\\\\\\"")).toArray(String[]::new);
        String s = "\\\"" + String.join("\\\",\\\"", searchableAttributes) + "\\\"";
        executeCli("/subsystem=keycloak-server/spi=client:add()", "/subsystem=keycloak-server/spi=client/provider=jpa/:add(properties={searchableAttributes => \"[" + s + "]\"},enabled=true)");
    } else if (suiteContext.getAuthServerInfo().isQuarkus()) {
        searchableAttributes = Arrays.stream(searchableAttributes).map(a -> a.replace(" ", "\\ ").replace("\"", "\\\\\\\"")).toArray(String[]::new);
        String s = String.join(",", searchableAttributes);
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer) suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
        container.setAdditionalBuildArgs(Collections.singletonList("--spi-client-jpa-searchable-attributes=\"" + s + "\""));
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else {
        throw new RuntimeException("Don't know how to config");
    }
    reconnectAdminClient();
}
Also used : OnlineManagementClient(org.wildfly.extras.creaper.core.online.OnlineManagementClient) Arrays(java.util.Arrays) AuthServerContainerExclude(org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude) ClientProvider(org.keycloak.models.ClientProvider) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Test(org.junit.Test) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) AuthServerTestEnricher(org.keycloak.testsuite.arquillian.AuthServerTestEnricher) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) REMOTE(org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE) Administration(org.wildfly.extras.creaper.core.online.operations.admin.Administration) After(org.junit.After) ArquillianResource(org.jboss.arquillian.test.api.ArquillianResource) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ContainerController(org.jboss.arquillian.container.test.api.ContainerController) KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer) Collections(java.util.Collections) Before(org.junit.Before) KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)

Example 2 with KeycloakQuarkusServerDeployableContainer

use of org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer in project keycloak by keycloak.

the class ClientSearchTest method resetSearchableAttributes.

void resetSearchableAttributes() throws Exception {
    log.info("Reset searchableAttributes");
    if (suiteContext.getAuthServerInfo().isUndertow()) {
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        System.clearProperty(SEARCHABLE_ATTRS_PROP);
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
        executeCli("/subsystem=keycloak-server/spi=client:remove");
    } else if (suiteContext.getAuthServerInfo().isQuarkus()) {
        KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer) suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
        container.setAdditionalBuildArgs(Collections.emptyList());
        container.restartServer();
    } else {
        throw new RuntimeException("Don't know how to config");
    }
    reconnectAdminClient();
}
Also used : KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)

Example 3 with KeycloakQuarkusServerDeployableContainer

use of org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer in project keycloak by keycloak.

the class AbstractHostnameTest method reset.

void reset() throws Exception {
    LOGGER.info("Reset hostname config to default");
    if (suiteContext.getAuthServerInfo().isUndertow()) {
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        removeProperties("keycloak.hostname.provider", "keycloak.frontendUrl", "keycloak.adminUrl", "keycloak.hostname.default.forceBackendUrlToFrontendUrl", "keycloak.hostname.fixed.hostname", "keycloak.hostname.fixed.httpPort", "keycloak.hostname.fixed.httpsPort", "keycloak.hostname.fixed.alwaysHttps");
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
        executeCli("/subsystem=keycloak-server/spi=hostname:remove", "/subsystem=keycloak-server/spi=hostname/:add(default-provider=default)", "/subsystem=keycloak-server/spi=hostname/provider=default/:add(properties={frontendUrl => \"${keycloak.frontendUrl:}\",forceBackendUrlToFrontendUrl => \"false\"},enabled=true)");
    } else if (suiteContext.getAuthServerInfo().isQuarkus()) {
        KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer) suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
        container.resetConfiguration();
        configureDefault(OAuthClient.AUTH_SERVER_ROOT, false, null);
        container.restartServer();
    } else {
        throw new RuntimeException("Don't know how to config");
    }
    reconnectAdminClient();
}
Also used : KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)

Example 4 with KeycloakQuarkusServerDeployableContainer

use of org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer in project keycloak by keycloak.

the class AbstractHostnameTest method configureDefault.

void configureDefault(String frontendUrl, boolean forceBackendUrlToFrontendUrl, String adminUrl) throws Exception {
    LOGGER.infov("Configuring default hostname provider: frontendUrl={0}, forceBackendUrlToFrontendUrl={1}, adminUrl={3}", frontendUrl, forceBackendUrlToFrontendUrl, adminUrl);
    if (suiteContext.getAuthServerInfo().isUndertow()) {
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        System.setProperty("keycloak.hostname.provider", "default");
        System.setProperty("keycloak.frontendUrl", frontendUrl);
        if (adminUrl != null) {
            System.setProperty("keycloak.adminUrl", adminUrl);
        }
        System.setProperty("keycloak.hostname.default.forceBackendUrlToFrontendUrl", String.valueOf(forceBackendUrlToFrontendUrl));
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else if (suiteContext.getAuthServerInfo().isJBossBased()) {
        executeCli("/subsystem=keycloak-server/spi=hostname:remove", "/subsystem=keycloak-server/spi=hostname/:add(default-provider=default)", "/subsystem=keycloak-server/spi=hostname/provider=default/:add(properties={" + "frontendUrl => \"" + frontendUrl + "\"" + ",forceBackendUrlToFrontendUrl => \"" + forceBackendUrlToFrontendUrl + "\"" + (adminUrl != null ? ",adminUrl=\"" + adminUrl + "\"" : "") + "},enabled=true)");
    } else if (suiteContext.getAuthServerInfo().isQuarkus()) {
        controller.stop(suiteContext.getAuthServerInfo().getQualifier());
        KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer) suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
        List<String> additionalArgs = new ArrayList<>();
        URI frontendUri = URI.create(frontendUrl);
        // enable proxy so that we can check headers are taken into account when building urls
        additionalArgs.add("--proxy=reencrypt");
        additionalArgs.add("--hostname=" + frontendUri.getHost());
        additionalArgs.add("--hostname-path=" + frontendUri.getPath());
        if ("https".equals(frontendUri.getScheme())) {
            additionalArgs.add("--hostname-strict-https=true");
        }
        additionalArgs.add("--hostname-strict-backchannel=" + forceBackendUrlToFrontendUrl);
        if (adminUrl != null) {
            URI adminUri = URI.create(adminUrl);
            additionalArgs.add("--hostname-admin=" + adminUri.getHost());
        }
        container.setAdditionalBuildArgs(additionalArgs);
        controller.start(suiteContext.getAuthServerInfo().getQualifier());
    } else {
        throw new RuntimeException("Don't know how to config");
    }
    reconnectAdminClient();
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) KeycloakQuarkusServerDeployableContainer(org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)

Aggregations

KeycloakQuarkusServerDeployableContainer (org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer)4 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 ContainerController (org.jboss.arquillian.container.test.api.ContainerController)1 ArquillianResource (org.jboss.arquillian.test.api.ArquillianResource)1 After (org.junit.After)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ClientProvider (org.keycloak.models.ClientProvider)1 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)1 AuthServerTestEnricher (org.keycloak.testsuite.arquillian.AuthServerTestEnricher)1 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)1