-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
policy_details.ts
225 lines (207 loc) · 7.94 KB
/
policy_details.ts
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* 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 { FtrProviderContext } from '../../ftr_provider_context';
import { PolicyTestResourceInfo } from '../../services/endpoint_policy';
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['common', 'endpoint', 'policy', 'endpointPageUtils']);
const testSubjects = getService('testSubjects');
const policyTestResources = getService('policyTestResources');
describe('When on the Endpoint Policy Details Page', function () {
this.tags(['ciGroup7']);
describe('with an invalid policy id', () => {
it('should display an error', async () => {
await pageObjects.policy.navigateToPolicyDetails('invalid-id');
await testSubjects.existOrFail('policyDetailsIdNotFoundMessage');
expect(await testSubjects.getVisibleText('policyDetailsIdNotFoundMessage')).to.equal(
'Saved object [ingest-datasources/invalid-id] not found'
);
});
});
describe('with a valid policy id', () => {
let policyInfo: PolicyTestResourceInfo;
before(async () => {
policyInfo = await policyTestResources.createPolicy();
await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id);
});
after(async () => {
if (policyInfo) {
await policyInfo.cleanup();
}
});
it('should display policy view', async () => {
expect(await testSubjects.getVisibleText('pageViewHeaderLeftTitle')).to.equal(
policyInfo.datasource.name
);
});
});
describe('and the save button is clicked', () => {
let policyInfo: PolicyTestResourceInfo;
beforeEach(async () => {
policyInfo = await policyTestResources.createPolicy();
await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id);
});
afterEach(async () => {
if (policyInfo) {
await policyInfo.cleanup();
}
});
it('should display success toast on successful save', async () => {
await pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyWindowsEvent_dns');
await pageObjects.policy.confirmAndSave();
await testSubjects.existOrFail('policyDetailsSuccessMessage');
expect(await testSubjects.getVisibleText('policyDetailsSuccessMessage')).to.equal(
`Policy ${policyInfo.datasource.name} has been updated.`
);
});
it('should persist update on the screen', async () => {
await pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyWindowsEvent_process');
await pageObjects.policy.confirmAndSave();
await testSubjects.existOrFail('policyDetailsSuccessMessage');
await pageObjects.policy.navigateToPolicyList();
await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id);
expect(await (await testSubjects.find('policyWindowsEvent_process')).isSelected()).to.equal(
false
);
});
it('should have updated policy data in overall agent configuration', async () => {
// This test ensures that updates made to the Endpoint Policy are carried all the way through
// to the generated Agent Configuration that is dispatch down to the Elastic Agent.
await Promise.all([
pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyWindowsEvent_file'),
pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyLinuxEvent_file'),
pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyMacEvent_file'),
]);
await pageObjects.policy.confirmAndSave();
await testSubjects.existOrFail('policyDetailsSuccessMessage');
const agentFullConfig = await policyTestResources.getFullAgentConfig(
policyInfo.agentConfig.id
);
expect(agentFullConfig).to.eql({
datasources: [
{
enabled: true,
id: policyInfo.datasource.id,
inputs: [
{
enabled: true,
policy: {
linux: {
advanced: {
elasticsearch: {
indices: {
control: 'control-index',
event: 'event-index',
logging: 'logging-index',
},
kernel: {
connect: true,
process: true,
},
},
},
events: {
file: false,
network: true,
process: true,
},
logging: {
file: 'info',
stdout: 'debug',
},
},
mac: {
advanced: {
elasticsearch: {
indices: {
control: 'control-index',
event: 'event-index',
logging: 'logging-index',
},
kernel: {
connect: true,
process: true,
},
},
},
events: {
file: false,
network: true,
process: true,
},
logging: {
file: 'info',
stdout: 'debug',
},
malware: {
mode: 'detect',
},
},
windows: {
advanced: {
elasticsearch: {
indices: {
control: 'control-index',
event: 'event-index',
logging: 'logging-index',
},
kernel: {
connect: true,
process: true,
},
},
},
events: {
dll_and_driver_load: true,
dns: true,
file: false,
network: true,
process: true,
registry: true,
security: true,
},
logging: {
file: 'info',
stdout: 'debug',
},
malware: {
mode: 'prevent',
},
},
},
streams: [],
type: 'endpoint',
},
],
name: 'Protect East Coast',
namespace: 'default',
package: {
name: 'endpoint',
version: policyInfo.packageInfo.version,
},
use_output: 'default',
},
],
id: policyInfo.agentConfig.id,
outputs: {
default: {
hosts: ['http://localhost:9200'],
type: 'elasticsearch',
},
},
revision: 3,
settings: {
monitoring: {
enabled: false,
logs: false,
metrics: false,
},
},
});
});
});
});
}