From 51f88691d2c525443560ae3be2cd80d1abb1aeed Mon Sep 17 00:00:00 2001 From: Rupal Mahajan Date: Wed, 28 Feb 2024 22:49:19 -0800 Subject: [PATCH] Update condition to select tenant (#65) * Add logs to test Signed-off-by: Rupal Mahajan * Fix invalid username/password error due to missing tenant selection window Signed-off-by: Rupal Mahajan * Remove debug logs Signed-off-by: Rupal Mahajan * Remove Dockerfile Signed-off-by: Rupal Mahajan * Fix tenant condition Signed-off-by: Rupal Mahajan --------- Signed-off-by: Rupal Mahajan --- src/download-helpers.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/download-helpers.js b/src/download-helpers.js index df77af4..6a1bf0b 100644 --- a/src/download-helpers.js +++ b/src/download-helpers.js @@ -208,8 +208,9 @@ const basicAuthentication = async (page, overridePage, url, username, password, await page.type('[data-test-subj="password"]', password); await page.click('button[type=submit]'); await page.waitForTimeout(10000); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -227,7 +228,7 @@ const basicAuthentication = async (page, overridePage, url, username, password, exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(5000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -235,7 +236,7 @@ const basicAuthentication = async (page, overridePage, url, username, password, await overridePage.goto(url, { waitUntil: 'networkidle0' }); await overridePage.waitForTimeout(5000); - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { // Check if tenant was selected successfully. if ((await overridePage.$('button[data-test-subj="confirm"]')) !== null) { spinner.fail('Invalid tenant'); @@ -257,8 +258,9 @@ const samlAuthentication = async (page, url, username, password, tenant, multite await page.type('[name="credentials.passcode"]', password); await page.click('[value="Sign in"]') await page.waitForTimeout(timeout); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -275,7 +277,7 @@ const samlAuthentication = async (page, url, username, password, tenant, multite spinner.fail('Invalid username or password'); exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(2000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -291,8 +293,9 @@ const cognitoAuthentication = async (page, overridePage, url, username, password await page.type('[name="password"]', password); await page.click('[name="signInSubmitButton"]'); await page.waitForTimeout(timeout); + const tenantSelection = await page.$('Select your tenant'); try { - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { if (tenant === 'global' || tenant === 'private') { await page.click('label[for=' + tenant + ']'); } else { @@ -309,7 +312,7 @@ const cognitoAuthentication = async (page, overridePage, url, username, password spinner.fail('Invalid username or password'); exit(1); } - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { await page.waitForTimeout(2000); await page.click('button[data-test-subj="confirm"]'); await page.waitForTimeout(25000); @@ -317,7 +320,7 @@ const cognitoAuthentication = async (page, overridePage, url, username, password await overridePage.goto(url, { waitUntil: 'networkidle0' }); await overridePage.waitForTimeout(5000); - if (multitenancy === true) { + if (multitenancy === true && tenantSelection !== null) { // Check if tenant was selected successfully. if ((await overridePage.$('button[data-test-subj="confirm"]')) !== null) { spinner.fail('Invalid tenant');