[Test framework] Add custom provider dependencies into a Keycloak server (#34621)
* Add custom provider dependencies into a Keycloak server. Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com> Co-authored-by: Simon Vacek <svacek@redhat.com> * Update test-framework/examples/pom.xml Signed-off-by: Stian Thorgersen <stian@redhat.com> --------- Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com> Signed-off-by: Stian Thorgersen <stian@redhat.com> Co-authored-by: Simon Vacek <svacek@redhat.com> Co-authored-by: Stian Thorgersen <stian@redhat.com>
This commit is contained in:
parent
ce454bda47
commit
a8d9a5553f
29 changed files with 323 additions and 84 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -969,7 +969,7 @@ jobs:
|
||||||
uses: ./.github/actions/integration-test-setup
|
uses: ./.github/actions/integration-test-setup
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./mvnw test -f test-framework/pom.xml
|
run: ./mvnw package -f test-framework/pom.xml
|
||||||
|
|
||||||
base-new-integration-tests:
|
base-new-integration-tests:
|
||||||
name: Base IT (new)
|
name: Base IT (new)
|
||||||
|
|
|
@ -63,10 +63,6 @@ public final class Maven {
|
||||||
dependencies.addAll(projectDescriptor.getManagedDependencies());
|
dependencies.addAll(projectDescriptor.getManagedDependencies());
|
||||||
Artifact artifact = resolveArtifact(groupId, artifactId, dependencies);
|
Artifact artifact = resolveArtifact(groupId, artifactId, dependencies);
|
||||||
|
|
||||||
if (artifact == null) {
|
|
||||||
resolveArtifact(groupId, artifactId, projectDescriptor.getManagedDependencies());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (artifact == null) {
|
if (artifact == null) {
|
||||||
artifact = resolveArtifactRecursively(ctx, projectDescriptor, groupId, artifactId);
|
artifact = resolveArtifactRecursively(ctx, projectDescriptor, groupId, artifactId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public abstract class AbstractKeycloakTestServerSupplier implements Supplier<Key
|
||||||
}
|
}
|
||||||
|
|
||||||
KeycloakTestServer server = getServer();
|
KeycloakTestServer server = getServer();
|
||||||
server.start(rawOptions);
|
server.start(rawOptions, serverConfig.dependencies());
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.keycloak.test.framework.server;
|
package org.keycloak.test.framework.server;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
import org.keycloak.it.utils.RawKeycloakDistribution;
|
import org.keycloak.it.utils.RawKeycloakDistribution;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class DistributionKeycloakTestServer implements KeycloakTestServer {
|
public class DistributionKeycloakTestServer implements KeycloakTestServer {
|
||||||
|
|
||||||
|
@ -16,8 +18,13 @@ public class DistributionKeycloakTestServer implements KeycloakTestServer {
|
||||||
private RawKeycloakDistribution keycloak;
|
private RawKeycloakDistribution keycloak;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(List<String> rawOptions) {
|
public void start(List<String> rawOptions, Set<Dependency> dependencies) {
|
||||||
keycloak = new RawKeycloakDistribution(DEBUG, MANUAL_STOP, ENABLE_TLS, RE_CREATE, REMOVE_BUILD_OPTIONS_AFTER_BUILD, REQUEST_PORT);
|
keycloak = new RawKeycloakDistribution(DEBUG, MANUAL_STOP, ENABLE_TLS, RE_CREATE, REMOVE_BUILD_OPTIONS_AFTER_BUILD, REQUEST_PORT);
|
||||||
|
|
||||||
|
for (Dependency dependency : dependencies) {
|
||||||
|
keycloak.copyProvider(dependency.getGroupId(), dependency.getArtifactId());
|
||||||
|
}
|
||||||
|
|
||||||
keycloak.run(rawOptions).assertStartedDevMode();
|
keycloak.run(rawOptions).assertStartedDevMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.keycloak.test.framework.server;
|
package org.keycloak.test.framework.server;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
import org.keycloak.Keycloak;
|
import org.keycloak.Keycloak;
|
||||||
import org.keycloak.common.Version;
|
import org.keycloak.common.Version;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class EmbeddedKeycloakTestServer implements KeycloakTestServer {
|
public class EmbeddedKeycloakTestServer implements KeycloakTestServer {
|
||||||
|
@ -11,10 +13,14 @@ public class EmbeddedKeycloakTestServer implements KeycloakTestServer {
|
||||||
private Keycloak keycloak;
|
private Keycloak keycloak;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(List<String> rawOptions) {
|
public void start(List<String> rawOptions, Set<Dependency> dependencies) {
|
||||||
keycloak = Keycloak.builder()
|
Keycloak.Builder builder = Keycloak.builder().setVersion(Version.VERSION);
|
||||||
.setVersion(Version.VERSION)
|
|
||||||
.start(rawOptions);
|
for(Dependency dependency : dependencies) {
|
||||||
|
builder.addDependency(dependency.getGroupId(), dependency.getArtifactId(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
keycloak = builder.start(rawOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package org.keycloak.test.framework.server;
|
package org.keycloak.test.framework.server;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface KeycloakTestServer {
|
public interface KeycloakTestServer {
|
||||||
|
|
||||||
void start(List<String> rawOptions);
|
void start(List<String> rawOptions, Set<Dependency> dependencies);
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.keycloak.test.framework.server;
|
package org.keycloak.test.framework.server;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -16,4 +18,8 @@ public interface KeycloakTestServerConfig {
|
||||||
|
|
||||||
default boolean enableSysLog() { return false; }
|
default boolean enableSysLog() { return false; }
|
||||||
|
|
||||||
|
default Set<Dependency> dependencies() {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
package org.keycloak.test.framework.server;
|
package org.keycloak.test.framework.server;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class RemoteKeycloakTestServer implements KeycloakTestServer {
|
public class RemoteKeycloakTestServer implements KeycloakTestServer {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(RemoteKeycloakTestServer.class);
|
private static final Logger LOGGER = Logger.getLogger(RemoteKeycloakTestServer.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(List<String> rawOptions) {
|
public void start(List<String> rawOptions, Set<Dependency> dependencies) {
|
||||||
LOGGER.infov("Requested server config: {0}", String.join(" ", rawOptions));
|
LOGGER.infov("Requested server config: {0}", String.join(" ", rawOptions));
|
||||||
|
LOGGER.infov("Requested dependencies: {0}", String.join(" ", dependencies.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,77 +27,13 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>keycloak-test-framework-examples</artifactId>
|
<artifactId>keycloak-test-framework-examples</artifactId>
|
||||||
<name>Keycloak Test Framework Examples</name>
|
<name>Keycloak Test Framework Examples Parent</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>pom</packaging>
|
||||||
<description>Example tests to demonstrate the new testing framework</description>
|
<description>Example tests to demonstrate the new testing framework</description>
|
||||||
|
|
||||||
<dependencyManagement>
|
<modules>
|
||||||
<dependencies>
|
<module>providers</module>
|
||||||
<dependency>
|
<module>tests</module>
|
||||||
<groupId>org.keycloak.test</groupId>
|
</modules>
|
||||||
<artifactId>keycloak-test-framework-bom</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>import</scope>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-db-mariadb</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-db-mssql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-db-mysql</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-db-oracle</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-db-postgres</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.keycloak.test</groupId>
|
|
||||||
<artifactId>keycloak-test-framework-ui</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.logmanager</groupId>
|
|
||||||
<artifactId>jboss-logmanager</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
|
||||||
<java.util.concurrent.ForkJoinPool.common.threadFactory>io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory</java.util.concurrent.ForkJoinPool.common.threadFactory>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
41
test-framework/examples/providers/pom.xml
Normal file
41
test-framework/examples/providers/pom.xml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-test-framework-examples</artifactId>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<version>999.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>keycloak-test-framework-example-providers</artifactId>
|
||||||
|
<name>Keycloak Test Framework Example Providers</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Example providers used for test framework example tests</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-core</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-server-spi</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-server-spi-private</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,39 @@
|
||||||
|
package org.keycloak.providers.example;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
import org.keycloak.services.resource.RealmResourceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:svacek@redhat.com">Simon Vacek</a>
|
||||||
|
*/
|
||||||
|
public class MyCustomRealmResourceProvider implements RealmResourceProvider {
|
||||||
|
|
||||||
|
private final KeycloakSession session;
|
||||||
|
|
||||||
|
public MyCustomRealmResourceProvider(KeycloakSession session) {
|
||||||
|
this.session = session;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getResource() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("hello")
|
||||||
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
public Response hello() {
|
||||||
|
return Response.ok("Hello World!").type(MediaType.TEXT_PLAIN).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package org.keycloak.providers.example;
|
||||||
|
|
||||||
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
|
import org.keycloak.services.resource.RealmResourceProvider;
|
||||||
|
import org.keycloak.services.resource.RealmResourceProviderFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:svacek@redhat.com">Simon Vacek</a>
|
||||||
|
*/
|
||||||
|
public class MyCustomRealmResourceProviderFactory implements RealmResourceProviderFactory {
|
||||||
|
|
||||||
|
public static final String ID = "custom-provider";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RealmResourceProvider create(KeycloakSession session) {
|
||||||
|
return new MyCustomRealmResourceProvider(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(org.keycloak.Config.Scope config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postInit(KeycloakSessionFactory factory) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
org.keycloak.providers.example.MyCustomRealmResourceProviderFactory
|
109
test-framework/examples/tests/pom.xml
Normal file
109
test-framework/examples/tests/pom.xml
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
|
||||||
|
~ and other contributors as indicated by the @author tags.
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-test-framework-examples</artifactId>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<version>999.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>keycloak-test-framework-example-tests</artifactId>
|
||||||
|
<name>Keycloak Test Framework Example Tests</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Example tests to demonstrate the new testing framework</description>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-bom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>import</scope>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-db-mariadb</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-db-mssql</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-db-mysql</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-db-oracle</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-db-postgres</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak.test</groupId>
|
||||||
|
<artifactId>keycloak-test-framework-example-providers</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logmanager</groupId>
|
||||||
|
<artifactId>jboss-logmanager</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
|
<java.util.concurrent.ForkJoinPool.common.threadFactory>io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory</java.util.concurrent.ForkJoinPool.common.threadFactory>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.keycloak.test.examples;
|
||||||
|
|
||||||
|
import io.quarkus.maven.dependency.Dependency;
|
||||||
|
import io.quarkus.maven.dependency.DependencyBuilder;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpUriRequest;
|
||||||
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.keycloak.test.framework.annotations.InjectRealm;
|
||||||
|
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
|
||||||
|
import org.keycloak.test.framework.realm.ManagedRealm;
|
||||||
|
import org.keycloak.test.framework.server.KeycloakTestServerConfig;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:svacek@redhat.com">Simon Vacek</a>
|
||||||
|
*/
|
||||||
|
@KeycloakIntegrationTest(config = MyCustomProviderTest.ServerConfig.class)
|
||||||
|
public class MyCustomProviderTest {
|
||||||
|
|
||||||
|
@InjectRealm
|
||||||
|
ManagedRealm realm;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void httpGetTest() {
|
||||||
|
String url = realm.getBaseUrl();
|
||||||
|
|
||||||
|
HttpUriRequest request = new HttpGet(url + "/custom-provider/hello");
|
||||||
|
try {
|
||||||
|
HttpResponse response = HttpClientBuilder.create().build().execute(request);
|
||||||
|
Assertions.assertEquals(200, response.getStatusLine().getStatusCode());
|
||||||
|
|
||||||
|
String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
|
Assertions.assertEquals("Hello World!", content);
|
||||||
|
} catch (IOException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ServerConfig implements KeycloakTestServerConfig {
|
||||||
|
|
||||||
|
public Set<Dependency> dependencies() {
|
||||||
|
return Set.of(new DependencyBuilder().setGroupId("org.keycloak.test").setArtifactId("keycloak-test-framework-example-providers").build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue