-
Notifications
You must be signed in to change notification settings - Fork 118
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
Cypress Integ test for dynamic multi-tenancy features #609
Merged
ashwin-pc
merged 1 commit into
opensearch-project:main
from
abhivka7:Dynamic_MultiTenancy
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...ures/plugins/security-dashboards-plugin/indexpatterns/indexPatternGlobalTenantHeader.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"securitytenant": ["global"] | ||
} |
3 changes: 3 additions & 0 deletions
3
...res/plugins/security-dashboards-plugin/indexpatterns/indexPatternPrivateTenantHeader.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"securitytenant": ["private"] | ||
} |
33 changes: 33 additions & 0 deletions
33
cypress/integration/plugins/security-dashboards-plugin/default_tenant.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SAVED_OBJECTS_PATH } from '../../../utils/dashboards/constants'; | ||
|
||
import { CURRENT_TENANT } from '../../../utils/commands'; | ||
import tenantDescription from '../../../fixtures/plugins/security-dashboards-plugin/tenants/testTenant'; | ||
|
||
const tenantName = 'test'; | ||
|
||
if (Cypress.env('SECURITY_ENABLED')) { | ||
describe('Multi Tenancy Default Tenant Tests: ', () => { | ||
before(() => { | ||
cy.server(); | ||
cy.createTenant(tenantName, tenantDescription); | ||
cy.changeDefaultTenant({ | ||
multitenancy_enabled: true, | ||
private_tenant_enabled: true, | ||
default_tenant: tenantName, | ||
}); | ||
}); | ||
it('Test Changed Default Tenant ', () => { | ||
CURRENT_TENANT.newTenant = null; | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.waitForLoader(); | ||
cy.get('#user-icon-btn').click(); | ||
cy.wait(1000); | ||
cy.get('#tenantName').contains(tenantName); | ||
}); | ||
}); | ||
} |
150 changes: 150 additions & 0 deletions
150
cypress/integration/plugins/security-dashboards-plugin/multi_tenancy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
SAVED_OBJECTS_PATH, | ||
TENANTS_MANAGE_PATH, | ||
} from '../../../utils/dashboards/constants'; | ||
|
||
import { CURRENT_TENANT } from '../../../utils/commands'; | ||
|
||
import indexPatternPrivateTenantHeaderSetUp from '../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternPrivateTenantHeader'; | ||
import indexPatternGlobalTenantHeaderSetUp from '../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternGlobalTenantHeader'; | ||
import tenantDescription from '../../../fixtures/plugins/security-dashboards-plugin/tenants/testTenant.json'; | ||
|
||
const tenantName = 'test'; | ||
|
||
if (Cypress.env('SECURITY_ENABLED')) { | ||
describe('Multi Tenancy Tests: ', () => { | ||
before(() => { | ||
cy.server(); | ||
cy.createTenant(tenantName, tenantDescription); | ||
cy.createIndexPattern( | ||
'index-pattern1', | ||
{ | ||
title: 's*', | ||
timeFieldName: 'timestamp', | ||
}, | ||
indexPatternGlobalTenantHeaderSetUp | ||
); | ||
|
||
cy.createIndexPattern( | ||
'index-pattern2', | ||
{ | ||
title: 'se*', | ||
timeFieldName: 'timestamp', | ||
}, | ||
indexPatternPrivateTenantHeaderSetUp | ||
); | ||
}); | ||
it('Test 1 Disable Multi Tenancy ', () => { | ||
CURRENT_TENANT.newTenant = 'private'; | ||
|
||
// Load into Private Tenant initially and check if index Pattern matches to the one saved in Private tenant. | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('a', 'Saved objects'); | ||
cy.contains('a', 'se*'); | ||
|
||
// Switch tenants button should exist when multi-tenancy is enabled. | ||
cy.get('#user-icon-btn').click(); | ||
cy.contains('button', 'Switch tenants').should('exist'); | ||
|
||
// Disable multi-tenancy. | ||
cy.visit(TENANTS_MANAGE_PATH); | ||
cy.waitForLoader(); | ||
|
||
cy.contains('button', 'Configure').click(); | ||
cy.waitForLoader(); | ||
cy.get('#EnableMultitenancyCheckBox').uncheck({ force: true }); | ||
cy.contains('button', 'Save Changes').click(); | ||
|
||
cy.get('#tenancyChangeCheckbox').check({ force: true }); | ||
cy.contains('button', 'Apply changes').click(); | ||
|
||
cy.reload(); | ||
cy.waitForLoader(); | ||
|
||
// Switch tenants button should not exist when multi-tenancy is disabled. | ||
cy.get('#user-icon-btn').click(); | ||
cy.contains('button', 'Switch tenants').should('not.exist'); | ||
|
||
//Tenancy disbaled warning should show on manage page. | ||
cy.contains('Tenancy is disabled').should('exist'); | ||
|
||
// Saved index pattern should only have the ones saved in Global tenant. | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('a', 'Saved objects'); | ||
cy.contains('a', 's*'); | ||
|
||
// Enable Multi-tenancy before closing test. | ||
cy.visit(TENANTS_MANAGE_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('button', 'Configure').click(); | ||
cy.waitForLoader(); | ||
cy.get('#EnableMultitenancyCheckBox').check({ force: true }); | ||
cy.contains('button', 'Save Changes').click(); | ||
cy.get('#tenancyChangeCheckbox').check({ force: true }); | ||
cy.contains('button', 'Apply changes').click(); | ||
cy.reload(); | ||
cy.waitForLoader(); | ||
}); | ||
it('Test 2 Disable Private Tenancy ', () => { | ||
CURRENT_TENANT.newTenant = 'private'; | ||
|
||
// Load into Private Tenant initially and check if index Pattern matches to the one saved in Private tenant. | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('a', 'Saved objects'); | ||
cy.contains('a', 'se*'); | ||
|
||
// Check if switching to private tenant is enabled. | ||
cy.get('#user-icon-btn').click(); | ||
cy.contains('button', 'Switch tenants').click(); | ||
cy.get('#private').should('be.enabled'); | ||
cy.contains('button', 'Cancel').click(); | ||
|
||
// Disable private tenant. | ||
cy.visit(TENANTS_MANAGE_PATH); | ||
cy.waitForLoader(); | ||
|
||
cy.contains('button', 'Configure').click(); | ||
cy.waitForLoader(); | ||
cy.get('#EnablePrivateTenantCheckBox').uncheck({ force: true }); | ||
cy.contains('button', 'Save Changes').click(); | ||
|
||
cy.get('#privateTenancyChangeCheckbox').check({ force: true }); | ||
cy.contains('button', 'Apply changes').click(); | ||
|
||
cy.reload(); | ||
cy.waitForLoader(); | ||
|
||
// Check if switching to private tenant is enabled. | ||
cy.get('#user-icon-btn').click(); | ||
cy.contains('button', 'Switch tenants').click(); | ||
cy.get('#private').should('be.disabled'); | ||
cy.contains('button', 'Cancel').click(); | ||
|
||
// Saved index pattern should only have the ones saved in Global tenant. | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('a', 'Saved objects'); | ||
cy.contains('a', 's*'); | ||
|
||
// Enable private tenant before exiting test. | ||
cy.visit(TENANTS_MANAGE_PATH); | ||
cy.waitForLoader(); | ||
cy.contains('button', 'Configure').click(); | ||
cy.waitForLoader(); | ||
cy.get('#EnablePrivateTenantCheckBox').check({ force: true }); | ||
cy.contains('button', 'Save Changes').click(); | ||
cy.get('#privateTenancyChangeCheckbox').check({ force: true }); | ||
cy.contains('button', 'Apply changes').click(); | ||
cy.reload(); | ||
cy.waitForLoader(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment header here is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks @ashwin-pc for pointing this out.