dasniko / testcontainers-keycloak

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

Realm import: file is not handled #94

Closed jmizv closed 1 year ago

jmizv commented 1 year ago

Describe the bug

In my test extension I have:

public KeycloakExtension(String importFile) {
    _importFile = importFile;
    _keycloakContainer = new KeycloakContainer("quay.io/keycloak/keycloak:19.0.1");
    if (_importFile != null) {
      _keycloakContainer.withRealmImportFile(_importFile);
    }
    _keycloakContainer.withCreateContainerCmdModifier(
        cmd -> cmd.withName(KEYCLOAK_TEST_CONTAINER_NAME_SUFFIX + FriendlyId.createFriendlyId()));
  }

And when I give the correct file, I can also see in the terminal for that container that the file is correctly copied:

sh-4.4$ ls opt/keycloak/data/import/
realm.json

But looking into the admin of that keycloak docker container, the realm is completely missing.

Is this a known problem?

Version

2.3.0

Expected behavior

The realm in the realm.json in the directory /opt/keycloak/data/import is successfully imported to the Keycloak.

Actual behavior

The expected realm from the JSON file is missing.

How to Reproduce?

No response

Relevant log output

No response

Anything else?

No response

dasniko commented 1 year ago

Realm import is working in general. Are you able to import the realm file into a running Keycloak instance of same version? What does the log output of the testcontainer tell you? Can you share the realm json to reproduce the behavior?

jmizv commented 1 year ago

I thought so that it should work in general. Haven't seen any exceptions and now I've switched to another approach and create my entities via admin client.

So I'd close this issue.