I am currently using keycloak testcontainer and docker instance with version 20.0.3,
both container and docker imports two realms which includes specific settings need for my app and I am testing my application by using this data.
The momnet I change the version to 21.0.1 there is no possibilty to import and external realm.
This happens both for docker container and keycloak test container
The error I encounter is below:
11:33:41.335 [main] DEBUG org.testcontainers.utility.PrefixingImageNameSubstitutor - No prefix is configured
11:33:41.335 [main] DEBUG org.testcontainers.utility.ImageNameSubstitutor - Did not find a substitute image for quay.io/keycloak/keycloak:21.0.0 (using image substitutor: DefaultImageNameSubstitutor (composite of ‘ConfigurationFileImageNameSubstitutor’ and ‘PrefixingImageNameSubstitutor’))
The test I am running is
@Test
public void shouldImportMultipleRealms() {
try (KeycloakContainer keycloak = new KeycloakContainer().
withRealmImportFiles(TEST_REALM_JSON, "/realm-other-dev.json")) {
keycloak.start();
String accountService = given().when().get(keycloak.getAuthServerUrl() + "realms/master")
.then().statusCode(200).body("realm", equalTo("master"))
.extract().path("account-service");
given().when().get(accountService).then().statusCode(200);
accountService = given().when().get(keycloak.getAuthServerUrl() + "realms/other")
.then().statusCode(200).body("realm", equalTo("users"))
.extract().path("account-service");
given().when().get(accountService).then().statusCode(200);
}
}
Also my docker configuration is as below:
keycloak
postgres-kc:
image: postgres:latest
container_name: keycloak_postgres
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
ports:
- '5431:5431'
keycloak:
container_name: keycloak
image: quay.io/keycloak/keycloak:20.0.0
volumes:
- ./imports:/opt/keycloak/data/import
entrypoint: /opt/keycloak/bin/kc.sh start-dev --import-realm -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
# It is only possible to import non-existing realms; since in our case we can only import "others" realm
environment:
DB_VENDOR: POSTGRES
DB_ADDR: postgres-kc
DB_DATABASE: keycloak
DB_USER: keycloak
DB_PASSWORD: password
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: admin-secret
# KEYCLOAK_ADMIN & KEYCLOAK_ADMIN_PASSWORD password need to be defined for some releases, otherwise it causes error as
# "Open http://localhost:8080/ or set the environment variables KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD before
# starting the server."
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
ports:
- '8082:8080'
depends_on:
- postgres-kc