-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathaggregation_view.js
124 lines (102 loc) · 4.37 KB
/
aggregation_view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* 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 = 'testUserPassword123';
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 check the saved objects by applying filter', () => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(SAVED_OBJECTS_PATH);
cy.contains('a', 'Saved objects');
cy.get('span[title="Tenant"]').first().click({ force: true });
cy.get('span').contains('Private').click();
cy.contains('a', 's*');
cy.contains('a', 'se*').should('not.exist');
cy.wait(3000);
cy.get('span').contains('test').click();
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';
cy.deleteIndexPattern('index-pattern1', { failOnStatusCode: false });
cy.deleteIndexPattern('index-pattern2', { failOnStatusCode: false });
});
});
}