-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
users.js
114 lines (98 loc) · 4.59 KB
/
users.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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { indexBy } from 'lodash';
export default function({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['security', 'settings']);
const config = getService('config');
const log = getService('log');
describe('users', function() {
before(async () => {
log.debug('users');
await PageObjects.settings.navigateTo();
await PageObjects.security.clickElasticsearchUsers();
});
it('should show the default elastic and kibana users', async function() {
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username');
log.info('actualUsers = %j', users);
log.info('config = %j', config.get('servers.elasticsearch.hostname'));
if (config.get('servers.elasticsearch.hostname') === 'localhost') {
expect(users.elastic.roles).to.eql(['superuser']);
expect(users.elastic.reserved).to.be(true);
expect(users.kibana.roles).to.eql(['kibana_system']);
expect(users.kibana.reserved).to.be(true);
} else {
expect(users.anonymous.roles).to.eql(['anonymous']);
expect(users.anonymous.reserved).to.be(true);
}
});
it('should add new user', async function() {
await PageObjects.security.addUser({
username: 'Lee',
password: 'LeePwd',
confirmPassword: 'LeePwd',
fullname: 'LeeFirst LeeLast',
email: 'lee@myEmail.com',
save: true,
roles: ['kibana_admin'],
});
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username');
log.debug('actualUsers = %j', users);
expect(users.Lee.roles).to.eql(['kibana_admin']);
expect(users.Lee.fullname).to.eql('LeeFirst LeeLast');
expect(users.Lee.email).to.eql('lee@myEmail.com');
expect(users.Lee.reserved).to.be(false);
});
it('should add new user with optional fields left empty', async function() {
await PageObjects.security.addUser({
username: 'OptionalUser',
password: 'OptionalUserPwd',
confirmPassword: 'OptionalUserPwd',
save: true,
roles: [],
});
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username');
log.debug('actualUsers = %j', users);
expect(users.OptionalUser.roles).to.eql(['']);
expect(users.OptionalUser.fullname).to.eql('');
expect(users.OptionalUser.email).to.eql('');
expect(users.OptionalUser.reserved).to.be(false);
});
it('should delete user', async function() {
const alertMsg = await PageObjects.security.deleteUser('Lee');
log.debug('alertMsg = %s', alertMsg);
const users = indexBy(await PageObjects.security.getElasticsearchUsers(), 'username');
log.debug('actualUsers = %j', users);
expect(users).to.not.have.key('Lee');
});
it('should show the default roles', async function() {
await PageObjects.security.clickElasticsearchRoles();
const roles = indexBy(await PageObjects.security.getElasticsearchRoles(), 'rolename');
log.debug('actualRoles = %j', roles);
// This only contains the first page of alphabetically sorted results, so the assertions are only for the first handful of expected roles.
expect(roles.apm_system.reserved).to.be(true);
expect(roles.apm_system.deprecated).to.be(false);
expect(roles.apm_user.reserved).to.be(true);
expect(roles.apm_user.deprecated).to.be(false);
expect(roles.beats_admin.reserved).to.be(true);
expect(roles.beats_admin.deprecated).to.be(false);
expect(roles.beats_system.reserved).to.be(true);
expect(roles.beats_system.deprecated).to.be(false);
expect(roles.kibana_admin.reserved).to.be(true);
expect(roles.kibana_admin.deprecated).to.be(false);
expect(roles.kibana_user.reserved).to.be(true);
expect(roles.kibana_user.deprecated).to.be(true);
expect(roles.kibana_dashboard_only_user.reserved).to.be(true);
expect(roles.kibana_dashboard_only_user.deprecated).to.be(true);
expect(roles.kibana_system.reserved).to.be(true);
expect(roles.kibana_system.deprecated).to.be(false);
expect(roles.logstash_system.reserved).to.be(true);
expect(roles.logstash_system.deprecated).to.be(false);
expect(roles.monitoring_user.reserved).to.be(true);
expect(roles.monitoring_user.deprecated).to.be(false);
});
});
}