From 8b0589bd5cd6b73c8fc842f257ac98dd7fd56e7b 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 --- 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 dd6ff2230203..febdbfb89ee4 100644 --- a/selenium/test/pageobjects/BasePage.js +++ b/selenium/test/pageobjects/BasePage.js @@ -163,6 +163,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 f9eec1ea8217536590c29b45b081c4498f0a3027 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 --- 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 de820ef9dabb..f59d02ae5d56 100644 --- a/selenium/bin/suite_template +++ b/selenium/bin/suite_template @@ -486,6 +486,12 @@ runWith() { run_local_with $@ fi } +initOnly() { + if [[ "$COMMAND" == "initOnly" ]] + then + init_only $@ + fi +} run_local_with() { export PROFILES="local ${PROFILES}" @@ -536,6 +542,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 e6fe38b504bcda2509fb1b6e849749c8a3b24125 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 --- 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 f59d02ae5d56..e37db8cfeb32 100644 --- a/selenium/bin/suite_template +++ b/selenium/bin/suite_template @@ -544,8 +544,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