From f794c3947b7a05775abbeb968a3f381a0d5f69a2 Mon Sep 17 00:00:00 2001 From: Ryan Liang Date: Wed, 15 Nov 2023 17:00:56 -0800 Subject: [PATCH] Finish refactoring 1st test case of oidc Signed-off-by: Ryan Liang --- .cypress/e2e/oidc/oidc_test.spec.js | 45 +++++++++++++++++------------ .eslintignore | 1 + package.json | 2 +- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.cypress/e2e/oidc/oidc_test.spec.js b/.cypress/e2e/oidc/oidc_test.spec.js index 5ed0ac32b..289393421 100644 --- a/.cypress/e2e/oidc/oidc_test.spec.js +++ b/.cypress/e2e/oidc/oidc_test.spec.js @@ -18,30 +18,39 @@ * SPDX-License-Identifier: Apache-2.0 */ +const login = 'admin'; +const password = 'admin'; +const tenantLocalStorageKey = 'opendistro::security::tenant::saved'; +const globalTenantLocalStorageValue = '\"\"'; +const newThemeModalLocalStorageKey = 'home:newThemeModal:show' + describe('Log in via OIDC', () => { - const login = 'admin'; - const password = 'admin'; + + after(() => { + cy.clearCookies(); + cy.clearLocalStorage(); + }); const kcLogin = () => { - cy.get('#kc-page-title', { timeout: 10000 }).should('be.visible'); - cy.get('#username').type(login); - cy.get('#password').type(password); + cy.get('#kc-page-title', { timeout: 15000 }).should('be.visible'); + cy.get('input[id=username]', { timeout: 15000}).should('be.visible').type(login); + cy.get('input[id=password]', { timeout: 15000}).should('be.visible').type(password); cy.get('#kc-login').click(); }; it('Login to app/opensearch_dashboards_overview#/ when OIDC is enabled', () => { - cy.visit('http://localhost:5601/app/opensearch_dashboards_overview#/', { failOnStatusCode: false, timeout: 10000 }); - - cy.wait(15000); - + cy.visit('http://localhost:5601/app/opensearch_dashboards_overview', { + failOnStatusCode: false, + timeout: 10000, + }); + kcLogin(); - cy.origin('http://localhost:5601', () => { - cy.wait(5000); - cy.get('button[data-test-subj="confirm"]').click(); - - cy.wait(5000) - cy.get('button[aria-label="Closes this modal window"]').click(); + cy.origin('http://localhost:5601', { + args: [tenantLocalStorageKey, globalTenantLocalStorageValue, newThemeModalLocalStorageKey, 'false'] + }, (tenantKey, tenantValue, themeModalKey, themeModalValue) => { + localStorage.setItem(tenantKey, tenantValue); + localStorage.setItem(themeModalKey, themeModalValue); cy.get('#osdOverviewPageHeader__title', { timeout: 10000 }).should('be.visible'); @@ -49,7 +58,7 @@ describe('Log in via OIDC', () => { }); }); - it('Login to app/dev_tools#/console when OIDC is enabled', () => { + it.skip('Login to app/dev_tools#/console when OIDC is enabled', () => { cy.visit('http://localhost:5601/app/dev_tools#/console', { failOnStatusCode: false, timeout: 10000 }); cy.wait(15000); @@ -72,7 +81,7 @@ describe('Log in via OIDC', () => { }); }); - it('Login to Dashboard with Hash', () => { + it.skip('Login to Dashboard with Hash', () => { cy.visit( `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)` ); @@ -88,7 +97,7 @@ describe('Log in via OIDC', () => { }); }); - it('Tenancy persisted after logout in OIDC', () => { + it.skip('Tenancy persisted after logout in OIDC', () => { cy.visit('http://localhost:5601/app/opensearch_dashboards_overview#/', { failOnStatusCode: false, timeout: 10000 }); cy.wait(15000); diff --git a/.eslintignore b/.eslintignore index 17ca04c94..5ee33b072 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ node_modules /build /target /.eslintrc.js +cypress.config.js diff --git a/package.json b/package.json index d2a83a841..eea00c4c7 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "@elastic/eslint-import-resolver-kibana": "link:../../packages/osd-eslint-import-resolver-opensearch-dashboards", "@testing-library/react-hooks": "^7.0.2", "@types/hapi__wreck": "^15.0.1", - "cypress": "^13.2.0", + "cypress": "^13.5.1", "cypress-mochawesome-reporter": "^3.3.0", "gulp-rename": "2.0.0", "jose": "^4.11.2",