Skip to content

Commit

Permalink
Handle undefined
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Apr 19, 2024
1 parent 8c912e1 commit 80d753c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/cypress/e2e/saml/saml_auth_test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { ALL_ACCESS_ROLE, SHORTEN_URL_DATA } from '../../support/constants';

import samlUserRoleMapping from '../../fixtures/saml/samlUserRoleMappiing.json';

const basePath = Cypress.env('basePath') || '';

before(() => {
cy.intercept('https://localhost:9200');

// Avoid Cypress lock onto the ipv4 range, so fake `visit()` before `request()`.
// See: https://github.com/cypress-io/cypress/issues/25397#issuecomment-1402556488
cy.visit(`http://localhost:5601${Cypress.env('basePath')}`);
cy.visit(`http://localhost:5601${basePath}`);

cy.createRoleMapping(ALL_ACCESS_ROLE, samlUserRoleMapping);
cy.clearCookies();
Expand All @@ -52,7 +54,7 @@ describe('Log in via SAML', () => {
localStorage.setItem('opendistro::security::tenant::saved', '"__user__"');
localStorage.setItem('home:newThemeModal:show', 'false');

cy.visit(`http://localhost:5601${Cypress.env('basePath')}/app/opensearch_dashboards_overview`, {
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
failOnStatusCode: false,
});

Expand All @@ -66,7 +68,7 @@ describe('Log in via SAML', () => {
localStorage.setItem('opendistro::security::tenant::saved', '"__user__"');
localStorage.setItem('home:newThemeModal:show', 'false');

cy.visit(`http://localhost:5601${Cypress.env('basePath')}/app/dev_tools#/console`, {
cy.visit(`http://localhost:5601${basePath}/app/dev_tools#/console`, {
failOnStatusCode: false,
});

Expand All @@ -80,9 +82,7 @@ describe('Log in via SAML', () => {
localStorage.setItem('opendistro::security::tenant::saved', '"__user__"');
localStorage.setItem('home:newThemeModal:show', 'false');

const urlWithHash = `http://localhost:5601${Cypress.env(
'basePath'
)}/app/security-dashboards-plugin#/getstarted`;
const urlWithHash = `http://localhost:5601${basePath}/app/security-dashboards-plugin#/getstarted`;

cy.visit(urlWithHash, {
failOnStatusCode: false,
Expand All @@ -97,7 +97,7 @@ describe('Log in via SAML', () => {
it('Tenancy persisted after logout in SAML', () => {
localStorage.setItem('home:newThemeModal:show', 'false');

cy.visit(`http://localhost:5601${Cypress.env('basePath')}/app/opensearch_dashboards_overview`, {
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
failOnStatusCode: false,
});

Expand Down Expand Up @@ -130,9 +130,7 @@ describe('Log in via SAML', () => {
// We need to explicitly clear cookies,
// since the Shorten URL api is return's set-cookie header for admin user.
cy.clearCookies().then(() => {
const gotoUrl = `http://localhost:5601${Cypress.env('basePath')}/goto/${
response.urlId
}?security_tenant=global`;
const gotoUrl = `http://localhost:5601${basePath}/goto/${response.urlId}?security_tenant=global`;
cy.visit(gotoUrl);
samlLogin();
cy.getCookie('security_authentication').should('exist');
Expand Down

0 comments on commit 80d753c

Please sign in to comment.