Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update condition to select tenant #65

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/download-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if tenant selection is null, is it possible that the Select your tenant popup didn't show up but user is still in a wrong tenant?

for example the dashboard is in global tenant but after login, user is in private tenant and the Select your tenant didn't show up, would that happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't happen when report is generated with short URL with tenant info. e.g. https://<domain>.us-west-2.on.aws/_dashboards/goto/8fa30d307ea81f81a5edc692e189c297?security_tenant=global

if (tenant === 'global' || tenant === 'private') {
await page.click('label[for=' + tenant + ']');
} else {
Expand All @@ -227,15 +228,15 @@ 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);
}
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');
Expand All @@ -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 {
Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -309,15 +312,15 @@ 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);
}
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');
Expand Down
Loading