8000 fix: making the embedded resteasy server work again · lukebfox/keycloak@ce38c5b · GitHub
[go: up one dir, main page]

Skip to content

Commit ce38c5b

Browse files
shawkinsmposolda
authored andcommitted
fix: making the embedded resteasy server work again
closes: keycloak#49058 Signed-off-by: Steve Hawkins <shawkins@redhat.com>
1 parent f9e2753 commit ce38c5b

4 files changed

Lines changed: 30 additions & 31 deletions

File tree

‎quarkus/runtime/src/main/resources/META-INF/services/org.keycloak.platform.PlatformProvider‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎services/src/test/java/org/keycloak/services/resteasy/ResteasyKeycloakApplication.java‎

Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public class ResteasyKeycloakApplication extends KeycloakApplication {
4848
protected Set<Class<?>> classes = new HashSet<>();
4949

5050
public ResteasyKeycloakApplication() {
51+
Config.init(new JsonConfigProviderFactory().create()
52+
.orElseThrow(() -> new RuntimeException("Failed to load Keycloak configuration")));
53+
Profile.configure(
54+
new PropertiesProfileConfigResolver(System.getProperties()),
55+
new PropertiesFileProfileConfigResolver()
56+
);
5157
classes.add(RealmsResource.class);
5258
if (Profile.isFeatureEnabled(Profile.Feature.ADMIN_API)) {
5359
classes.add(AdminRoot.class);
@@ -68,12 +74,6 @@ public ResteasyKeycloakApplication() {
6874
// an endpoint for the load balancer to gather information whether this site should receive requests or not.
6975
classes.add(LoadBalancerResource.class);
7076
}
71-
Config.init(new JsonConfigProviderFactory().create()
72-
.orElseThrow(() -> new RuntimeException("Failed to load Keycloak configuration")));
73-
Profile.configure(
74-
new PropertiesProfileConfigResolver(System.getProperties()),
75-
new PropertiesFileProfileConfigResolver()
76-
);
7777
startup();
7878
}
7979

‎testsuite/utils/pom.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@
268268
<version>${mssql-jdbc.version}</version>
269269
</dependency>
270270

271-
<dependency>
272-
<groupId>org.keycloak</groupId>
273-
<artifactId>keycloak-junit5</artifactId>
274-
</dependency>
275-
276271
<dependency>
277272
<groupId>io.quarkus</groupId>
278273
<artifactId>quarkus-micrometer</artifactId>

‎testsuite/utils/src/main/java/org/keycloak/testsuite/KeycloakServer.java‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.InputStream;
2323
import java.nio.charset.StandardCharsets;
2424
import java.nio.file.Files;
25+
import java.nio.file.Path;
2526
import java.nio.file.Paths;
2627
import java.security.KeyStore;
2728
import java.text.SimpleDateFormat;
@@ -41,7 +42,6 @@
4142
import jakarta.servlet.DispatcherType;
4243
import jakarta.servlet.Filter;
4344

44-
import org.keycloak.Keycloak;
4545
import org.keycloak.authentication.AuthenticatorSpi;
4646
import org.keycloak.authentication.authenticators.browser.DeployedScriptAuthenticatorFactory;
4747
import org.keycloak.authorization.policy.provider.PolicySpi;
@@ -77,6 +77,7 @@
7777
import io.undertow.servlet.api.DeploymentInfo;
7878
import io.undertow.servlet.api.FilterInfo;
7979
import io.undertow.servlet.api.InstanceHandle;
80+
import org.apache.commons.io.FileUtils;
8081
import org.jboss.logging.Logger;
8182
import org.jboss.resteasy.core.ResteasyDeploymentImpl;
8283
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
@@ -320,7 +321,28 @@ public static String detectDataDirectory() {
320321
}
321322

322323
// we generate a dynamic jboss.server.data.dir and remove it at the end.
323-
return Keycloak.initTempDirectory("keycloak-data").toFile().getAbsolutePath();
324+
return initTempDirectory("keycloak-data").toFile().getAbsolutePath();
325+
}
326+
327+
public static Path initTempDirectory(String name) {
328+
String buildDir = System.getProperty("project.build.directory");
329+
if (buildDir == null) {
330+
try {
331+
Path tempDirectory = Files.createTempDirectory(name);
332+
tempDirectory.toFile().deleteOnExit();
333+
return tempDirectory.toAbsolutePath();
334+
} catch (IOException e) {
335+
throw new RuntimeException("Could not create temporary directory", e);
336+
}
337+
} else {
338+
Path tempDirectory = Path.of(buildDir, name);
339+
try {
340+
FileUtils.deleteDirectory(tempDirectory.toFile());
341+
} catch (IOException e) {
342+
e.printStackTrace();
343+
}
344+
return tempDirectory;
345+
}
324346
}
325347

326348
private KeycloakServerConfig config;

0 commit comments

Comments
 (0)
0