Skip to content

Commit

Permalink
Finish refactoring 1st test case of oidc
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Nov 16, 2023
1 parent 7f7c40d commit f794c39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
45 changes: 27 additions & 18 deletions .cypress/e2e/oidc/oidc_test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,47 @@
* 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');

cy.getCookie('security_authentication', { timeout: 10000 }).should('exist');
});
});

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);
Expand All @@ -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)`
);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
/build
/target
/.eslintrc.js
cypress.config.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f794c39

Please sign in to comment.