-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for aggregation view feature (#334)
- Loading branch information
Showing
20 changed files
with
324 additions
and
6 deletions.
There are no files selected for viewing
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
3 changes: 3 additions & 0 deletions
3
...s/fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternTenantHeader.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": ["test"] | ||
} |
24 changes: 24 additions & 0 deletions
24
cypress/fixtures/plugins/security-dashboards-plugin/roles/roleWithTest.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,24 @@ | ||
{ | ||
"cluster_permissions": [ | ||
"cluster_all" | ||
], | ||
"index_permissions": [{ | ||
"index_patterns": [ | ||
"*" | ||
], | ||
"dls": "", | ||
"fls": [], | ||
"masked_fields": [], | ||
"allowed_actions": [ | ||
"indices_all" | ||
] | ||
}], | ||
"tenant_permissions": [{ | ||
"tenant_patterns": [ | ||
"test" | ||
], | ||
"allowed_actions": [ | ||
"kibana_all_write" | ||
] | ||
}] | ||
} |
20 changes: 20 additions & 0 deletions
20
cypress/fixtures/plugins/security-dashboards-plugin/roles/roleWithoutTest.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,20 @@ | ||
{ | ||
"cluster_permissions": [ | ||
"cluster_all" | ||
], | ||
"index_permissions": [{ | ||
"index_patterns": [ | ||
"*" | ||
], | ||
"dls": "", | ||
"fls": [], | ||
"masked_fields": [], | ||
"allowed_actions": [ | ||
"indices_all" | ||
] | ||
}], | ||
"tenant_permissions": [{ | ||
"tenant_patterns": [], | ||
"allowed_actions": [] | ||
}] | ||
} |
4 changes: 4 additions & 0 deletions
4
cypress/fixtures/plugins/security-dashboards-plugin/rolesmapping/kibanauserRoleMapping.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,4 @@ | ||
{ | ||
"backend_roles" : [ "kibanauser" ], | ||
"users" : [ "test1", "test2" ] | ||
} |
3 changes: 3 additions & 0 deletions
3
cypress/fixtures/plugins/security-dashboards-plugin/rolesmapping/roleWithTestMapping.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 @@ | ||
{ | ||
"users" : [ "test1" ] | ||
} |
3 changes: 3 additions & 0 deletions
3
cypress/fixtures/plugins/security-dashboards-plugin/rolesmapping/roleWithoutTestMapping.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 @@ | ||
{ | ||
"users" : [ "test2" ] | ||
} |
3 changes: 3 additions & 0 deletions
3
cypress/fixtures/plugins/security-dashboards-plugin/tenants/testTenant.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 @@ | ||
{ | ||
"description": "This test tenant for aggregation view feature testing." | ||
} |
3 changes: 3 additions & 0 deletions
3
cypress/fixtures/plugins/security-dashboards-plugin/users/testUser.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 @@ | ||
{ | ||
"password": "password" | ||
} |
108 changes: 108 additions & 0 deletions
108
cypress/integration/plugins/security-dashboards-plugin/aggregation_view.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,108 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
SAVED_OBJECTS_PATH, | ||
} from '../../../utils/dashboards/constants'; | ||
|
||
import { | ||
ADMIN_AUTH, | ||
CURRENT_TENANT, | ||
} from '../../../utils/commands'; | ||
|
||
import tenantDescription from '../../../fixtures/plugins/security-dashboards-plugin/tenants/testTenant'; | ||
import testUsersSetUp from '../../../fixtures/plugins/security-dashboards-plugin/users/testUser'; | ||
import roleWithTestSetUp from '../../../fixtures/plugins/security-dashboards-plugin/roles/roleWithTest'; | ||
import roleWithoutTestSetUp from '../../../fixtures/plugins/security-dashboards-plugin/roles/roleWithoutTest'; | ||
import kibanaRoleMappingSetUp from '../../../fixtures/plugins/security-dashboards-plugin/rolesmapping/kibanauserRoleMapping'; | ||
import roleWithTestMappingSetUp from '../../../fixtures/plugins/security-dashboards-plugin/rolesmapping/roleWithTestMapping'; | ||
import roleWithoutTestMappingSetUp from '../../../fixtures/plugins/security-dashboards-plugin/rolesmapping/roleWithoutTestMapping'; | ||
import indexPatternTenantHeaderSetUp from '../../../fixtures/plugins/security-dashboards-plugin/indexpatterns/indexPatternTenantHeader'; | ||
|
||
const tenantName = 'test'; | ||
const userName1 = 'test1'; | ||
const userName2 = 'test2'; | ||
const password = 'password'; | ||
const roleName1 = 'roleWithTest'; | ||
const roleName2 = 'roleWithoutTest'; | ||
const kibanaRoleName = 'kibana_user' | ||
|
||
if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) { | ||
describe('Saved objects table test', () => { | ||
// start a server so that server responses can be mocked via fixtures | ||
// in all of the below test cases | ||
before(() => { | ||
cy.server(); | ||
cy.createTenant(tenantName, tenantDescription); | ||
|
||
cy.createIndexPattern('index-pattern1', { | ||
title: 's*', | ||
timeFieldName: 'timestamp', | ||
}); | ||
cy.createIndexPattern('index-pattern2', { | ||
title: 'se*', | ||
timeFieldName: 'timestamp', | ||
}, | ||
indexPatternTenantHeaderSetUp | ||
); | ||
|
||
cy.createInternalUser(userName1, testUsersSetUp); | ||
cy.createInternalUser(userName2, testUsersSetUp); | ||
|
||
cy.createRole(roleName1, roleWithTestSetUp); | ||
cy.createRole(roleName2, roleWithoutTestSetUp); | ||
|
||
cy.createRoleMapping(kibanaRoleName, kibanaRoleMappingSetUp); | ||
cy.createRoleMapping(roleName1, roleWithTestMappingSetUp); | ||
cy.createRoleMapping(roleName2, roleWithoutTestMappingSetUp); | ||
|
||
cy.wait(300000); | ||
}); | ||
|
||
it('should check the saved objects as global tenant', () => { | ||
CURRENT_TENANT.newTenant = 'global'; | ||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.contains('a', 'Saved objects'); | ||
cy.contains('a', 's*'); | ||
cy.contains('a', 'se*'); | ||
}); | ||
|
||
it('should login as test1 and check saved object', () =>{ | ||
CURRENT_TENANT.newTenant = 'private'; | ||
ADMIN_AUTH.newUser = userName1; | ||
ADMIN_AUTH.newPassword = password; | ||
|
||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.url().should((url) => { | ||
expect(url).to.contain('/management'); | ||
}); | ||
|
||
cy.wait(5000); | ||
cy.contains('a', 'se*'); | ||
cy.contains('a', 's*').should('not.exist'); | ||
}); | ||
|
||
it('should login as test2 and check saved object', () =>{ | ||
CURRENT_TENANT.newTenant = 'private'; | ||
ADMIN_AUTH.newUser = userName2; | ||
ADMIN_AUTH.newPassword = password; | ||
|
||
cy.visit(SAVED_OBJECTS_PATH); | ||
cy.url().should((url) => { | ||
expect(url).to.contain('/management'); | ||
}); | ||
|
||
cy.wait(5000); | ||
cy.contains('a', 'se*').should('not.exist'); | ||
cy.contains('a', 's*').should('not.exist'); | ||
}); | ||
|
||
after(() => { | ||
ADMIN_AUTH.newUser = Cypress.env('username'); | ||
ADMIN_AUTH.newPassword = Cypress.env('password'); | ||
CURRENT_TENANT.newTenant = 'private'; | ||
}); | ||
}); | ||
} |
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
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
48 changes: 48 additions & 0 deletions
48
cypress/utils/plugins/security-dashboards-plugin/commands.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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SEC_API } from '../../constants'; | ||
|
||
/** | ||
***************************** | ||
SECURITY DASHBOARDS PLUGIN COMMANDS | ||
***************************** | ||
*/ | ||
|
||
Cypress.Commands.add('createTenant', (tenantID, tenantJson) => { | ||
cy.request( | ||
'PUT', | ||
`${Cypress.env('openSearchUrl')}${SEC_API.TENANTS_BASE}/${tenantID}`, | ||
tenantJson | ||
); | ||
cy.wait(10000); | ||
}); | ||
|
||
Cypress.Commands.add('createInternalUser', (userID, userJson) => { | ||
cy.request( | ||
'PUT', | ||
`${Cypress.env('openSearchUrl')}${SEC_API.INTERNALUSERS_BASE}/${userID}`, | ||
userJson | ||
); | ||
cy.wait(10000); | ||
}); | ||
|
||
Cypress.Commands.add('createRole', (roleID, roleJson) => { | ||
cy.request( | ||
'PUT', | ||
`${Cypress.env('openSearchUrl')}${SEC_API.ROLE_BASE}/${roleID}`, | ||
roleJson | ||
); | ||
cy.wait(10000); | ||
}); | ||
|
||
Cypress.Commands.add('createRoleMapping', (roleID, rolemappingJson) => { | ||
cy.request( | ||
'PUT', | ||
`${Cypress.env('openSearchUrl')}${SEC_API.ROLE_MAPPING_BASE}/${roleID}`, | ||
rolemappingJson | ||
); | ||
cy.wait(10000); | ||
}); |
19 changes: 19 additions & 0 deletions
19
cypress/utils/plugins/security-dashboards-plugin/constants.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,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
***************************** | ||
SECURITY DASHBOARDS PLUGIN CONSTANTS | ||
***************************** | ||
*/ | ||
|
||
//Security API Constants | ||
export const SEC_API_PREFIX = '/_plugins/_security/api'; | ||
export const SEC_API = { | ||
TENANTS_BASE: `${SEC_API_PREFIX}/tenants`, | ||
INTERNALUSERS_BASE: `${SEC_API_PREFIX}/internalusers`, | ||
ROLE_BASE: `${SEC_API_PREFIX}/roles`, | ||
ROLE_MAPPING_BASE: `${SEC_API_PREFIX}/rolesmapping`, | ||
} |
Oops, something went wrong.