diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HttpAdvancedReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HttpAdvancedReactiveIT.java index 867c54e20..1c21edc62 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HttpAdvancedReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/HttpAdvancedReactiveIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.http.advanced.reactive; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.Tag; import io.quarkus.test.bootstrap.KeycloakService; @@ -12,11 +16,9 @@ @QuarkusScenario public class HttpAdvancedReactiveIT extends BaseHttpAdvancedReactiveIT { - private static final String REALM_DEFAULT = "test-realm"; - //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(ssl = true) diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/OpenShiftHttpAdvancedReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/OpenShiftHttpAdvancedReactiveIT.java index 4829f5086..61f7ab233 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/OpenShiftHttpAdvancedReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/OpenShiftHttpAdvancedReactiveIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.http.advanced.reactive; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; @@ -13,11 +17,9 @@ @DisabledIfSystemProperty(named = "ts.s390x.missing.services.excludes", matches = "true", disabledReason = "keycloak container not available on s390x.") public class OpenShiftHttpAdvancedReactiveIT extends BaseHttpAdvancedReactiveIT { - private static final String REALM_DEFAULT = "test-realm"; - //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(ssl = true) diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java index 08ff46e81..35382df97 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java @@ -55,7 +55,6 @@ public abstract class BaseHttpAdvancedIT { - protected static final String REALM_DEFAULT = "test-realm"; private static final String ROOT_PATH = "/api"; private static final int TIMEOUT_SEC = 3; private static final int RETRY = 3; diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HttpAdvancedIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HttpAdvancedIT.java index 58ec8079f..c71b9638a 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HttpAdvancedIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/HttpAdvancedIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.http.advanced; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.Tag; import io.quarkus.test.bootstrap.KeycloakService; @@ -13,8 +17,8 @@ public class HttpAdvancedIT extends BaseHttpAdvancedIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(ssl = true) diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/OpenShiftHttpAdvancedIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/OpenShiftHttpAdvancedIT.java index da83c0c0b..969dca430 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/OpenShiftHttpAdvancedIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/OpenShiftHttpAdvancedIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.http.advanced; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; @@ -14,8 +18,8 @@ public class OpenShiftHttpAdvancedIT extends BaseHttpAdvancedIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(ssl = true) diff --git a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/BaseMicrometerOidcSecurityIT.java b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/BaseMicrometerOidcSecurityIT.java index 9c99fab77..08695f836 100644 --- a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/BaseMicrometerOidcSecurityIT.java +++ b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/BaseMicrometerOidcSecurityIT.java @@ -1,5 +1,8 @@ package io.quarkus.ts.micrometer.oidc; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -18,7 +21,6 @@ public abstract class BaseMicrometerOidcSecurityIT { static final String NORMAL_USER = "test-normal-user"; - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; static final int ASSERT_SERVICE_TIMEOUT_MINUTES = 1; @@ -28,8 +30,8 @@ public abstract class BaseMicrometerOidcSecurityIT { static final String UNAUTHORIZED_HTTP_CALL_METRIC = HTTP_METRIC + "outcome=\"CLIENT_ERROR\",status=\"401\",uri=\"%s\"}"; //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); private AuthzClient authzClient; diff --git a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/DevMicrometerOidcSecurityIT.java b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/DevMicrometerOidcSecurityIT.java index 5f25f793f..b27b10433 100644 --- a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/DevMicrometerOidcSecurityIT.java +++ b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/DevMicrometerOidcSecurityIT.java @@ -9,7 +9,7 @@ public class DevMicrometerOidcSecurityIT extends BaseMicrometerOidcSecurityIT { @DevModeQuarkusApplication static RestService app = new RestService() - .withProperty("quarkus.oidc.auth-server-url", () -> keycloak.getRealmUrl()) + .withProperty("quarkus.oidc.auth-server-url", keycloak::getRealmUrl) .withProperty("quarkus.oidc.client-id", CLIENT_ID_DEFAULT) .withProperty("quarkus.oidc.credentials.secret", CLIENT_SECRET_DEFAULT); diff --git a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/ProdMicrometerOidcSecurityIT.java b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/ProdMicrometerOidcSecurityIT.java index 2cfa3bae2..c17db9cec 100644 --- a/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/ProdMicrometerOidcSecurityIT.java +++ b/monitoring/micrometer-prometheus-oidc/src/test/java/io/quarkus/ts/micrometer/oidc/ProdMicrometerOidcSecurityIT.java @@ -9,7 +9,7 @@ public class ProdMicrometerOidcSecurityIT extends BaseMicrometerOidcSecurityIT { @QuarkusApplication static RestService app = new RestService() - .withProperty("quarkus.oidc.auth-server-url", () -> keycloak.getRealmUrl()) + .withProperty("quarkus.oidc.auth-server-url", keycloak::getRealmUrl) .withProperty("quarkus.oidc.client-id", CLIENT_ID_DEFAULT) .withProperty("quarkus.oidc.credentials.secret", CLIENT_SECRET_DEFAULT); diff --git a/pom.xml b/pom.xml index 127d3d7d4..78915b9f0 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ io.quarkus 999-SNAPSHOT 3.6.1 - 1.4.0.Beta4 + 1.4.0.Beta5 2.5.0 4.5.14 7.5.1 @@ -57,6 +57,7 @@ no docker.io/library/postgres:15 + registry.redhat.io/rhbk/keycloak-rhel9:22-6 2.35.1 3.3.1 @@ -749,7 +750,7 @@ true - registry.redhat.io/rh-sso-7/sso76-openshift-rhel8 + ${rhbk.image} registry.redhat.io/rhscl/postgresql-10-rhel7 registry.redhat.io/rhscl/postgresql-13-rhel7 registry.redhat.io/rhscl/mariadb-103-rhel7 @@ -799,7 +800,7 @@ true true - registry.redhat.io/rh-sso-7/sso76-openshift-rhel8 + ${rhbk.image} registry.redhat.io/rhel8/postgresql-10 registry.redhat.io/rhel8/mysql-80 registry.redhat.io/rhel8/mariadb-103 @@ -852,7 +853,7 @@ true registry.redhat.io/amq7/amq-broker-rhel8:7.10 - registry.redhat.io/rh-sso-7/sso76-openshift-rhel8 + ${rhbk.image} registry.redhat.io/rhel8/postgresql-10 registry.redhat.io/rhel8/mysql-80 registry.redhat.io/rhel8/mariadb-103 diff --git a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/BaseAuthzSecurityIT.java b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/BaseAuthzSecurityIT.java index 313b43a5f..7795553e4 100644 --- a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/BaseAuthzSecurityIT.java +++ b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/BaseAuthzSecurityIT.java @@ -16,7 +16,6 @@ public abstract class BaseAuthzSecurityIT { static final String NORMAL_USER = "test-normal-user"; static final String ADMIN_USER = "test-admin-user"; - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; diff --git a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/KeycloakAuthzSecurityIT.java b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/KeycloakAuthzSecurityIT.java index 9a2c61c43..b0a2ed565 100644 --- a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/KeycloakAuthzSecurityIT.java +++ b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/KeycloakAuthzSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.authz; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -9,11 +13,9 @@ @QuarkusScenario public class KeycloakAuthzSecurityIT extends BaseAuthzSecurityIT { - static final int KEYCLOAK_PORT = 8080; - //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/OpenShiftRhSsoAuthzSecurityIT.java b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/OpenShiftRhSsoAuthzSecurityIT.java index e2f1175b2..424999004 100644 --- a/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/OpenShiftRhSsoAuthzSecurityIT.java +++ b/security/keycloak-authz-classic/src/test/java/io/quarkus/ts/security/keycloak/authz/OpenShiftRhSsoAuthzSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.authz; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoAuthzSecurityIT extends BaseAuthzSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/BaseAuthzSecurityReactiveIT.java b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/BaseAuthzSecurityReactiveIT.java index 035bc1b8d..15f722bc6 100644 --- a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/BaseAuthzSecurityReactiveIT.java +++ b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/BaseAuthzSecurityReactiveIT.java @@ -24,7 +24,6 @@ public abstract class BaseAuthzSecurityReactiveIT { static final String NORMAL_USER = "test-normal-user"; static final String ADMIN_USER = "test-admin-user"; - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; diff --git a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/KeycloakAuthzSecurityReactiveIT.java b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/KeycloakAuthzSecurityReactiveIT.java index 0207f95e0..f59636bac 100644 --- a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/KeycloakAuthzSecurityReactiveIT.java +++ b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/KeycloakAuthzSecurityReactiveIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.authz.reactive; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -10,8 +14,8 @@ public class KeycloakAuthzSecurityReactiveIT extends BaseAuthzSecurityReactiveIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/OpenShiftRhSsoAuthzSecurityReactiveIT.java b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/OpenShiftRhSsoAuthzSecurityReactiveIT.java index eec1ebd61..b21f7e306 100644 --- a/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/OpenShiftRhSsoAuthzSecurityReactiveIT.java +++ b/security/keycloak-authz-reactive/src/test/java/io/quarkus/ts/security/keycloak/authz/reactive/OpenShiftRhSsoAuthzSecurityReactiveIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.authz.reactive; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoAuthzSecurityReactiveIT extends BaseAuthzSecurityReactiveIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/BaseOidcJwtSecurityIT.java b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/BaseOidcJwtSecurityIT.java index bec3f4f42..ac76f3d6a 100644 --- a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/BaseOidcJwtSecurityIT.java +++ b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/BaseOidcJwtSecurityIT.java @@ -1,5 +1,6 @@ package io.quarkus.ts.security.keycloak.jwt; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -22,10 +23,9 @@ public abstract class BaseOidcJwtSecurityIT { - protected static final String REALM_DEFAULT = "test-realm"; protected static final String CLIENT_ID_DEFAULT = "test-application-client"; - private static final String LOGIN_REALM_REGEXP = ".*(Sign|Log) in to " + REALM_DEFAULT + ".*"; + private static final String LOGIN_REALM_REGEXP = ".*(Sign|Log) in to " + DEFAULT_REALM + ".*"; private WebClient webClient; private HtmlPage page; diff --git a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/KeycloakOidcJwtSecurityIT.java b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/KeycloakOidcJwtSecurityIT.java index d1bb2be7e..d3669c627 100644 --- a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/KeycloakOidcJwtSecurityIT.java +++ b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/KeycloakOidcJwtSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.jwt; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.Tag; import io.quarkus.test.bootstrap.KeycloakService; @@ -13,8 +17,8 @@ public class KeycloakOidcJwtSecurityIT extends BaseOidcJwtSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/OpenShiftRhSsoOidcJwtSecurityIT.java b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/OpenShiftRhSsoOidcJwtSecurityIT.java index 04730be52..c50fee124 100644 --- a/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/OpenShiftRhSsoOidcJwtSecurityIT.java +++ b/security/keycloak-jwt/src/test/java/io/quarkus/ts/security/keycloak/jwt/OpenShiftRhSsoOidcJwtSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.jwt; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoOidcJwtSecurityIT extends BaseOidcJwtSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/BaseMultiTenantSecurityIT.java b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/BaseMultiTenantSecurityIT.java index 5446e688e..2f3f3e7fd 100644 --- a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/BaseMultiTenantSecurityIT.java +++ b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/BaseMultiTenantSecurityIT.java @@ -1,5 +1,6 @@ package io.quarkus.ts.security.keycloak.multitenant; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; import static io.restassured.RestAssured.given; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -27,9 +28,8 @@ public abstract class BaseMultiTenantSecurityIT { protected static final String USER = "test-user"; - protected static final String REALM_DEFAULT = "test-realm"; - private static final String LOGIN_REALM_REGEXP = ".*(Sign|Log) in to " + REALM_DEFAULT + ".*"; + private static final String LOGIN_REALM_REGEXP = ".*(Sign|Log) in to " + DEFAULT_REALM + ".*"; private WebClient webClient; diff --git a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/KeycloakMultiTenantSecurityIT.java b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/KeycloakMultiTenantSecurityIT.java index 1de4470cd..84c104365 100644 --- a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/KeycloakMultiTenantSecurityIT.java +++ b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/KeycloakMultiTenantSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.multitenant; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.Tag; import io.quarkus.test.bootstrap.KeycloakService; @@ -13,9 +17,8 @@ public class KeycloakMultiTenantSecurityIT extends BaseMultiTenantSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/OpenShiftRhSsoMultiTenantSecurityIT.java b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/OpenShiftRhSsoMultiTenantSecurityIT.java index 21e6e121e..8f0411a3c 100644 --- a/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/OpenShiftRhSsoMultiTenantSecurityIT.java +++ b/security/keycloak-multitenant/src/test/java/io/quarkus/ts/security/keycloak/multitenant/OpenShiftRhSsoMultiTenantSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.multitenant; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,15 +18,13 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoMultiTenantSecurityIT extends BaseMultiTenantSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", + "--features=token-exchange" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() - .withProperty("quarkus.oidc.auth-server-url", () -> keycloak.getRealmUrl()); + .withProperty("quarkus.oidc.auth-server-url", keycloak::getRealmUrl); @Override protected KeycloakService getKeycloak() { diff --git a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/BaseOauth2SecurityIT.java b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/BaseOauth2SecurityIT.java index a768f64f5..fe5b74ae1 100644 --- a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/BaseOauth2SecurityIT.java +++ b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/BaseOauth2SecurityIT.java @@ -14,7 +14,6 @@ public abstract class BaseOauth2SecurityIT { static final String NORMAL_USER = "test-normal-user"; static final String ADMIN_USER = "test-admin-user"; - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; diff --git a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/KeycloakOauth2SecurityIT.java b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/KeycloakOauth2SecurityIT.java index 5fcd1a333..1327a57b8 100644 --- a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/KeycloakOauth2SecurityIT.java +++ b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/KeycloakOauth2SecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.oauth2; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -10,8 +14,8 @@ public class KeycloakOauth2SecurityIT extends BaseOauth2SecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/OpenShiftRhSsoOauth2SecurityIT.java b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/OpenShiftRhSsoOauth2SecurityIT.java index 44bbd74a8..ad0a6cda6 100644 --- a/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/OpenShiftRhSsoOauth2SecurityIT.java +++ b/security/keycloak-oauth2/src/test/java/io/quarkus/ts/security/keycloak/oauth2/OpenShiftRhSsoOauth2SecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.oauth2; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoOauth2SecurityIT extends BaseOauth2SecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/BaseOidcClientSecurityIT.java b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/BaseOidcClientSecurityIT.java index 2b7e183c2..643145f8e 100644 --- a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/BaseOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/BaseOidcClientSecurityIT.java @@ -13,8 +13,6 @@ public abstract class BaseOidcClientSecurityIT { - static final String REALM_DEFAULT = "test-realm"; - @Test public void clientCredentialsSecuredResource() { getApp().given() diff --git a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/KeycloakOidcClientSecurityIT.java b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/KeycloakOidcClientSecurityIT.java index 7af64eea6..b741e1799 100644 --- a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/KeycloakOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/KeycloakOidcClientSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.oidcclient.basic; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -10,9 +14,9 @@ public class KeycloakOidcClientSecurityIT extends BaseOidcClientSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/OpenShiftRhSsoOidcClientSecurityIT.java b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/OpenShiftRhSsoOidcClientSecurityIT.java index 8d1172b4e..19b346d38 100644 --- a/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/OpenShiftRhSsoOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/basic/OpenShiftRhSsoOidcClientSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.oidcclient.basic; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,15 +18,13 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoOidcClientSecurityIT extends BaseOidcClientSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() - .withProperty("quarkus.oidc.auth-server-url", () -> keycloak.getRealmUrl()); + .withProperty("quarkus.oidc.auth-server-url", keycloak::getRealmUrl); @Override protected KeycloakService getKeycloak() { diff --git a/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/BaseOidcIT.java b/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/BaseOidcIT.java index 009e94735..1e420915a 100644 --- a/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/BaseOidcIT.java +++ b/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/BaseOidcIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.oidcclient.extended.restclient; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.BeforeEach; import org.keycloak.authorization.client.AuthzClient; @@ -11,14 +15,13 @@ public abstract class BaseOidcIT { static final String USER = "test-user"; - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/LogoutSinglePageAppFlowIT.java b/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/LogoutSinglePageAppFlowIT.java index 5a9bb63bf..cd67bb8be 100644 --- a/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/LogoutSinglePageAppFlowIT.java +++ b/security/keycloak-oidc-client-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/extended/restclient/LogoutSinglePageAppFlowIT.java @@ -1,5 +1,6 @@ package io.quarkus.ts.security.keycloak.oidcclient.extended.restclient; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -30,8 +31,8 @@ public class LogoutSinglePageAppFlowIT { static final String REALM_DEFAULT = "quarkus"; @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/kc-logout-realm.json", REALM_DEFAULT, "/realms") + "start-dev", "--import-realm", "--hostname-strict-https=false", }) + static KeycloakService keycloak = new KeycloakService("/kc-logout-realm.json", REALM_DEFAULT, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(classes = { LogoutFlow.class, LogoutTenantResolver.class }) diff --git a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/BaseOidcClientSecurityIT.java b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/BaseOidcClientSecurityIT.java index a15affd0a..6a314a21b 100644 --- a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/BaseOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/BaseOidcClientSecurityIT.java @@ -13,8 +13,6 @@ public abstract class BaseOidcClientSecurityIT { - static final String REALM_DEFAULT = "test-realm"; - @Test public void clientCredentialsSecuredResource() { getApp().given() diff --git a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/KeycloakOidcClientSecurityIT.java b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/KeycloakOidcClientSecurityIT.java index a9f668dfe..5c1354de1 100644 --- a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/KeycloakOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/KeycloakOidcClientSecurityIT.java @@ -1,5 +1,8 @@ package io.quarkus.ts.security.keycloak.oidcclient.reactive.basic; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; import static io.restassured.RestAssured.given; import java.util.List; @@ -20,9 +23,9 @@ public class KeycloakOidcClientSecurityIT extends BaseOidcClientSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/OpenShiftRhSsoOidcClientSecurityIT.java b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/OpenShiftRhSsoOidcClientSecurityIT.java index 1f6b574f3..055d14835 100644 --- a/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/OpenShiftRhSsoOidcClientSecurityIT.java +++ b/security/keycloak-oidc-client-reactive-basic/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/basic/OpenShiftRhSsoOidcClientSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.oidcclient.reactive.basic; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,9 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoOidcClientSecurityIT extends BaseOidcClientSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/BaseOidcIT.java b/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/BaseOidcIT.java index 9d7e3adbe..48b04c473 100644 --- a/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/BaseOidcIT.java +++ b/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/BaseOidcIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.oidcclient.reactive.extended; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.BeforeEach; import org.keycloak.authorization.client.AuthzClient; @@ -10,15 +14,13 @@ public abstract class BaseOidcIT { static final String USER = "test-user"; - - static final String REALM_DEFAULT = "test-realm"; static final String CLIENT_ID_DEFAULT = "test-application-client"; static final String CLIENT_SECRET_DEFAULT = "test-application-client-secret"; //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict-https=false", + "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/LogoutSinglePageAppFlowIT.java b/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/LogoutSinglePageAppFlowIT.java index 6ff6f4abf..d04f6b575 100644 --- a/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/LogoutSinglePageAppFlowIT.java +++ b/security/keycloak-oidc-client-reactive-extended/src/test/java/io/quarkus/ts/security/keycloak/oidcclient/reactive/extended/LogoutSinglePageAppFlowIT.java @@ -1,5 +1,6 @@ package io.quarkus.ts.security.keycloak.oidcclient.reactive.extended; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -32,9 +33,8 @@ public class LogoutSinglePageAppFlowIT { static final String REALM_DEFAULT = "quarkus"; - @KeycloakContainer(command = { - "start-dev --import-realm --hostname-strict-https=false --features=token-exchange" }) - static KeycloakService keycloak = new KeycloakService("/kc-logout-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", "--features=token-exchange" }) + static KeycloakService keycloak = new KeycloakService("/kc-logout-realm.json", REALM_DEFAULT, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication(classes = { LogoutFlow.class }) diff --git a/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/KeycloakWebappSecurityIT.java b/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/KeycloakWebappSecurityIT.java index 412abda3c..84c4d0639 100644 --- a/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/KeycloakWebappSecurityIT.java +++ b/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/KeycloakWebappSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak.webapp; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -10,8 +14,8 @@ public class KeycloakWebappSecurityIT extends BaseWebappSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm --hostname-strict=false" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/OpenShiftRhSsoWebappSecurityIT.java b/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/OpenShiftRhSsoWebappSecurityIT.java index 66d55a8d5..633c6a176 100644 --- a/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/OpenShiftRhSsoWebappSecurityIT.java +++ b/security/keycloak-webapp/src/test/java/io/quarkus/ts/security/keycloak/webapp/OpenShiftRhSsoWebappSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak.webapp; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoWebappSecurityIT extends BaseWebappSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/KeycloakOidcSecurityIT.java b/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/KeycloakOidcSecurityIT.java index 3a12b85ac..52a9f7902 100644 --- a/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/KeycloakOidcSecurityIT.java +++ b/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/KeycloakOidcSecurityIT.java @@ -1,5 +1,9 @@ package io.quarkus.ts.security.keycloak; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; @@ -10,8 +14,8 @@ public class KeycloakOidcSecurityIT extends BaseOidcSecurityIT { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = { "start-dev --import-realm" }) - static KeycloakService keycloak = new KeycloakService("/keycloak-realm.json", REALM_DEFAULT, "/realms") + @KeycloakContainer(command = { "start-dev", "--import-realm" }) + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH) .withProperty("JAVA_OPTS", "-Dcom.redhat.fips=false"); @QuarkusApplication diff --git a/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/OpenShiftRhSsoOidcSecurityIT.java b/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/OpenShiftRhSsoOidcSecurityIT.java index 623992078..29acb9948 100644 --- a/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/OpenShiftRhSsoOidcSecurityIT.java +++ b/security/keycloak/src/test/java/io/quarkus/ts/security/keycloak/OpenShiftRhSsoOidcSecurityIT.java @@ -1,12 +1,16 @@ package io.quarkus.ts.security.keycloak; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_BASE_PATH; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; + import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.services.Container; +import io.quarkus.test.services.KeycloakContainer; import io.quarkus.test.services.QuarkusApplication; @OpenShiftScenario @@ -14,11 +18,8 @@ @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") public class OpenShiftRhSsoOidcSecurityIT extends BaseOidcSecurityIT { - static final int KEYCLOAK_PORT = 8080; - - @Container(image = "${rhsso.image}", expectedLog = "Http management interface listening", port = KEYCLOAK_PORT) - static KeycloakService keycloak = new KeycloakService(REALM_DEFAULT) - .withProperty("SSO_IMPORT_FILE", "resource::/keycloak-realm.json"); + @KeycloakContainer(command = { "start-dev", "--import-realm" }, image = "${rhbk.image}") + static KeycloakService keycloak = new KeycloakService(DEFAULT_REALM_FILE, DEFAULT_REALM, DEFAULT_REALM_BASE_PATH); @QuarkusApplication static RestService app = new RestService() diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/BaseOidcMtlsIT.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/BaseOidcMtlsIT.java index aee3dc28c..1984cd5d9 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/BaseOidcMtlsIT.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/BaseOidcMtlsIT.java @@ -21,7 +21,6 @@ @Tag("QUARKUS-1676") public abstract class BaseOidcMtlsIT { protected static final String REALM_DEFAULT = "test-mutual-tls-realm"; - protected static final String REALM_FILE_PATH = "/keycloak-realm.json"; protected static final String RESOURCE_PATH = "/ping"; protected static final String NORMAL_USER = "test-normal-user"; protected static final String CLIENT_ID_DEFAULT = "test-mutual-tls"; diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/IncorrectKsFileTypeOidcMtlsIT.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/IncorrectKsFileTypeOidcMtlsIT.java index 06c748cff..5bd62a665 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/IncorrectKsFileTypeOidcMtlsIT.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/IncorrectKsFileTypeOidcMtlsIT.java @@ -1,6 +1,6 @@ package io.quarkus.ts.security.oidcclient.mtls; -import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.KC_DEV_MODE_JKS_CMD; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.newKeycloakInstance; import static io.restassured.RestAssured.given; @@ -25,8 +25,13 @@ public class IncorrectKsFileTypeOidcMtlsIT extends BaseOidcMtlsIT { static final String KEYSTORE_FILE_EXTENSION = "jks"; //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = KC_DEV_MODE_JKS_CMD, port = KEYCLOAK_PORT) - static KeycloakService keycloak = newKeycloakInstance(REALM_FILE_PATH, REALM_DEFAULT, "realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", + "--hostname-strict-https=false", "--features=token-exchange", + "--hostname=localhost", // required by LocalHostKeycloakContainerManagedResourceBuilder + "--https-client-auth=required", "--https-key-store-file=/etc/server-keystore.jks", + "--https-trust-store-file=/etc/server-truststore.jks", + "--https-trust-store-password=password" }, port = KEYCLOAK_PORT) + static KeycloakService keycloak = newKeycloakInstance(DEFAULT_REALM_FILE, REALM_DEFAULT, "realms") .withRedHatFipsDisabled() .withProperty("HTTPS_KEYSTORE", "resource_with_destination::/etc/|server-keystore." + KEYSTORE_FILE_EXTENSION) .withProperty("HTTPS_TRUSTSTORE", "resource_with_destination::/etc/|server-truststore." + KEYSTORE_FILE_EXTENSION); diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/JksOidcMtlsIT.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/JksOidcMtlsIT.java index 4172ef879..60460b61f 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/JksOidcMtlsIT.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/JksOidcMtlsIT.java @@ -1,6 +1,6 @@ package io.quarkus.ts.security.oidcclient.mtls; -import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.KC_DEV_MODE_JKS_CMD; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.newKeycloakInstance; import org.junit.jupiter.api.Tag; @@ -16,8 +16,13 @@ public class JksOidcMtlsIT extends KeycloakMtlsAuthN { //TODO Remove workaround after Keycloak is fixed https://github.com/keycloak/keycloak/issues/9916 - @KeycloakContainer(command = KC_DEV_MODE_JKS_CMD, port = KEYCLOAK_PORT, builder = LocalHostKeycloakContainerManagedResourceBuilder.class) - static KeycloakService keycloak = newKeycloakInstance(REALM_FILE_PATH, REALM_DEFAULT, "realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", + "--hostname-strict-https=false", "--features=token-exchange", + "--hostname=localhost", // required by LocalHostKeycloakContainerManagedResourceBuilder + "--https-client-auth=required", "--https-key-store-file=/etc/server-keystore.jks", + "--https-trust-store-file=/etc/server-truststore.jks", + "--https-trust-store-password=password" }, port = KEYCLOAK_PORT, builder = LocalHostKeycloakContainerManagedResourceBuilder.class) + static KeycloakService keycloak = newKeycloakInstance(DEFAULT_REALM_FILE, REALM_DEFAULT, "realms") .withRedHatFipsDisabled() .withProperty("HTTPS_KEYSTORE", "resource_with_destination::/etc/|server-keystore." + JKS_KEYSTORE_FILE_EXTENSION) .withProperty("HTTPS_TRUSTSTORE", diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/MutualTlsKeycloakService.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/MutualTlsKeycloakService.java index 74da397cd..4ed5d2188 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/MutualTlsKeycloakService.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/MutualTlsKeycloakService.java @@ -1,10 +1,10 @@ package io.quarkus.ts.security.oidcclient.mtls; -import static io.quarkus.test.utils.PropertiesUtils.SECRET_PREFIX; import static java.lang.String.format; import io.quarkus.test.bootstrap.KeycloakService; import io.quarkus.test.bootstrap.Protocol; +import io.quarkus.test.utils.TestExecutionProperties; public class MutualTlsKeycloakService extends KeycloakService { @@ -14,46 +14,20 @@ public class MutualTlsKeycloakService extends KeycloakService { private final String realmBasePath; private final boolean openshiftScenario; - // command used by Keycloak 18+ container in order to launch JKS secured Keycloak - public static final String KC_DEV_MODE_JKS_CMD = "start-dev " + - "--import-realm --hostname-strict=false --hostname-strict-https=false --features=token-exchange " + - "--hostname=localhost " + // required by LocalHostKeycloakContainerManagedResourceBuilder - "--https-client-auth=required " + - "--https-key-store-file=/etc/server-keystore.jks " + - "--https-trust-store-file=/etc/server-truststore.jks " + - "--https-trust-store-password=password"; - - // command used by Keycloak 18+ container in order to launch P12 secured Keycloak - public static final String KC_DEV_MODE_P12_CMD = "start-dev " + - "--import-realm --hostname-strict=false --hostname-strict-https=false --features=token-exchange " + - "--hostname=localhost " + // required by LocalHostKeycloakContainerManagedResourceBuilder - "--https-client-auth=required " + - "--https-key-store-file=/etc/server-keystore.p12 " + - "--https-trust-store-file=/etc/server-truststore.p12 " + - "--https-trust-store-password=password"; - public static MutualTlsKeycloakService newKeycloakInstance(String realmFile, String realmName, String realmBasePath) { return new MutualTlsKeycloakService(realmFile, realmName, realmBasePath); } - public static MutualTlsKeycloakService newRhSsoInstance(String realmFilePath, String realm) { - return (MutualTlsKeycloakService) new MutualTlsKeycloakService(realm) - .withProperty(X509_CA_BUNDLE, "/var/run/secrets/kubernetes.io/serviceaccount/*.crt") - .withProperty("SSO_IMPORT_FILE", SECRET_PREFIX + realmFilePath); + public static MutualTlsKeycloakService newRhSsoInstance(String realmFile, String realm) { + return (MutualTlsKeycloakService) new MutualTlsKeycloakService(realmFile, realm, DEFAULT_REALM_BASE_PATH) + .withProperty(X509_CA_BUNDLE, "/var/run/secrets/kubernetes.io/serviceaccount/*.crt"); } private MutualTlsKeycloakService(String realmFile, String realmName, String realmBasePath) { super(realmFile, realmName, realmBasePath); this.realm = realmName; this.realmBasePath = realmBasePath; - openshiftScenario = false; - } - - private MutualTlsKeycloakService(String realm) { - super(realm); - openshiftScenario = true; - this.realm = realm; - this.realmBasePath = "auth/realms"; + this.openshiftScenario = TestExecutionProperties.isOpenshiftPlatform(); } /** diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/OpenShiftRhSsoOidcMtlsIT.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/OpenShiftRhSsoOidcMtlsIT.java index 1f4ea5fc5..d7d193689 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/OpenShiftRhSsoOidcMtlsIT.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/OpenShiftRhSsoOidcMtlsIT.java @@ -5,6 +5,7 @@ import java.nio.file.Paths; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; @@ -14,6 +15,7 @@ import io.quarkus.test.services.Container; import io.quarkus.test.services.QuarkusApplication; +@Disabled // TODO mvavrik: fixing this will probably require fixing config map names created for resources @OpenShiftScenario @DisabledIfSystemProperty(named = "ts.arm.missing.services.excludes", matches = "true", disabledReason = "https://github.com/quarkus-qe/quarkus-test-suite/issues/1145") @EnabledIfSystemProperty(named = "ts.redhat.registry.enabled", matches = "true") diff --git a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/Pkcs12OidcMtlsIT.java b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/Pkcs12OidcMtlsIT.java index c65e0a358..979f41c8c 100644 --- a/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/Pkcs12OidcMtlsIT.java +++ b/security/oidc-client-mutual-tls/src/test/java/io/quarkus/ts/security/oidcclient/mtls/Pkcs12OidcMtlsIT.java @@ -1,6 +1,6 @@ package io.quarkus.ts.security.oidcclient.mtls; -import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.KC_DEV_MODE_P12_CMD; +import static io.quarkus.test.bootstrap.KeycloakService.DEFAULT_REALM_FILE; import static io.quarkus.ts.security.oidcclient.mtls.MutualTlsKeycloakService.newKeycloakInstance; import io.quarkus.test.bootstrap.KeycloakService; @@ -16,8 +16,13 @@ @QuarkusScenario public class Pkcs12OidcMtlsIT extends KeycloakMtlsAuthN { - @KeycloakContainer(command = KC_DEV_MODE_P12_CMD, port = KEYCLOAK_PORT, builder = LocalHostKeycloakContainerManagedResourceBuilder.class) - static KeycloakService keycloak = newKeycloakInstance(REALM_FILE_PATH, REALM_DEFAULT, "realms") + @KeycloakContainer(command = { "start-dev", "--import-realm", "--hostname-strict=false", + "--hostname-strict-https=false", "--features=token-exchange", + "--hostname=localhost", // required by LocalHostKeycloakContainerManagedResourceBuilder + "--https-client-auth=required", "--https-key-store-file=/etc/server-keystore.p12", + "--https-trust-store-file=/etc/server-truststore.p12", + "--https-trust-store-password=password" }, port = KEYCLOAK_PORT, builder = LocalHostKeycloakContainerManagedResourceBuilder.class) + static KeycloakService keycloak = newKeycloakInstance(DEFAULT_REALM_FILE, REALM_DEFAULT, "realms") .withProperty("HTTPS_KEYSTORE", "resource_with_destination::/etc/|server-keystore." + P12_KEYSTORE_FILE_EXTENSION) .withProperty("HTTPS_TRUSTSTORE", "resource_with_destination::/etc/|server-truststore." + P12_KEYSTORE_FILE_EXTENSION); diff --git a/security/oidc-client-mutual-tls/src/test/resources/test.properties b/security/oidc-client-mutual-tls/src/test/resources/test.properties index 8484e09dd..3db54985c 100644 --- a/security/oidc-client-mutual-tls/src/test/resources/test.properties +++ b/security/oidc-client-mutual-tls/src/test/resources/test.properties @@ -1,4 +1,3 @@ ts.keycloak.log.enable=true -ts.rhsso.log.enable=true ts.app.log.enable=true -ts.rhsso.openshift.template=/openshift-rh-sso-deployment-template.yml \ No newline at end of file +ts.keycloak.openshift.template=/openshift-rh-sso-deployment-template.yml \ No newline at end of file