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

[Backport 2.x] Allow URL params for Security plugin intercept calls (#1276) #1332

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"remoteDataSourceBasicAuthPassword": "admin",
"SECURITY_ENABLED": false,
"AGGREGATION_VIEW": false,
"MULTITENANCY_ENABLED": true,
"username": "admin",
"password": "myStrongPassword123!",
"ENDPOINT_WITH_PROXY": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {
ADMIN_AUTH.newUser = Cypress.env('username');
ADMIN_AUTH.newPassword = Cypress.env('password');
CURRENT_TENANT.newTenant = 'private';
cy.deleteIndexPattern('index-pattern1', { failOnStatusCode: false });
cy.deleteIndexPattern('index-pattern2', { failOnStatusCode: false });
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { TENANTS_MANAGE_PATH } from '../../../utils/dashboards/constants';
import { SECURITY_PLUGIN_PATH } from '../../../utils/dashboards/constants';

if (Cypress.env('SECURITY_ENABLED')) {
if (Cypress.env('SECURITY_ENABLED') && !Cypress.env('MULTITENANCY_ENABLED')) {
describe('Multi Tenancy Tests: ', () => {
before(() => {
cy.server();
});
it('Test Dashboards tenancy features should not be accessible ', () => {
// This test is to ensure tenancy related features are not accessible when opensearch_security.multitenancy.enabled is disabled in the opensearchdashboard.yaml
cy.visit(TENANTS_MANAGE_PATH);
cy.visit(SECURITY_PLUGIN_PATH);
cy.waitForLoader();

cy.contains('You have not enabled multi tenancy').should('exist');
cy.get('[title="Tenants"]').should('not.exist');

// Switch tenants button should not exist when multi-tenancy is disabled.
cy.get('#user-icon-btn').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ if (Cypress.env('SECURITY_ENABLED')) {
indexPatternPrivateTenantHeaderSetUp
);
});
after(() => {
cy.deleteIndexPattern('index-pattern1', { failOnStatusCode: false });
cy.deleteIndexPattern('index-pattern2', { failOnStatusCode: false });
});
it('Test 1 Disable Multi Tenancy ', () => {
CURRENT_TENANT.newTenant = 'private';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (Cypress.env('SECURITY_ENABLED')) {
`"${TEST_CONFIG.tenant.name}"`
);
window.localStorage.setItem('home:newThemeModal:show', false);
window.localStorage.setItem('home:welcome:show', false);
},
});
cy.waitForLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export function switchTenantTo(newTenant) {
cy.getElementByTestId('account-popover').click();
cy.intercept({
method: 'GET',
url: '/api/v1/auth/dashboardsinfo',
url: '/api/v1/auth/dashboardsinfo*',
}).as('waitForDashboardsInfo');

cy.intercept({
method: 'GET',
url: '/api/v1/configuration/account',
url: '/api/v1/configuration/account*',
}).as('waitForAccountInfo');

cy.getElementByTestId('switch-tenants').click();
Expand All @@ -37,7 +37,7 @@ export function switchTenantTo(newTenant) {

cy.intercept({
method: 'POST',
url: '/api/v1/multitenancy/tenant',
url: '/api/v1/multitenancy/tenant*',
}).as('waitForUpdatingTenants');
cy.getElementByTestId('tenant-switch-modal')
.find('[data-test-subj="confirm"]')
Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Cypress.Commands.overwrite('visit', (orig, url, options) => {
}
newOptions.qs = { security_tenant: CURRENT_TENANT.defaultTenant };
if (waitForGetTenant) {
cy.intercept('GET', '/api/v1/multitenancy/tenant').as('getTenant');
cy.intercept('GET', '/api/v1/multitenancy/tenant*').as('getTenant');
orig(url, newOptions);
supressNoRequestOccurred();
cy.wait('@getTenant');
Expand Down
3 changes: 3 additions & 0 deletions cypress/utils/dashboards/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { BASE_PATH } from '../base_constants';

// STACK MANAGEMENT PATH
export const STACK_MANAGEMENT_PATH = BASE_PATH + '/app/management';
export const SECURITY_PLUGIN_PATH =
BASE_PATH + '/app/security-dashboards-plugin#/';

export const TENANTS_MANAGE_PATH =
BASE_PATH + '/app/security-dashboards-plugin#/tenants';

Expand Down
Loading