diff --git a/.github/workflows/security-integration-test.yml b/.github/workflows/security-integration-test.yml
index 2cccb95f25c..5fd20693a50 100644
--- a/.github/workflows/security-integration-test.yml
+++ b/.github/workflows/security-integration-test.yml
@@ -24,9 +24,8 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- - name: 'Add host.testcontainers.internal to /etc/hosts'
- run: |
- echo "127.0.0.1 host.testcontainers.internal" | sudo tee -a /etc/hosts
+ - name: 'Download Chrome'
+ uses: browser-actions/setup-chrome@latest
- name: 'Copy Application.Properties'
working-directory: ./cbioportal
run: |
diff --git a/pom.xml b/pom.xml
index c883c4ac2d0..9a442e2d7ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,7 +73,7 @@
1.6.3
3.0.2
- 1.19.3
+ 1.19.4
5.15.0
4.1.1
@@ -96,6 +96,7 @@
5.1.48
3.2.0
3.14.0
+ 4.17.0
7.1.0
@@ -277,6 +278,7 @@
org.seleniumhq.selenium
selenium-java
+ ${selenium.version}
test
diff --git a/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java b/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java
index 78943a9439d..ea8b64b507f 100644
--- a/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java
+++ b/src/test/java/org/cbioportal/test/integration/OAuth2KeycloakInitializer.java
@@ -18,7 +18,7 @@ public void initializeImpl(ConfigurableApplicationContext configurableApplicatio
try {
String keycloakUrlForCBioportal = keycloakContainer.getAuthServerUrl();
- String keycloakUrlForBrowser = String.format("http://host.testcontainers.internal:%s", keycloakContainer.getHttpPort());
+ String keycloakUrlForBrowser = String.format("http://localhost:%s", keycloakContainer.getHttpPort());
TestPropertyValues values = TestPropertyValues.of(
diff --git a/src/test/java/org/cbioportal/test/integration/security/ContainerConfig.java b/src/test/java/org/cbioportal/test/integration/security/ContainerConfig.java
index a5f02e12507..b74ff9c542d 100644
--- a/src/test/java/org/cbioportal/test/integration/security/ContainerConfig.java
+++ b/src/test/java/org/cbioportal/test/integration/security/ContainerConfig.java
@@ -1,10 +1,11 @@
package org.cbioportal.test.integration.security;
import dasniko.testcontainers.keycloak.KeycloakContainer;
-import org.cbioportal.test.integration.OAuth2ResourceServerKeycloakInitializer;
import org.cbioportal.test.integration.MysqlInitializer;
import org.cbioportal.test.integration.OAuth2KeycloakInitializer;
+import org.cbioportal.test.integration.OAuth2ResourceServerKeycloakInitializer;
import org.cbioportal.test.integration.SamlKeycloakInitializer;
+import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.context.WebServerInitializedEvent;
@@ -13,70 +14,62 @@
import org.springframework.context.ConfigurableApplicationContext;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BindMode;
-import org.testcontainers.containers.BrowserWebDriverContainer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MySQLContainer;
+import org.testcontainers.containers.Network;
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
import org.testcontainers.utility.DockerImageName;
-import java.io.File;
-import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
-import static org.cbioportal.test.integration.security.util.Util.isHostMappingPresent;
-import static org.testcontainers.containers.BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL;
-
public class ContainerConfig {
-
+
public final static int CBIO_PORT = 8080;
public final static int SESSION_SERVICE_PORT = 5000;
public final static int MONGO_PORT = 27017;
- public final static int MYSQL_PORT = 3306;
+
+ public final static String MONGO_NETWORK = "mongo-network";
public final static int MOCKSERVER_PORT = 8085;
public final static String DOWNLOAD_FOLDER = "/tmp/browser_downloads";
-
+
private static final String SESSION_IMAGE_VERSION = "docker.io/cbioportal/session-service:0.6.1";
private static final String MONGO_IMAGE_VERSION = "docker.io/mongo:3.7.9";
private static final String KEYCLOAK_IMAGE_VERSION = "quay.io/keycloak/keycloak:22.0.5";
private static final String MYSQL_IMAGE_VERSION = "mysql:5.7";
private static final String MOCKSERVER_IMAGE_VERSION = "docker.io/mockserver/mockserver:5.15.0";
- static final GenericContainer sessionServiceContainer;
- static final GenericContainer mongoContainer;
static final MySQLContainer mysqlContainer;
static final GenericContainer mockServerContainer;
static final KeycloakContainer keycloakContainer;
- static final BrowserWebDriverContainer chromedriverContainer;
+ static final ChromeDriver chromeDriver;
- static {
+ static final GenericContainer sessionServiceContainer;
+ static final GenericContainer mongoContainer;
- String hostToCheck = "host.testcontainers.internal";
- String ipAddressToCheck = "127.0.0.1";
- 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);
- }
+ static {
+
+ Network mongoNetwork = Network.newNetwork();
+ mongoContainer = new GenericContainer(DockerImageName.parse(MONGO_IMAGE_VERSION))
+ .withNetwork(mongoNetwork)
+ .withNetworkAliases(MONGO_NETWORK)
+ .withAccessToHost(true)
+ .withEnv("MONGO_INITDB_DATABASE", "session_service");
+ String mongoConnectionString = String.format("-Dspring.data.mongodb.uri=mongodb://%s:%s/session-service",MONGO_NETWORK, MONGO_PORT);
sessionServiceContainer = new GenericContainer(DockerImageName.parse(SESSION_IMAGE_VERSION))
+ .withNetwork(mongoNetwork)
.withAccessToHost(true)
.withEnv("SERVER_PORT", "5000")
- .withEnv("JAVA_OPTS", "-Dspring.data.mongodb.uri=mongodb://host.testcontainers.internal:27017/session-service");
+ .withEnv("JAVA_OPTS", mongoConnectionString);
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");
- mongoContainer.setPortBindings(ImmutableList.of(String.format("%s:27017", MONGO_PORT, MONGO_PORT)));
-
keycloakContainer = new KeycloakContainer(KEYCLOAK_IMAGE_VERSION)
.withRealmImportFile("security/keycloak-configuration-generated.json")
.withAdminUsername("admin")
.withAdminPassword("admin")
- .withEnv("KC_HOSTNAME", "host.testcontainers.internal")
+ .withEnv("KC_HOSTNAME", "localhost")
.withEnv("KC_HOSTNAME_ADMIN", "localhost");
mockServerContainer = new GenericContainer(MOCKSERVER_IMAGE_VERSION)
@@ -89,25 +82,22 @@ public class ContainerConfig {
.withStartupTimeout(Duration.ofMinutes(10));
ChromeOptions options = new ChromeOptions();
+ options.addArguments("--no-sandbox");
+ options.addArguments("--disable-dev-shm-usage");
+ options.addArguments("--headless");
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);
+ chromeDriver = new ChromeDriver(options);
- chromedriverContainer = new BrowserWebDriverContainer<>()
- .withCapabilities(options)
- // activate this to record movies of the tests (great for debugging)
- .withRecordingMode(RECORD_ALL, new File("/home/pnp300/"))
- .withAccessToHost(true);
-
- mysqlContainer.start();
- sessionServiceContainer.start();
mongoContainer.start();
+ sessionServiceContainer.start();
+ mysqlContainer.start();
mockServerContainer.start();
keycloakContainer.start();
- chromedriverContainer.start();
}
// Update application properties with connection info on Keycloak container
@@ -158,8 +148,7 @@ public void initialize(ConfigurableApplicationContext applicationContext) {
values.applyTo(applicationContext);
applicationContext.addApplicationListener(
(ApplicationListener) event -> {
- Testcontainers.exposeHostPorts(CBIO_PORT, keycloakContainer.getHttpPort(), MONGO_PORT);
- keycloakContainer.setPortBindings(ImmutableList.of(String.format("%s:8080", keycloakContainer.getHttpPort())));
+ Testcontainers.exposeHostPorts(CBIO_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 fae45791315..1b580f2a2eb 100644
--- a/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java
+++ b/src/test/java/org/cbioportal/test/integration/security/OAuth2AuthIntegrationTest.java
@@ -2,10 +2,8 @@
import org.cbioportal.PortalApplication;
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.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -41,7 +39,7 @@
"dat.oauth2.clientId=cbioportal_oauth2",
"dat.oauth2.clientSecret=client_secret",
// Redirect URL to cBiopPortal application from perspective of browser
- "dat.oauth2.redirectUri=http://host.testcontainers.internal:8080/api/data-access-token/oauth2",
+ "dat.oauth2.redirectUri=http://localhost:8080/api/data-access-token/oauth2",
"dat.oauth2.jwtRolesPath=resource_access::cbioportal::roles",
"session.service.url=http://localhost:5000/api/sessions/my_portal/",
"filter_groups_by_appname=false"
@@ -53,31 +51,30 @@
MyOAuth2KeycloakInitializer.class,
PortInitializer.class
})
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@DirtiesContext // needed to reuse port 8080 for multiple tests
+@DirtiesContext
public class OAuth2AuthIntegrationTest extends ContainerConfig {
public final static String CBIO_URL_FROM_BROWSER =
- String.format("http://host.testcontainers.internal:%d", CBIO_PORT);
+ String.format("http://localhost:%d", CBIO_PORT);
@Test
public void a_loginSuccess() {
- Util.testLogin(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testLogin(CBIO_URL_FROM_BROWSER, chromeDriver);
}
@Test
public void b_downloadOfflineToken() throws Exception {
- Util.testDownloadOfflineToken(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testDownloadOfflineToken(CBIO_URL_FROM_BROWSER, chromeDriver);
}
@Test
public void c_logoutSuccess() {
- Util.testLogout(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testOAuthLogout(CBIO_URL_FROM_BROWSER, chromeDriver);
}
@Test
public void d_loginAgainSuccess() {
- Util.testLoginAgain(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testLoginAgain(CBIO_URL_FROM_BROWSER, chromeDriver);
}
}
\ No newline at end of file
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 4ddb4b409be..bdb48da1146 100644
--- a/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java
+++ b/src/test/java/org/cbioportal/test/integration/security/OAuth2ResourceServerIntegrationTest.java
@@ -24,7 +24,6 @@
package org.cbioportal.test.integration.security;
-import org.cbioportal.PortalApplication;
import org.cbioportal.test.integration.security.util.HttpHelper;
import org.json.JSONArray;
import org.json.JSONException;
@@ -55,8 +54,7 @@
*/
@RunWith(SpringRunner.class)
@SpringBootTest(
- webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
- classes = {PortalApplication.class}
+ webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT
)
@TestPropertySource(
properties = {
@@ -71,10 +69,10 @@
"spring.security.saml2.relyingparty.registration.keycloak.signing.credentials[0].private-key-location=classpath:dev/security/signing-key.pem",
"dat.oauth2.clientId=client_id",
"dat.oauth2.clientSecret=client_secret",
- "dat.oauth2.redirectUri=http://host.testcontainers.internal:8080/api/data-access-token/oauth2",
+ "dat.oauth2.redirectUri=http://localhost:8080/api/data-access-token/oauth2",
// host is the mock server that fakes the oidc idp
- "dat.oauth2.accessTokenUri=http://host.testcontainers.internal:8085/realms/cbio/protocol/openid-connect/token",
- "dat.oauth2.userAuthorizationUri=http://host.testcontainers.internal:8085/realms/cbio/protocol/openid-connect/auth",
+ "dat.oauth2.accessTokenUri=http://localhost:8085/realms/cbio/protocol/openid-connect/token",
+ "dat.oauth2.userAuthorizationUri=http://localhost:8085/realms/cbio/protocol/openid-connect/auth",
"dat.oauth2.jwtRolesPath=resource_access::cbioportal::roles",
"filter_groups_by_appname=false"
}
@@ -83,11 +81,12 @@
MyMysqlInitializer.class,
MyOAuth2ResourceServerKeycloakInitializer.class
})
-@DirtiesContext // needed to reuse port 8080 for multiple tests
+@DirtiesContext
public class OAuth2ResourceServerIntegrationTest extends ContainerConfig {
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";
@Test
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 dea0b471bdf..cefa6844f2c 100644
--- a/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java
+++ b/src/test/java/org/cbioportal/test/integration/security/SamlAuthIntegrationTest.java
@@ -1,11 +1,8 @@
package org.cbioportal.test.integration.security;
-import org.cbioportal.PortalApplication;
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.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -18,8 +15,7 @@
@RunWith(SpringRunner.class)
@SpringBootTest(
- webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
- classes = {PortalApplication.class}
+ webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT
)
@TestPropertySource(
properties = {
@@ -51,26 +47,25 @@
MySamlKeycloakInitializer.class,
PortInitializer.class
})
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@DirtiesContext // needed to reuse port 8080 for multiple tests
+@DirtiesContext
public class SamlAuthIntegrationTest extends ContainerConfig {
public final static String CBIO_URL_FROM_BROWSER =
- String.format("http://host.testcontainers.internal:%d", CBIO_PORT);
-
+ String.format("http://localhost:%d", CBIO_PORT);
+
@Test
public void a_loginSuccess() {
- Util.testLogin(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testLogin(CBIO_URL_FROM_BROWSER, chromeDriver);
}
@Test
public void b_testAuthorizedStudy() {
- Util.testLoginAndVerifyStudyNotPresent(CBIO_URL_FROM_BROWSER,chromedriverContainer );
+ Util.testLoginAndVerifyStudyNotPresent(CBIO_URL_FROM_BROWSER,chromeDriver );
}
@Test
public void c_logoutSuccess() {
- Util.testLogout(CBIO_URL_FROM_BROWSER, chromedriverContainer);
+ Util.testSamlLogout(CBIO_URL_FROM_BROWSER, chromeDriver);
}
}
\ No newline at end of file
diff --git a/src/test/java/org/cbioportal/test/integration/security/util/Util.java b/src/test/java/org/cbioportal/test/integration/security/util/Util.java
index e92e95c179d..d81dc0f2420 100644
--- a/src/test/java/org/cbioportal/test/integration/security/util/Util.java
+++ b/src/test/java/org/cbioportal/test/integration/security/util/Util.java
@@ -5,113 +5,96 @@
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
-import org.springframework.util.Assert;
-import org.testcontainers.containers.BrowserWebDriverContainer;
-import org.testcontainers.containers.Container;
-import org.testcontainers.containers.GenericContainer;
-import javax.annotation.Nonnull;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
+import java.io.File;
import java.time.Duration;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import static org.testcontainers.shaded.org.awaitility.Awaitility.await;
public class Util {
- public static boolean isHostMappingPresent(String host, String ipAddress) throws IOException {
- String hostsFilePath = "/etc/hosts";
- BufferedReader reader = new BufferedReader(new FileReader(hostsFilePath));
- String line;
-
- try {
- while ((line = reader.readLine()) != null) {
- if (line.contains(host) && line.contains(ipAddress)) {
- return true;
- }
- }
- } finally {
- reader.close();
- }
-
- return false;
- }
-
- public static void testLogin(String cbioUrl, BrowserWebDriverContainer chromedriverContainer) {
- RemoteWebDriver driver = chromedriverContainer.getWebDriver();
- performLogin(cbioUrl, driver);
- WebElement loggedInButton = driver.findElement(By.id("dat-dropdown"));
+ public static void testLogin(String cbioUrl, ChromeDriver chromedriver) {
+ performLogin(cbioUrl, chromedriver);
+ WebElement loggedInButton = chromedriver.findElement(By.id("dat-dropdown"));
Assertions.assertEquals("Logged in as testuser@thehyve.nl", loggedInButton.getText());
- new WebDriverWait(driver, Duration.ofSeconds(20)).until(
+ new WebDriverWait(chromedriver, Duration.ofSeconds(20)).until(
ExpectedConditions.presenceOfElementLocated(By.xpath("//span[.='Breast Invasive Carcinoma (TCGA,Nature 2012)']")));
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.xpath("//span[.='Breast Invasive Carcinoma (TCGA,Nature 2012)']")),
+ () -> chromedriver.findElement(By.xpath("//span[.='Breast Invasive Carcinoma (TCGA,Nature 2012)']")),
"Study could not be found on the landing page. Permissions are not correctly passed from IDP to client.");
}
- public static void testLoginAndVerifyStudyNotPresent(String cbioUrl, BrowserWebDriverContainer chromedriverContainer) {
- RemoteWebDriver driver = chromedriverContainer.getWebDriver();
- performLogin(cbioUrl, driver);
- WebElement loggedInButton = driver.findElement(By.id("dat-dropdown"));
+ public static void testLoginAndVerifyStudyNotPresent(String cbioUrl, ChromeDriver chromeDriver) {
+ performLogin(cbioUrl, chromeDriver);
+ WebElement loggedInButton = chromeDriver.findElement(By.id("dat-dropdown"));
Assertions.assertEquals("Logged in as testuser@thehyve.nl", loggedInButton.getText());
- new WebDriverWait(driver, Duration.ofSeconds(20)).until(
+ new WebDriverWait(chromeDriver, Duration.ofSeconds(20)).until(
ExpectedConditions.presenceOfElementLocated(By.xpath("//span[.='Breast Invasive Carcinoma (TCGA,Nature 2012)']")));
Assertions.assertThrows(
NoSuchElementException.class,
- () -> driver.findElement(By.xpath("//span[.='Adrenocortical Carcinoma (TCGA, Provisional)']")),
+ () -> chromeDriver.findElement(By.xpath("//span[.='Adrenocortical Carcinoma (TCGA, Provisional)']")),
"Study could not be found on the landing page. Permissions are not correctly passed from IDP to client.");
}
- public static void testDownloadOfflineToken(String cbioUrl, BrowserWebDriverContainer chromedriverContainer) throws Exception {
- RemoteWebDriver driver = chromedriverContainer.getWebDriver();
- performLogin(cbioUrl, driver);
+ public static void testDownloadOfflineToken(String cbioUrl, ChromeDriver chromeDriver) throws Exception {
+ performLogin(cbioUrl, chromeDriver);
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("dat-dropdown")).click(),
+ () -> chromeDriver.findElement(By.id("dat-dropdown")).click(),
"Logged-in menu could not be found on the page.");
- driver.findElement(By.linkText("Data Access Token")).click();
- driver.findElement(By.xpath("//button[text()='Download Token']")).click();
-
- await().atMost(Duration.ofSeconds(5)).until(downloadedFile(chromedriverContainer));
+ chromeDriver.findElement(By.linkText("Data Access Token")).click();
+ chromeDriver.findElement(By.xpath("//button[text()='Download Token']")).click();
- Assertions.assertTrue(downloadedFile(chromedriverContainer ).call());
+ var file = new File(String.format("%s/cbioportal_data_access_token.txt",
+ ContainerConfig.DOWNLOAD_FOLDER));
+ await().atMost(Duration.ofSeconds(5)).until(file::exists);
+ Assertions.assertTrue(file.exists());
}
- public static void testLogout(String cbioUrl, BrowserWebDriverContainer chromedriverContainer) {
- RemoteWebDriver driver = chromedriverContainer.getWebDriver();
- performLogin(cbioUrl, driver);
+ public static void testOAuthLogout(String cbioUrl, ChromeDriver chromeDriver) {
+ performLogin(cbioUrl, chromeDriver);
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("dat-dropdown")).click(),
+ () -> chromeDriver.findElement(By.id("dat-dropdown")).click(),
"Logout menu could not be found on the page.");
- driver.findElement(By.linkText("Sign out")).click();
+ //chromeDriver.findElement(By.linkText("Sign out")).click();
// TODO: Remove when sync'd with frontend
- driver.get(cbioUrl + "/logout");
+ chromeDriver.get(cbioUrl + "/logout");
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("username")),
- "IDP login screen not visible on the page. Logout did not work correctly."
- );
+ () -> chromeDriver.findElement(By.id("username")),
+ "IDP login screen not visible on the page. Logout did not work correctly.");
}
+
+ public static void testSamlLogout(String cbioUrl, ChromeDriver chromeDriver) {
+ performLogin(cbioUrl, chromeDriver);
+ Assertions.assertDoesNotThrow(
+ () -> chromeDriver.findElement(By.id("dat-dropdown")).click(),
+ "Logout menu could not be found on the page.");
+ //chromeDriver.findElement(By.linkText("Sign out")).click();
+ // TODO: Remove when sync'd with frontend
+ chromeDriver.get(cbioUrl + "/logout");
+ Assertions.assertEquals(chromeDriver.getCurrentUrl(), cbioUrl + "/login?logout_success");
+ }
+
- public static void testLoginAgain(String cbioUrl, BrowserWebDriverContainer chromedriverContainer) {
- RemoteWebDriver driver = chromedriverContainer.getWebDriver();
- performLogin(cbioUrl, driver);
+
+ public static void testLoginAgain(String cbioUrl, ChromeDriver chromeDriver) {
+ performLogin(cbioUrl, chromeDriver);
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("dat-dropdown")).click(),
+ () -> chromeDriver.findElement(By.id("dat-dropdown")).click(),
"Logout menu could not be found on the page.");
- driver.get(cbioUrl + "/logout");
- driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
+ chromeDriver.get(cbioUrl + "/logout");
+ chromeDriver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("username")),
+ () -> chromeDriver.findElement(By.id("username")),
"IDP login screen not visible on the page. Logout did not work correctly."
);
- performLogin(cbioUrl, driver);
+ performLogin(cbioUrl, chromeDriver);
Assertions.assertDoesNotThrow(
- () -> driver.findElement(By.id("dat-dropdown")),
+ () -> chromeDriver.findElement(By.id("dat-dropdown")),
"Logged-in menu could not be found on the page. Login did not work correctly.");
}
@@ -129,29 +112,8 @@ private static void performLogin(String url, RemoteWebDriver driver) {
passwordInput.sendKeys("P@ssword1");
loginButton.click();
}
- // wait for the page to load
-// driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
new WebDriverWait(driver, Duration.ofSeconds(20)).until(
ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@data-test='cancerTypeListContainer']")));
}
- private static boolean containerFileExists(
- @Nonnull final GenericContainer container, @Nonnull String path)
- throws IOException, InterruptedException {
- Assert.notNull(container, "Containers is null");
- Assert.isTrue(!path.isEmpty(), "Path string is empty");
- Container.ExecResult r = container.execInContainer("/bin/sh", "-c",
- "if [ -f " + path
- + " ] ; then echo '0' ; else (>&2 echo '1') ; fi");
- boolean fileNotFound = r.getStderr().contains("1");
- container.execInContainer("rm -f " + path);
- return !fileNotFound;
- }
-
- private static Callable downloadedFile(GenericContainer chromedriverContainer) {
- return () -> containerFileExists(chromedriverContainer,
- String.format("%s/cbioportal_data_access_token.txt",
- ContainerConfig.DOWNLOAD_FOLDER));
- }
-
}
diff --git a/src/test/resources/security/keycloak-configuration-generated.json b/src/test/resources/security/keycloak-configuration-generated.json
index b13e59f45aa..6aa760d1f49 100644
--- a/src/test/resources/security/keycloak-configuration-generated.json
+++ b/src/test/resources/security/keycloak-configuration-generated.json
@@ -282,18 +282,16 @@
{
"id": "4b5c2aa6-bc44-458d-ac1f-1a2166520f4d",
"clientId": "cbioportal",
- "adminUrl": "http://host.testcontainers.internal:8084/saml",
+ "adminUrl": "",
"surrogateAuthRequired": false,
"enabled": true,
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-secret",
"redirectUris": [
- "http://host.testcontainers.internal:8080/*",
- "http://host.testcontainers.internal:8088/*",
- "http://host.testcontainers.internal:8089/*"
+ "http://localhost:8080/*"
],
"webOrigins": [
- "http://host.testcontainers.internal:8080"
+ "http://localhost:8080"
],
"notBefore": 0,
"bearerOnly": false,
@@ -308,7 +306,7 @@
"attributes": {
"saml.assertion.signature": "false",
"saml.force.post.binding": "false",
- "saml_single_logout_service_url_post": "http://host.testcontainers.internal:8080/logout/saml2/slo",
+ "saml_single_logout_service_url_post": "http://localhost:8080/login?logout_success",
"signing.private.key": "MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDJTDNHzHv19kM4tVLOIjpR/vez4QJk70PMbghQBdCp1Er1yU8GkQRMx0QtumQB2ML1p2f63EEd7WsAPMEVYNQv6MHJDhAIDt+npWmYrGl3PrkVA3GNzZcD+GQEMZdGcECvfocOy2tB6iMOhdnFqu4L/QfFG2yJ+CpimpijvW78cJ35oYmOTnD7R9LBAJQuBlQDpOvB+I/dFeCiNKw61HQy0nMf6oe0pBy4E7bImQ0HY/soxBnzbvPUzbBvnhb2d97l3wn6ElUMrZuQSyI+OyVgBMyv9gcgV4Wq16oEuNkWFIdY2j8GeiDlqy9KJAttgLXBjGua2lRML0a+nrfF1VbBLgyzAZZP2IS/P3QYcSE2GbPWiWXjov2vF63/VnARzQhPhuLGilWp1Nxqr0HztgSiAyx0D3wqEBic0ERAQDVuHQZdjPd7RJaJ6MBnZH9mMVQOrjspIP5Sc6Z7omou26LPTjWNwmNWnfrq1sU8ADg4Uj09PWYcuWhPKxe6K9Zm4PLGXA0fR/fCVPDKaJPXIC7FGzDDdh/uSb9OURlgHwe319FCdvm1k7xD6tEfsyORjWJFoYvyT015j9LdBuO5fwt40EPCzNezqWCaimES7u3Puyg+4mbnRDh1UuouHOHVZ4jWySrrEktI0l6JkxrqdT2ilw7ICtmFx2fsjO9qso4tGwIDAQABAoICAFT7iprBRYQtl2uVgYPtB1oenkyerfgW2zSvL2s5SUKpkYv6lRZcmsgfSDVV/2qYLJaxOkC6Q/NyjD3paEqyOmKPjWBoQ3RjcyC/wLjn8Q6auGCat5H6Pcs7Tl5G4WqncWelrzcbwght5Kb481t0MlN1W5ZnYYdN8fb29YILM5P3p3oALKabjy9Gvz8kE2rq2QVA1xdo7LOVzOQuAJhFoVjjaB8NUIV+03ETQZOmqc149EvdnmcbbG1m+RnmUCN1r/C0HO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tGwIDAQABo1MwUTAdBgNVHQ4EFgQU0JL52xvzhG/48H01Rxac3MOgZYEwHwYDVR0jBBgwFoAU0JL52xvzhG/48H01Rxac3MOgZYEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAYYbj4v37eUTo9mtWgtZ2hHjWtdScPlZGxZanPZZpAcN8JR07ps/wow68rQMOZR9hFS6c2+izbn3HkR3OwCK9sZeuWzrLVPUBSiXxEbRkpK/pXAd/Irat+f1ylA3j3J4VyDJymqiuIBOE9kzGWpbMdyqlHdH5XG/giLEOY66p6k5QrtKDXKzfQ7BBzO1WTe1BkWp7HerEKqM7mRSA4pRT5J7UAGn4gHOU39bnOHZPhko/rFagI2iO8T3fSBL+IWx76ROoG3DUnaZmDIuMxzeEZD7G8aPWOJCP0/mnBrAQhsEUg0bcsRa6qzWFigY4oWjxOSc2aQMRSjxrVf59Geplyhh8AY0yI49uhJJc6SztwuiX9fksCm1/Z9YZeeJr/oOkBduGpX6BQbPA7N2yKg5APdn8DVIHFALijwobz+94+d6uv4+ihlQ8jBgbo1kwMZps+BAVOODgX3RpFKmqcyX9bjWaapw+XE1U8Rtt3mcgN9qchvcIqcnGZ1PfaY1ultvAzUa4TCECiYRXSOXT4iAXv+M1i2XisuThtw7dC9HMY1D/0oA/cRxwknLsuKRRGJWbUN/Ts4GMjLmvKejQOWfS+/wHS9kQdPKS3BKZYQgqli4OG1xRErykL6SRWTKJA3+VNditbHFkJuL9dGZLu0Dmaww6K1SSnYai77uTTPdOHoc=",
@@ -363,12 +361,10 @@
"clientAuthenticatorType": "client-secret",
"secret": "client_secret",
"redirectUris": [
- "http://host.testcontainers.internal:8080/*",
- "http://host.testcontainers.internal:8088/*",
- "http://host.testcontainers.internal:8089/*"
+ "http://localhost:8080/*"
],
"webOrigins": [
- "http://host.testcontainers.internal:8080"
+ "http://localhost:8080"
],
"notBefore": 0,
"bearerOnly": false,