Skip to content

Commit

Permalink
Small refactorings: print out exception if keycloak testcontainer cou…
Browse files Browse the repository at this point in the history
…ldn't be started & renaming
  • Loading branch information
Edwin Steiner committed Mar 27, 2024
1 parent 5d3c8dd commit 317eae3
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Optional;

@Testcontainers
class KeycloakConfigCLITestIT {
class KeycloakCustomTestIT {

private static final String DOCKER_IMAGE_NAME = "docker-registry.inventage.com:10094/com.inventage.keycloak.custom.container:latest";
private static final String POSTGRES_DOCKER_IMAGE_NAME = "postgres:13-alpine";
Expand All @@ -38,7 +38,13 @@ static void beforeAll() {
"KC_DB_PASSWORD", postgres.getPassword(),
"KC_DB_URL", jdbcUrl,
"KC_LOG_LEVEL", "info"));
keycloak.start();
try {
keycloak.start();
}
catch (Exception e) {
System.err.println(keycloak.getLogs());
throw e;
}
}

@AfterAll
Expand All @@ -62,7 +68,7 @@ void test_import_realm() {
.password(keycloak.getAdminPassword())
.build();

Optional<RealmRepresentation> testRealm = keycloakAdminClient.realms().findAll().stream().filter(realmRepresentation -> realmRepresentation.getRealm().equals("example1")).findFirst();
Assertions.assertTrue(testRealm.isPresent(), "Realm `testcontainer` should exist. Realm import via keycloak-config-cli failed.");
Optional<RealmRepresentation> example1 = keycloakAdminClient.realms().findAll().stream().filter(realmRepresentation -> realmRepresentation.getRealm().equals("example1")).findFirst();
Assertions.assertTrue(example1.isPresent(), "Realm `example1` should exist. Realm import via keycloak-config-cli failed.");
}
}

0 comments on commit 317eae3

Please sign in to comment.