dasniko / testcontainers-keycloak

A Testcontainer implementation for Keycloak IAM & SSO.
Apache License 2.0
328 stars 51 forks source link

Errors when trying to import realm from a folder #73

Closed aivinog1 closed 2 years ago

aivinog1 commented 2 years ago

Describe the bug

When I'm trying to import a realm file from a folder:

KeycloakContainer keycloak = new KeycloakContainer().withRealmImportFile("/single-test-folder/test-realm.json");

My container didn't start and I got such errors in the container:

16:36:34.212 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,218 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (development) mode
16:36:34.221 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,219 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to parse realm configuration file: /opt/keycloak/bin/../data/import/single-test-folder
16:36:34.221 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,228 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Is a directory
16:36:34.223 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,230 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.

In the 2.1.2 version, everything works fine.

Version

2.2.0

Expected behavior

I'm expecting that the container correctly imports realm files from classpath with a directory.

Actual behavior

The container crushes.

How to Reproduce?

KeycloakContainer keycloak = new KeycloakContainer().withRealmImportFile("/single-test-folder/test-realm.json");
keycloak.start();

Also, I will provide test cases in a draft PR: #74.

Relevant log output

16:36:34.212 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,218 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (development) mode
16:36:34.221 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,219 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to parse realm configuration file: /opt/keycloak/bin/../data/import/single-test-folder
16:36:34.221 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,228 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Is a directory
16:36:34.223 [docker-java-stream-438386004] INFO  🐳 [quay.io/keycloak/keycloak:18.0.0] - STDOUT: 2022-04-29 09:36:34,230 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.


### Anything else?

_No response_
dasniko commented 2 years ago

Thanks for reporting the issue. Yes, seems like an "unimplemented feature". 🙂

Auto-import of realms changed a lot in the past, unfortunately.

Is your PR just for reproducing the issue or can you also provide some fix? This would speed up things.

aivinog1 commented 2 years ago

Hey @dasniko! Yes, right now it is just test cases :) Let me dig up a little, maybe I can produce a fix. But no promises :)