Skip to content

Commit

Permalink
Add tests for shared links when multi-tenancy is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks authored and SuZhou-Joe committed Sep 3, 2024
1 parent 34ba5be commit 254cd39
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (Cypress.env('SECURITY_ENABLED')) {
'index-pattern1',
{
title: 's*',
timeFieldName: 'timestamp',
timeFieldName: '@timestamp',
},
indexPatternGlobalTenantHeaderSetUp
);
Expand All @@ -34,7 +34,7 @@ if (Cypress.env('SECURITY_ENABLED')) {
'index-pattern2',
{
title: 'se*',
timeFieldName: 'timestamp',
timeFieldName: '@timestamp',
},
indexPatternPrivateTenantHeaderSetUp
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { STACK_MANAGEMENT_PATH } from '../../../utils/dashboards/constants';

import { switchTenantTo } from './switch_tenant';
import 'cypress-real-events/support';

Cypress.automation('remote:debugger:protocol', {
command: 'Browser.grantPermissions',
params: {
permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'],
origin: window.location.origin,
},
});

if (Cypress.env('SECURITY_ENABLED')) {
describe('Multi Tenancy Tests for Shared Links: ', () => {
it('Tests to ensure that copy link includes security tenant as url param', () => {
cy.visit(STACK_MANAGEMENT_PATH);
cy.waitForLoader();
switchTenantTo('private');
cy.getElementByTestId('toggleNavButton').click();
cy.get('span[title="Discover"]').click();
cy.getElementByTestId('shareTopNavButton').click();
cy.getElementByTestId('copyShareUrlButton')
.realClick()
.then(() => {
cy.window()
.its('navigator.clipboard')
.then((clip) => clip.readText())
.should('contain', 'security_tenant=');
});
});
it('Tests to ensure that copy link includes security tenant as url param in short url', () => {
cy.visit(STACK_MANAGEMENT_PATH);
cy.waitForLoader();
switchTenantTo('private');
cy.getElementByTestId('toggleNavButton').click();
cy.get('span[title="Discover"]').click();
cy.getElementByTestId('shareTopNavButton').click();
cy.getElementByTestId('createShortUrl').click();
cy.getElementByTestId('copyShareUrlButton')
.realClick()
.then(() => {
cy.window()
.its('navigator.clipboard')
.then((clip) => clip.readText())
.should('contain', 'security_tenant=');
});
});
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"cypress": "9.5.4",
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.5.0",
"cypress-real-events": "1.7.6",
"cypress-real-events": "^1.12.0",
"eslint": "^7.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
Expand Down

0 comments on commit 254cd39

Please sign in to comment.