diff --git a/src/test/java/org/cbioportal/test/integration/MockServerContainer.java b/src/test/java/org/cbioportal/test/integration/MockServerContainer.java deleted file mode 100644 index 7ea39fd945f..00000000000 --- a/src/test/java/org/cbioportal/test/integration/MockServerContainer.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.cbioportal.test.integration; - -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.shaded.com.google.common.collect.ImmutableList; - -public class MockServerContainer extends GenericContainer { - - private static final String IMAGE_VERSION = "docker.io/mockserver/mockserver:5.15.0"; - private static String kcAdminName = "admin"; - private static String kcAdminPassword = "admin"; - private static GenericContainer container; - public final int port = 8085; - - private MockServerContainer() { - super(IMAGE_VERSION); - } - - public static GenericContainer getInstance() { - if (container == null) { - container = new GenericContainer(IMAGE_VERSION) - .withExposedPorts(1080); - container.setPortBindings(ImmutableList.of("8085:1080")); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java b/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java index c01a89f2366..0e04b993008 100644 --- a/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java +++ b/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java @@ -23,12 +23,6 @@ public void initializeImpl(ConfigurableApplicationContext configurableApplicatio TestPropertyValues values = TestPropertyValues.of( // These urls are from the perspective of cBioPortal application (port on host system). - String.format( - "spring.security.oauth2.client.provider.keycloak.issuer=%s/realms/cbio", - keycloakUrlForBrowser), - String.format( - "spring.security.oauth2.client.provider.keycloak.issuer-uri=%s/realms/cbio", - keycloakUrlForBrowser), String.format( "spring.security.oauth2.client.provider.keycloak.token-uri=%s/realms/cbio/protocol/openid-connect/token", keycloakUrlForCBioportal), @@ -45,6 +39,12 @@ public void initializeImpl(ConfigurableApplicationContext configurableApplicatio keycloakUrlForCBioportal), // This url is from the perspective of the browser. + String.format( + "spring.security.oauth2.client.provider.keycloak.issuer=%s/realms/cbio", + keycloakUrlForBrowser), + String.format( + "spring.security.oauth2.client.provider.keycloak.issuer-uri=%s/realms/cbio", + keycloakUrlForBrowser), String.format( "spring.security.oauth2.client.provider.keycloak.authorization-uri=%s/realms/cbio/protocol/openid-connect/auth", keycloakUrlForBrowser), diff --git a/src/test/java/org/cbioportal/test/integration/SharedChromeContainer.java b/src/test/java/org/cbioportal/test/integration/SharedChromeContainer.java deleted file mode 100644 index 2aedebd0ced..00000000000 --- a/src/test/java/org/cbioportal/test/integration/SharedChromeContainer.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.cbioportal.test.integration; - -import static org.testcontainers.containers.BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL; - - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import org.openqa.selenium.chrome.ChromeOptions; -import org.testcontainers.containers.BrowserWebDriverContainer; - -public class SharedChromeContainer extends BrowserWebDriverContainer { - - public final static String DOWNLOAD_FOLDER = "/tmp/browser_downloads"; - - private static BrowserWebDriverContainer container; - - private SharedChromeContainer() { - super(); - } - - // For test development a VNC viewer can be connected to the selenium container. - // Make sure to connect to exposed port on host system connected to internal - // port 5900 of the browser container. The password is 'secret'. - - public static BrowserWebDriverContainer getInstance() { - if (container == null) { - - ChromeOptions options = new ChromeOptions(); - Map prefs = new HashMap<>(); - prefs.put("download.default_directory", DOWNLOAD_FOLDER); - prefs.put("profile.default_content_settings.popups", 0); - prefs.put("download.prompt_for_download", "false"); - prefs.put("download.directory_upgrade", "true"); - options.setExperimentalOption("prefs", prefs); - - container = new BrowserWebDriverContainer<>() - // activate this to record movies of the tests (greate for debugging) - .withRecordingMode(RECORD_ALL, new File("/home/pnp300")) - .withAccessToHost(true) - .withCapabilities(options) - .withReuse(true); - container.start(); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/SharedKeycloakContainer.java b/src/test/java/org/cbioportal/test/integration/SharedKeycloakContainer.java deleted file mode 100644 index aec4716124b..00000000000 --- a/src/test/java/org/cbioportal/test/integration/SharedKeycloakContainer.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.cbioportal.test.integration; - -import dasniko.testcontainers.keycloak.KeycloakContainer; -import org.testcontainers.shaded.com.google.common.collect.ImmutableList; - -public class SharedKeycloakContainer extends KeycloakContainer { - - private static final String IMAGE_VERSION = "quai.io/keycloak/keycloak:23.0"; - private static String kcAdminName = "admin"; - private static String kcAdminPassword = "admin"; - private static KeycloakContainer container; - - private SharedKeycloakContainer() { - super(IMAGE_VERSION); - } - - public static KeycloakContainer getInstance() { - if (container == null) { - container = new KeycloakContainer() - .withRealmImportFile("security/keycloak-configuration-generated.json") - .withAdminUsername(kcAdminName) - .withAdminPassword(kcAdminPassword) - // Needed because cBioPortal and Chrome use different urls to Keycloak container - // Causes mismatch of 'issuer' field in JWT. - // See: https://stackoverflow.com/a/65848717/11651683 - .withEnv("KC_HOSTNAME", "host.testcontainers.internal") - .withEnv("KC_HOSTNAME_ADMIN", "localhost") - .withReuse(true); -// .withEnv("KC_LOG_LEVEL", "DEBUG"); - container.setPortBindings(ImmutableList.of("8084:8080")); - container.start(); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/SharedMongoContainer.java b/src/test/java/org/cbioportal/test/integration/SharedMongoContainer.java deleted file mode 100644 index 2eaf0d16a0e..00000000000 --- a/src/test/java/org/cbioportal/test/integration/SharedMongoContainer.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.cbioportal.test.integration; - -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; -import org.testcontainers.shaded.com.google.common.collect.ImmutableList; - - -public class SharedMongoContainer extends GenericContainer { - - private static final String IMAGE_VERSION = "docker.io/mongo:3.7.9"; - private static GenericContainer container; - - public static GenericContainer getInstance() { - if (container == null) { - container = new GenericContainer(DockerImageName.parse(IMAGE_VERSION)) - .withEnv("MONGO_INITDB_DATABASE", "session_service") - .withReuse(true); - container.setPortBindings(ImmutableList.of("27017:27017")); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/SharedMysqlContainer.java b/src/test/java/org/cbioportal/test/integration/SharedMysqlContainer.java deleted file mode 100644 index 43b6ed652e5..00000000000 --- a/src/test/java/org/cbioportal/test/integration/SharedMysqlContainer.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.cbioportal.test.integration; - -import org.testcontainers.containers.BindMode; -import org.testcontainers.containers.MySQLContainer; - -import java.time.Duration; - -public class SharedMysqlContainer extends MySQLContainer { - - private static final String IMAGE_VERSION = "mysql:5.7"; - private static SharedMysqlContainer container; - - private SharedMysqlContainer() { - super(IMAGE_VERSION); - } - - public static SharedMysqlContainer getInstance() { - if (container == null) { - container = new SharedMysqlContainer() - .withClasspathResourceMapping("cgds.sql", "/docker-entrypoint-initdb.d/a_schema.sql", BindMode.READ_ONLY) - .withClasspathResourceMapping("seed_mini.sql", "/docker-entrypoint-initdb.d/b_seed.sql", BindMode.READ_ONLY) - .withStartupTimeout(Duration.ofMinutes(10)) - .withReuse(true); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/SharedSessionServiceContainer.java b/src/test/java/org/cbioportal/test/integration/SharedSessionServiceContainer.java deleted file mode 100644 index 930003bba79..00000000000 --- a/src/test/java/org/cbioportal/test/integration/SharedSessionServiceContainer.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.cbioportal.test.integration; - -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; -import org.testcontainers.shaded.com.google.common.collect.ImmutableList; - - - -public class SharedSessionServiceContainer extends GenericContainer { - - private static final String IMAGE_VERSION = "docker.io/cbioportal/session-service:0.6.1"; - private static GenericContainer container; - - public static GenericContainer getInstance() { - if (container == null) { - container = new GenericContainer(DockerImageName.parse(IMAGE_VERSION)) - .withAccessToHost(true) - .withEnv("SERVER_PORT", "5000") - .withEnv("JAVA_OPTS", "-Dspring.data.mongodb.uri=mongodb://host.testcontainers.internal:27017/session-service") - .withReuse(true); - container.setPortBindings(ImmutableList.of("5000:5000")); - container.start(); - } - return container; - } - -} diff --git a/src/test/java/org/cbioportal/test/integration/security/AbstractContainerTest.java b/src/test/java/org/cbioportal/test/integration/security/AbstractContainerTest.java index e85703a5a55..c148365687c 100644 --- a/src/test/java/org/cbioportal/test/integration/security/AbstractContainerTest.java +++ b/src/test/java/org/cbioportal/test/integration/security/AbstractContainerTest.java @@ -5,6 +5,7 @@ import org.cbioportal.test.integration.OAuth2KeycloakInitializer; import org.cbioportal.test.integration.SamlKeycloakInitializer; import org.openqa.selenium.chrome.ChromeOptions; +import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.web.context.WebServerInitializedEvent; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationListener; @@ -68,8 +69,7 @@ public class AbstractContainerTest { sessionServiceContainer.setPortBindings(ImmutableList.of(String.format("%s:5000", SESSION_SERVICE_PORT))); mongoContainer = new GenericContainer(DockerImageName.parse(MONGO_IMAGE_VERSION)) - .withEnv("MONGO_INITDB_DATABASE", "session_service") - .withReuse(true); + .withEnv("MONGO_INITDB_DATABASE", "session_service"); mongoContainer.setPortBindings(ImmutableList.of(String.format("%s:27017", MONGO_PORT, MONGO_PORT))); keycloakContainer = new KeycloakContainer(KEYCLOAK_IMAGE_VERSION) @@ -77,8 +77,7 @@ public class AbstractContainerTest { .withAdminUsername("admin") .withAdminPassword("admin") .withEnv("KC_HOSTNAME", "host.testcontainers.internal") - .withEnv("KC_HOSTNAME_ADMIN", "localhost") - .withReuse(true); + .withEnv("KC_HOSTNAME_ADMIN", "localhost"); keycloakContainer.setPortBindings(ImmutableList.of(String.format("%s:8080", KEYCLOAK_PORT))); mockServerContainer = new GenericContainer(MOCKSERVER_IMAGE_VERSION) @@ -88,8 +87,7 @@ public class AbstractContainerTest { mysqlContainer = (MySQLContainer) new MySQLContainer(MYSQL_IMAGE_VERSION) .withClasspathResourceMapping("cgds.sql", "/docker-entrypoint-initdb.d/a_schema.sql", BindMode.READ_ONLY) .withClasspathResourceMapping("seed_mini.sql", "/docker-entrypoint-initdb.d/b_seed.sql", BindMode.READ_ONLY) - .withStartupTimeout(Duration.ofMinutes(10)) - .withReuse(true); + .withStartupTimeout(Duration.ofMinutes(10)); mysqlContainer.setPortBindings(ImmutableList.of(String.format("%s:3306", MYSQL_PORT))); ChromeOptions options = new ChromeOptions(); @@ -104,8 +102,7 @@ public class AbstractContainerTest { // activate this to record movies of the tests (greate for debugging) .withRecordingMode(RECORD_ALL, new File("/home/pnp300")) .withAccessToHost(true) - .withCapabilities(options) - .withReuse(true); + .withCapabilities(options); sessionServiceContainer.start(); mongoContainer.start(); @@ -149,9 +146,13 @@ public static class PortInitializer implements ApplicationContextInitializer { @Override public void initialize(ConfigurableApplicationContext applicationContext) { + TestPropertyValues values = TestPropertyValues.of( + "server.port=" + CBIO_PORT + ); + values.applyTo(applicationContext); applicationContext.addApplicationListener( (ApplicationListener) event -> { - Testcontainers.exposeHostPorts(CBIO_PORT, KEYCLOAK_PORT, SESSION_SERVICE_PORT); + Testcontainers.exposeHostPorts(CBIO_PORT, KEYCLOAK_PORT, MONGO_PORT); }); } } diff --git a/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java b/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java index f46d6859f6f..5cfe2ca673c 100644 --- a/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java +++ b/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java @@ -1,25 +1,18 @@ package org.cbioportal.test.integration.security; import org.cbioportal.PortalApplication; -import org.cbioportal.test.integration.MysqlInitializer; -import org.cbioportal.test.integration.OAuth2KeycloakInitializer; import org.cbioportal.test.integration.security.util.Util; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import org.testcontainers.Testcontainers; -import static org.cbioportal.test.integration.security.OAuth2AuthIntegrationTest.MyKeycloakInitializer; +import static org.cbioportal.test.integration.security.AbstractContainerTest.*; @RunWith(SpringRunner.class) @SpringBootTest( @@ -28,9 +21,6 @@ ) @TestPropertySource( properties = { - "app.name=cbioportal", - "server.port=8080", - "filter_groups_by_appname=false", "authenticate=oauth2", "dat.method=oauth2", // DB settings (also see MysqlInitializer) @@ -56,51 +46,16 @@ } ) @ContextConfiguration(initializers = { - OAuth2AuthIntegrationTest.MyMysqlInitializer.class, - MyKeycloakInitializer.class, - OAuth2AuthIntegrationTest.PortInitializer.class + MyMysqlInitializer.class, + MyOAuth2KeycloakInitializer.class, + PortInitializer.class }) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @DirtiesContext // needed to reuse port 8080 for multiple tests public class OAuth2AuthIntegrationTest extends AbstractContainerTest { - private final static int CBIO_PORT = 8080; - private final static int KC_PORT = 8084; - private final static int SESSION_PORT = 27017; public final static String CBIO_URL_FROM_BROWSER = String.format("http://host.testcontainers.internal:%d", CBIO_PORT); - - // Update application properties with connection info on Keycloak container - public static class MyKeycloakInitializer extends OAuth2KeycloakInitializer { - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - super.initializeImpl(configurableApplicationContext, keycloakContainer); - } - } - - // Update application properties with connection info on Mysql container - public static class MyMysqlInitializer extends MysqlInitializer { - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - super.initializeImpl(configurableApplicationContext, mysqlContainer); - } - } - - // Expose the ports for the cBioPortal Spring application and keycloak inside - // the Chrome container. Each address is available on http://host.testcontainers.internal: - // in the browser container. - public static class PortInitializer implements - ApplicationContextInitializer { - @Override - public void initialize(ConfigurableApplicationContext applicationContext) { - applicationContext.addApplicationListener( - (ApplicationListener) event -> { - Testcontainers.exposeHostPorts(CBIO_PORT, KC_PORT, SESSION_PORT); - }); - } - } @Test public void a_loginSuccess() { diff --git a/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java b/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java index 7a5d61a4f54..02e0aba1a62 100644 --- a/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java +++ b/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java @@ -24,14 +24,10 @@ package org.cbioportal.test.integration.security; -import dasniko.testcontainers.keycloak.KeycloakContainer; import org.cbioportal.PortalApplication; -import org.cbioportal.test.integration.*; import org.cbioportal.test.integration.security.util.HttpHelper; import org.json.JSONArray; import org.json.JSONException; -import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.junit.jupiter.api.Assertions; import org.junit.runner.RunWith; @@ -40,27 +36,22 @@ import org.mockserver.model.HttpResponse; import org.mockserver.model.StringBody; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; import java.io.IOException; import java.net.URLEncoder; import static org.cbioportal.test.integration.security.OAuth2ResourceServerIntegrationTest.MyMysqlInitializer; import static org.cbioportal.test.integration.security.util.TokenHelper.encodeWithoutSigning; -import static org.cbioportal.test.integration.security.util.Util.isHostMappingPresent; import static org.junit.Assert.assertEquals; /** - * Tests protection of API endpoints by SAML auth + * Tests protection of API endpoints by OIDC data access token */ -// This starts a live portal instance on a random port (imported via @LocalServerPort) @RunWith(SpringRunner.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, @@ -68,8 +59,6 @@ ) @TestPropertySource( properties = { - "app.name=cbioportal", - "server.port=8080", "authenticate=saml", "dat.method=oauth2", // DB settings @@ -90,58 +79,15 @@ } ) @ContextConfiguration(initializers = { - MyMysqlInitializer.class, + MyMysqlInitializer.class }) @DirtiesContext // needed to reuse port 8080 for multiple tests public class OAuth2ResourceServerIntegrationTest extends AbstractContainerTest { - private final static int CBIO_PORT = 8080; public final static String CBIO_URL_FROM_BROWSER = String.format("http://localhost:%d", CBIO_PORT); private final static String tokenUriPath = "/realms/cbio/protocol/openid-connect/token"; - - public final static DockerImageName MOCKSERVER_IMAGE = DockerImageName.parse("mockserver/mockserver") - .withTag("5.15.0"); -// -//// @ClassRule -// public static SharedMysqlContainer mysqlContainer = SharedMysqlContainer.getInstance(); -// -//// @ClassRule -// public static KeycloakContainer keycloakContainer = SharedKeycloakContainer.getInstance(); -// -//// @ClassRule -// public static GenericContainer mongoContainer = SharedMongoContainer.getInstance(); -// -//// @ClassRule -// public static GenericContainer sessionService = SharedSessionServiceContainer.getInstance(); -// -//// @ClassRule -// public static GenericContainer mockKeycloakServer = MockServerContainer.getInstance(); - // Update application properties with connection info on Mysql container - public static class MyMysqlInitializer extends MysqlInitializer { - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - super.initializeImpl(configurableApplicationContext, mysqlContainer); - } - } - - // TODO - move all boilerplate code to a base class - // For these tests to work, the host name 'host.testcontainers.internal' - // must be mapped to 'localhost' in /etc/hosts/ file. - static { - String hostToCheck = "host.testcontainers.internal"; - String ipAddressToCheck = "localhost"; - try { - if (!isHostMappingPresent(hostToCheck, ipAddressToCheck)) { - throw new IllegalStateException(hostToCheck + " is not mapped to " + ipAddressToCheck + " in /etc/hosts. Please add this mapping."); - } - } catch (IOException e) { - throw new RuntimeException("Unable to read /etc/hosts file.", e); - } - } - @Test public void testAccessForbiddenForAnonymousUser() throws IOException { HttpHelper.HttpResponse response = HttpHelper.sendGetRequest(CBIO_URL_FROM_BROWSER + "/api/studies", null, null); diff --git a/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java b/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java index f4a3265c1e7..f5ae67eb281 100644 --- a/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java +++ b/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java @@ -1,23 +1,18 @@ package org.cbioportal.test.integration.security; import org.cbioportal.PortalApplication; -import org.cbioportal.test.integration.MysqlInitializer; -import org.cbioportal.test.integration.SamlKeycloakInitializer; import org.cbioportal.test.integration.security.util.Util; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.ApplicationContextInitializer; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import org.testcontainers.Testcontainers; + +import static org.cbioportal.test.integration.security.AbstractContainerTest.*; @RunWith(SpringRunner.class) @SpringBootTest( @@ -26,9 +21,6 @@ ) @TestPropertySource( properties = { - "app.name=cbioportal", - "server.port=8080", - "filter_groups_by_appname=false", "authenticate=saml", "dat.method=oauth2", // DB settings (also see MysqlInitializer) @@ -50,52 +42,17 @@ } ) @ContextConfiguration(initializers = { - SamlAuthIntegrationTest.MyMysqlInitializer.class, - SamlAuthIntegrationTest.MySamlKeycloakInitializer.class, - SamlAuthIntegrationTest.PortInitializer.class + MyMysqlInitializer.class, + MySamlKeycloakInitializer.class, + PortInitializer.class }) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @DirtiesContext // needed to reuse port 8080 for multiple tests public class SamlAuthIntegrationTest extends AbstractContainerTest { - private final static int CBIO_PORT = 8080; - private final static int KC_PORT = 8084; - private final static int SESSION_PORT = 27017; public final static String CBIO_URL_FROM_BROWSER = String.format("http://host.testcontainers.internal:%d", CBIO_PORT); - // Update application properties with connection info on Keycloak container - public static class MySamlKeycloakInitializer extends SamlKeycloakInitializer { - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - super.initializeImpl(configurableApplicationContext, keycloakContainer); - } - } - - // Update application properties with connection info on Mysql container - public static class MyMysqlInitializer extends MysqlInitializer { - @Override - public void initialize( - ConfigurableApplicationContext configurableApplicationContext) { - super.initializeImpl(configurableApplicationContext, mysqlContainer); - } - } - - // Expose the ports for the cBioPortal Spring application and keycloak inside - // the Chrome container. Each address is available on http://host.testcontainers.internal: - // in the browser container. - public static class PortInitializer implements - ApplicationContextInitializer { - @Override - public void initialize(ConfigurableApplicationContext applicationContext) { - applicationContext.addApplicationListener( - (ApplicationListener) event -> { - Testcontainers.exposeHostPorts(CBIO_PORT, KC_PORT, SESSION_PORT); - }); - } - } - @Test public void a_loginSuccess() { Util.testLogin(CBIO_URL_FROM_BROWSER, chromedriverContainer);