From 862b239f178e8cd295e650f10095190dd374495d Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 12 Mar 2025 10:31:34 +0100 Subject: [PATCH 1/3] Add missing function that checks if element is not visible (cherry picked from commit 8b0589bd5cd6b73c8fc842f257ac98dd7fd56e7b) (cherry picked from commit f18d0e628d68cfb7f5baa6b99dfcece716371349) --- selenium/test/oauth/with-idp-down/landing.js | 2 +- selenium/test/pageobjects/BasePage.js | 21 ++++++++++++++++++++ selenium/test/pageobjects/SSOHomePage.js | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/selenium/test/oauth/with-idp-down/landing.js b/selenium/test/oauth/with-idp-down/landing.js index 5e23e8df807c..a096e11f6ada 100644 --- a/selenium/test/oauth/with-idp-down/landing.js +++ b/selenium/test/oauth/with-idp-down/landing.js @@ -26,7 +26,7 @@ describe('When UAA is down', function () { it('should not be presented with a login button to log in', async function () { await homePage.isLoaded() - assert.equal(false, await homePage.isLoginButtonVisible()) + assert.ok(await homePage.isLoginButtonNotVisible()) }) after(async function () { diff --git a/selenium/test/pageobjects/BasePage.js b/selenium/test/pageobjects/BasePage.js index b31ba216a56b..22df570bbc5a 100644 --- a/selenium/test/pageobjects/BasePage.js +++ b/selenium/test/pageobjects/BasePage.js @@ -162,6 +162,27 @@ module.exports = class BasePage { }) */ } + + async isPopupWarningNotDisplayed() { + return this.isElementNotVisible(FORM_POPUP) + } + + async isElementNotVisible(locator) { + try { + await this.driver.wait(async() => { + try { + const element = await this.driver.findElement(locator) + const visible = await element.isDisplayed() + return !visible + } catch (error) { + return true + } + }, this.timeout) + return true + } catch (error) { + return false + } + } async getPopupWarning() { let element = await driver.findElement(FORM_POPUP) return this.driver.wait(until.elementIsVisible(element), this.timeout, diff --git a/selenium/test/pageobjects/SSOHomePage.js b/selenium/test/pageobjects/SSOHomePage.js index 38ef6f3af3c2..9b22aea3087d 100644 --- a/selenium/test/pageobjects/SSOHomePage.js +++ b/selenium/test/pageobjects/SSOHomePage.js @@ -51,6 +51,9 @@ module.exports = class SSOHomePage extends BasePage { async getOAuthResourceOptions () { return this.getSelectableOptions(SELECT_RESOURCES) } + async isLoginButtonNotVisible() { + return this.isElementNotVisible(OAUTH2_LOGIN_BUTTON) + } async isLoginButtonVisible() { try { await this.waitForDisplayed(OAUTH2_LOGIN_BUTTON) From a061f01fdee371e6eda206f5600cf97d8f6e9ce0 Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 12 Mar 2025 11:54:09 +0100 Subject: [PATCH 2/3] Add initOnly function For scenarios where rabbitmq needs the certificates of an idp but the idp has not been started yet and hence the cert has not been generated With this function, the idp generates its certificates without starting (cherry picked from commit f9eec1ea8217536590c29b45b081c4498f0a3027) (cherry picked from commit 2fe3518b8a18bdd5fc89730ea8fcb39a4b3dbc7f) --- selenium/bin/suite_template | 15 +++++++++++++++ .../multi-oauth-with-basic-auth-when-idps-down.sh | 1 + 2 files changed, 16 insertions(+) diff --git a/selenium/bin/suite_template b/selenium/bin/suite_template index ccea295f5a1e..736370315c6f 100644 --- a/selenium/bin/suite_template +++ b/selenium/bin/suite_template @@ -479,6 +479,12 @@ runWith() { run_local_with $@ fi } +initOnly() { + if [[ "$COMMAND" == "initOnly" ]] + then + init_only $@ + fi +} run_local_with() { export PROFILES="local ${PROFILES}" @@ -529,6 +535,15 @@ determine_required_components_excluding_rabbitmq() { fi } } +initOnly() { + for (( i=1; i<=$#; i++)) { + if [[ $i != "rabbitmq" ]]; then + eval val='$'$i + init="init_$val" + $init + fi + } +} run_on_docker_with() { determine_required_components_including_rabbitmq $@ export PROFILES=`profiles_with_local_or_docker` diff --git a/selenium/suites/authnz-mgt/multi-oauth-with-basic-auth-when-idps-down.sh b/selenium/suites/authnz-mgt/multi-oauth-with-basic-auth-when-idps-down.sh index 1bea7e906036..8b46c5e0d7fc 100755 --- a/selenium/suites/authnz-mgt/multi-oauth-with-basic-auth-when-idps-down.sh +++ b/selenium/suites/authnz-mgt/multi-oauth-with-basic-auth-when-idps-down.sh @@ -7,4 +7,5 @@ TEST_CONFIG_PATH=/multi-oauth PROFILES="devkeycloak prodkeycloak enable-basic-auth with-resource-label with-resource-scopes tls" source $SCRIPT/../../bin/suite_template $@ +initOnly devkeycloak prodkeycloak run From 4604bcface332d5412dc8b2f90f1b441608fe34e Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 12 Mar 2025 13:12:26 +0100 Subject: [PATCH 3/3] Fix issue thanks to @zerpet (cherry picked from commit e6fe38b504bcda2509fb1b6e849749c8a3b24125) (cherry picked from commit c66bb403730ee4b14ef1f0cf5487a2bf6ffad423) --- selenium/bin/suite_template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selenium/bin/suite_template b/selenium/bin/suite_template index 736370315c6f..2d07565d6ddd 100644 --- a/selenium/bin/suite_template +++ b/selenium/bin/suite_template @@ -537,8 +537,8 @@ determine_required_components_excluding_rabbitmq() { } initOnly() { for (( i=1; i<=$#; i++)) { - if [[ $i != "rabbitmq" ]]; then - eval val='$'$i + eval val='$'$i + if [[ $val != "rabbitmq" ]]; then init="init_$val" $init fi