Skip to content

Commit

Permalink
Update Saml Security Tests (#10709)
Browse files Browse the repository at this point in the history
* Update Saml Security Tests

* 🔧 Update configs for integration tests

* 🔧 Fix docker-entrypoint to support new spring db props

* Add docker_image to test integration test

* Add Authenticate=false to application.properties

* Test updating PORTAL_HOME

* Revert authenticate property
  • Loading branch information
haynescd authored Mar 14, 2024
1 parent 209bd06 commit d991083
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ jobs:
sed 's|spring.datasource.url=.*|spring.datasource.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
sed 's|spring.datasource.username=.*|spring.datasource.username=cbio_user|' | \
sed 's|spring.datasource.password=.*|spring.datasource.password=somepassword|' \
> application.properties && \
echo "db.user=cbio_user" >> application.properties && \
echo "db.password=somepassword" >> application.properties && \
echo "db.connection_string=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false" >> application.properties && \
echo "db.driver=com.mysql.jdbc.Driver" >> application.properties
> application.properties
- name: 'Copy cgds.sql file into Docker Compose'
run: cp ./cbioportal/src/main/resources/db-scripts/cgds.sql ./cbioportal-docker-compose/data/.
- name: 'Dump Properties'
Expand All @@ -59,7 +55,7 @@ jobs:
- name: 'Start cbioportal-docker-compose'
working-directory: ./cbioportal-docker-compose
run: |
docker-compose -f docker-compose.yml -f $PORTAL_SOURCE_DIR/test/integration/docker-compose-localbuild.yml up -d
export DOCKER_IMAGE_CBIOPORTAL=cbioportal/cbioportal:demo-test-docker-entrypoint && docker-compose -f docker-compose.yml -f $PORTAL_SOURCE_DIR/test/integration/docker-compose-localbuild.yml up -d
- name: 'Wait for cbioportal to initialize ...'
id: startup
uses: nev7n/wait_for_response@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security-integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Security integration tests
on: [pull_request]
on: [push, pull_request]
jobs:
build:
name: Security integration tests
Expand Down
21 changes: 15 additions & 6 deletions docker/web-and-data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _is_sourced() {
}

parse_db_params_from_command_line() {
echo $@ | sed 's/-D/\n-D/g' | grep -- '-Ddb' | sed 's/-D//g' | grep db.
echo $@ | sed 's/-D/\n-D/g' | grep -- '-Dspring' | sed 's/-D//g' | grep db.
}

parse_db_params_from_config_and_command_line() {
Expand All @@ -23,7 +23,7 @@ parse_db_params_from_config_and_command_line() {
else
PROPERTIES_FILE=$BAKED_IN_WAR_CONFIG_FILE
fi
for param in db.host db.user db.portal_db_name db.password db.connection_string; do
for param in db.host spring.datasource.username db.portal_db_name spring.datasource.password spring.datasource.url; do
if $(parse_db_params_from_command_line $@ | grep -q $param); then
prop=$(parse_db_params_from_command_line $@ | grep "^$param" || [[ $? == 1 ]])
else
Expand All @@ -32,8 +32,12 @@ parse_db_params_from_config_and_command_line() {
if [[ -n "$prop" ]]
then
# Replace dot in parameter name with underscore.
prop=$(sed "s/^db\./db_/" <<< $prop)
if [[ $param == db.connection_string ]]
#prop=$(sed "s/\([^=]*\)\./\1_/g" <<< "$prop")
before_equal_sign="${prop%%=*}"
after_equal_sign="${prop#*=}"
updated_before_equal_sign="${before_equal_sign//./_}"
prop="${updated_before_equal_sign}=${after_equal_sign}"
if [[ $param == spring.datasource.url ]]
then
# Remove the parameters (?...) from the connection URL.
echo $(sed -r "s/^([^=]+)=([^\?]+).*/\1=\2/" <<< $prop)
Expand Down Expand Up @@ -74,6 +78,11 @@ check_db_connection() {
then
eval "$(parse_connection_string $db_connection_string)"
fi

if [[ -n $spring_datasource_url ]]
then
eval "$(parse_connection_string $spring_datasource_url)"
fi

if [ -z ${db_port+x} ] # is $db_port unset?
then
Expand All @@ -84,11 +93,11 @@ check_db_connection() {
fi
fi

while ! mysqladmin ping -s -h$(echo ${db_host} | cut -d: -f1) -P${db_port} -u${db_user} -p${db_password};
while ! mysqladmin ping -s -h$(echo ${db_host} | cut -d: -f1) -P${db_port} -u${spring_datasource_username} -p${spring_datasource_password};
do
sleep 5s;
if [ -n "$SHOW_DEBUG_INFO" ] && [ "$SHOW_DEBUG_INFO" != "false" ]; then
echo mysqladmin ping -s -h$(echo ${db_host} | cut -d: -f1) -P${db_port} -u${db_user} -p${db_password}
echo mysqladmin ping -s -h$(echo ${db_host} | cut -d: -f1) -P${db_port} -u${spring_datasource_username} -p${spring_datasource_password}
fi
echo "Database not available yet (first time can take a few minutes to load seed database)... Attempting reconnect..."
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public static void testSamlLogout(String cbioUrl, ChromeDriver 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");
chromeDriver.findElement(By.linkText("Sign out")).click();
Assertions.assertDoesNotThrow(
() -> {
chromeDriver.findElement(By.xpath("//button[text()='Login CBioPortal']"));
}
);
}


Expand Down

0 comments on commit d991083

Please sign in to comment.