@centreon/js-config 23.10.11-MON-20047-cace.0 → 23.10.11-enhance-e2e-tests-update-develop.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
const apiBase = '/centreon/api';
|
|
4
|
+
const apiActionV1 = `${apiBase}/index.php`;
|
|
5
|
+
|
|
6
|
+
interface ActionClapi {
|
|
7
|
+
action: string;
|
|
8
|
+
object?: string;
|
|
9
|
+
values: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ExecuteActionViaClapiProps {
|
|
13
|
+
bodyContent: ActionClapi;
|
|
14
|
+
method?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Cypress.Commands.add(
|
|
18
|
+
'executeActionViaClapi',
|
|
19
|
+
({
|
|
20
|
+
bodyContent,
|
|
21
|
+
method = 'POST'
|
|
22
|
+
}: ExecuteActionViaClapiProps): Cypress.Chainable => {
|
|
23
|
+
return cy.request({
|
|
24
|
+
body: bodyContent,
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
28
|
+
},
|
|
29
|
+
method,
|
|
30
|
+
url: `${apiActionV1}?action=action&object=centreon_clapi`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
Cypress.Commands.add(
|
|
36
|
+
'executeCommandsViaClapi',
|
|
37
|
+
(fixtureFile: string): Cypress.Chainable => {
|
|
38
|
+
return cy.fixture(fixtureFile).then((listRequestConfig) => {
|
|
39
|
+
cy.wrap(
|
|
40
|
+
Promise.all(
|
|
41
|
+
listRequestConfig.map((request: ActionClapi) =>
|
|
42
|
+
cy.executeActionViaClapi({ bodyContent: request })
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
interface TimePeriod {
|
|
51
|
+
alias?: string | null;
|
|
52
|
+
friday?: string;
|
|
53
|
+
monday?: string;
|
|
54
|
+
name: string;
|
|
55
|
+
saturday?: string;
|
|
56
|
+
sunday?: string;
|
|
57
|
+
thursday?: string;
|
|
58
|
+
tuesday?: string;
|
|
59
|
+
wednesday?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const defaultDayPeriod = '00:00-24:00';
|
|
63
|
+
|
|
64
|
+
Cypress.Commands.add(
|
|
65
|
+
'addTimePeriod',
|
|
66
|
+
({
|
|
67
|
+
alias = null,
|
|
68
|
+
friday = defaultDayPeriod,
|
|
69
|
+
monday = defaultDayPeriod,
|
|
70
|
+
name,
|
|
71
|
+
saturday = defaultDayPeriod,
|
|
72
|
+
sunday = defaultDayPeriod,
|
|
73
|
+
thursday = defaultDayPeriod,
|
|
74
|
+
tuesday = defaultDayPeriod,
|
|
75
|
+
wednesday = defaultDayPeriod
|
|
76
|
+
}: TimePeriod): Cypress.Chainable => {
|
|
77
|
+
const timePeriodAlias = alias === null ? name : alias;
|
|
78
|
+
|
|
79
|
+
return cy
|
|
80
|
+
.executeActionViaClapi({
|
|
81
|
+
bodyContent: {
|
|
82
|
+
action: 'ADD',
|
|
83
|
+
object: 'TP',
|
|
84
|
+
values: `${name};${timePeriodAlias}`
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.then(() => {
|
|
88
|
+
const weekDays = {
|
|
89
|
+
friday,
|
|
90
|
+
monday,
|
|
91
|
+
saturday,
|
|
92
|
+
sunday,
|
|
93
|
+
thursday,
|
|
94
|
+
tuesday,
|
|
95
|
+
wednesday
|
|
96
|
+
};
|
|
97
|
+
Object.entries(weekDays).map(([dayName, dayValue]) => {
|
|
98
|
+
return cy.executeActionViaClapi({
|
|
99
|
+
bodyContent: {
|
|
100
|
+
action: 'SETPARAM',
|
|
101
|
+
object: 'TP',
|
|
102
|
+
values: `${name};${dayName};${dayValue}`
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return cy.wrap(null);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
interface CheckCommand {
|
|
113
|
+
command: string;
|
|
114
|
+
enableShell?: boolean;
|
|
115
|
+
name: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Cypress.Commands.add(
|
|
119
|
+
'addCheckCommand',
|
|
120
|
+
({ name, enableShell = true, command }: CheckCommand): Cypress.Chainable => {
|
|
121
|
+
const commandEnableShell = enableShell ? 1 : 0;
|
|
122
|
+
|
|
123
|
+
return cy
|
|
124
|
+
.executeActionViaClapi({
|
|
125
|
+
bodyContent: {
|
|
126
|
+
action: 'ADD',
|
|
127
|
+
object: 'CMD',
|
|
128
|
+
values: `${name};check;${command}`
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
.executeActionViaClapi({
|
|
132
|
+
bodyContent: {
|
|
133
|
+
action: 'SETPARAM',
|
|
134
|
+
object: 'CMD',
|
|
135
|
+
values: `${name};enable_shell;${commandEnableShell}`
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
interface Host {
|
|
142
|
+
activeCheckEnabled?: boolean;
|
|
143
|
+
address?: string;
|
|
144
|
+
alias?: string | null;
|
|
145
|
+
checkCommand?: string | null;
|
|
146
|
+
checkPeriod?: string | null;
|
|
147
|
+
maxCheckAttempts?: number | null;
|
|
148
|
+
name: string;
|
|
149
|
+
passiveCheckEnabled?: boolean;
|
|
150
|
+
poller?: string;
|
|
151
|
+
template?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Cypress.Commands.add(
|
|
155
|
+
'addHost',
|
|
156
|
+
({
|
|
157
|
+
activeCheckEnabled = true,
|
|
158
|
+
address = '127.0.0.1',
|
|
159
|
+
alias = null,
|
|
160
|
+
checkCommand = null,
|
|
161
|
+
checkPeriod = null,
|
|
162
|
+
maxCheckAttempts = 1,
|
|
163
|
+
name,
|
|
164
|
+
passiveCheckEnabled = true,
|
|
165
|
+
poller = 'Central',
|
|
166
|
+
template = ''
|
|
167
|
+
}: Host): Cypress.Chainable => {
|
|
168
|
+
const hostAlias = alias === null ? name : alias;
|
|
169
|
+
const hostMaxCheckAttempts =
|
|
170
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
171
|
+
const hostActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
172
|
+
const hostPassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
173
|
+
|
|
174
|
+
return cy
|
|
175
|
+
.executeActionViaClapi({
|
|
176
|
+
bodyContent: {
|
|
177
|
+
action: 'ADD',
|
|
178
|
+
object: 'HOST',
|
|
179
|
+
values: `${name};${hostAlias};${address};${template};${poller};`
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
.then(() => {
|
|
183
|
+
const hostParams = {
|
|
184
|
+
active_checks_enabled: hostActiveCheckEnabled,
|
|
185
|
+
check_command: checkCommand,
|
|
186
|
+
check_period: checkPeriod,
|
|
187
|
+
max_check_attempts: hostMaxCheckAttempts,
|
|
188
|
+
passive_checks_enabled: hostPassiveCheckEnabled
|
|
189
|
+
};
|
|
190
|
+
Object.entries(hostParams).map(([paramName, paramValue]) => {
|
|
191
|
+
if (paramValue === null) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return cy.executeActionViaClapi({
|
|
196
|
+
bodyContent: {
|
|
197
|
+
action: 'SETPARAM',
|
|
198
|
+
object: 'HOST',
|
|
199
|
+
values: `${name};${paramName};${paramValue}`
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return cy.wrap(null);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
interface ServiceTemplate {
|
|
210
|
+
activeCheckEnabled?: boolean;
|
|
211
|
+
checkCommand?: string | null;
|
|
212
|
+
checkPeriod?: string | null;
|
|
213
|
+
description?: string | null;
|
|
214
|
+
maxCheckAttempts?: number | null;
|
|
215
|
+
name: string;
|
|
216
|
+
passiveCheckEnabled?: boolean;
|
|
217
|
+
template?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
Cypress.Commands.add(
|
|
221
|
+
'addServiceTemplate',
|
|
222
|
+
({
|
|
223
|
+
activeCheckEnabled = true,
|
|
224
|
+
checkCommand = null,
|
|
225
|
+
checkPeriod = null,
|
|
226
|
+
description = null,
|
|
227
|
+
maxCheckAttempts = 1,
|
|
228
|
+
name,
|
|
229
|
+
passiveCheckEnabled = true,
|
|
230
|
+
template = ''
|
|
231
|
+
}: ServiceTemplate): Cypress.Chainable => {
|
|
232
|
+
const serviceDescription = description === null ? name : description;
|
|
233
|
+
const serviceMaxCheckAttempts =
|
|
234
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
235
|
+
const serviceActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
236
|
+
const servicePassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
237
|
+
|
|
238
|
+
return cy
|
|
239
|
+
.executeActionViaClapi({
|
|
240
|
+
bodyContent: {
|
|
241
|
+
action: 'ADD',
|
|
242
|
+
object: 'STPL',
|
|
243
|
+
values: `${name};${description};${template}`
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
.then(() => {
|
|
247
|
+
const serviceParams = {
|
|
248
|
+
active_checks_enabled: serviceActiveCheckEnabled,
|
|
249
|
+
check_command: checkCommand,
|
|
250
|
+
check_period: checkPeriod,
|
|
251
|
+
description: serviceDescription,
|
|
252
|
+
max_check_attempts: serviceMaxCheckAttempts,
|
|
253
|
+
passive_checks_enabled: servicePassiveCheckEnabled
|
|
254
|
+
};
|
|
255
|
+
Object.entries(serviceParams).map(([paramName, paramValue]) => {
|
|
256
|
+
if (paramValue === null) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return cy.executeActionViaClapi({
|
|
261
|
+
bodyContent: {
|
|
262
|
+
action: 'SETPARAM',
|
|
263
|
+
object: 'STPL',
|
|
264
|
+
values: `${name};${paramName};${paramValue}`
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
return cy.wrap(null);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
interface Service extends ServiceTemplate {
|
|
275
|
+
host: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
Cypress.Commands.add(
|
|
279
|
+
'addService',
|
|
280
|
+
({
|
|
281
|
+
activeCheckEnabled = true,
|
|
282
|
+
checkCommand = null,
|
|
283
|
+
checkPeriod = null,
|
|
284
|
+
host,
|
|
285
|
+
maxCheckAttempts = 1,
|
|
286
|
+
name,
|
|
287
|
+
passiveCheckEnabled = true,
|
|
288
|
+
template = ''
|
|
289
|
+
}: Service): Cypress.Chainable => {
|
|
290
|
+
const serviceMaxCheckAttempts =
|
|
291
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
292
|
+
const serviceActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
293
|
+
const servicePassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
294
|
+
|
|
295
|
+
return cy
|
|
296
|
+
.executeActionViaClapi({
|
|
297
|
+
bodyContent: {
|
|
298
|
+
action: 'ADD',
|
|
299
|
+
object: 'SERVICE',
|
|
300
|
+
values: `${host};${name};${template}`
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
.then(() => {
|
|
304
|
+
const serviceParams = {
|
|
305
|
+
active_checks_enabled: serviceActiveCheckEnabled,
|
|
306
|
+
check_command: checkCommand,
|
|
307
|
+
check_period: checkPeriod,
|
|
308
|
+
max_check_attempts: serviceMaxCheckAttempts,
|
|
309
|
+
passive_checks_enabled: servicePassiveCheckEnabled
|
|
310
|
+
};
|
|
311
|
+
Object.entries(serviceParams).map(([paramName, paramValue]) => {
|
|
312
|
+
if (paramValue === null) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return cy.executeActionViaClapi({
|
|
317
|
+
bodyContent: {
|
|
318
|
+
action: 'SETPARAM',
|
|
319
|
+
object: 'SERVICE',
|
|
320
|
+
values: `${host};${name};${paramName};${paramValue}`
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
return cy.wrap(null);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
Cypress.Commands.add(
|
|
331
|
+
'applyPollerConfiguration',
|
|
332
|
+
(pollerName = 'Central'): Cypress.Chainable => {
|
|
333
|
+
return cy.executeActionViaClapi({
|
|
334
|
+
bodyContent: {
|
|
335
|
+
action: 'APPLYCFG',
|
|
336
|
+
values: pollerName
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
declare global {
|
|
343
|
+
namespace Cypress {
|
|
344
|
+
interface Chainable {
|
|
345
|
+
addCheckCommand: (props: CheckCommand) => Cypress.Chainable;
|
|
346
|
+
addHost: (props: Host) => Cypress.Chainable;
|
|
347
|
+
addService: (props: Service) => Cypress.Chainable;
|
|
348
|
+
addServiceTemplate: (props: ServiceTemplate) => Cypress.Chainable;
|
|
349
|
+
addTimePeriod: (props: TimePeriod) => Cypress.Chainable;
|
|
350
|
+
applyPollerConfiguration: (props?: string) => Cypress.Chainable;
|
|
351
|
+
executeActionViaClapi: (
|
|
352
|
+
props: ExecuteActionViaClapiProps
|
|
353
|
+
) => Cypress.Chainable;
|
|
354
|
+
executeCommandsViaClapi: (fixtureFile: string) => Cypress.Chainable;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export {};
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import './commands/configuration';
|
|
4
|
+
|
|
5
5
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
6
6
|
|
|
7
7
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
@@ -172,50 +172,6 @@ Cypress.Commands.add(
|
|
|
172
172
|
.visit('/waiting-page')
|
|
173
173
|
);
|
|
174
174
|
|
|
175
|
-
interface ActionClapi {
|
|
176
|
-
action: string;
|
|
177
|
-
object?: string;
|
|
178
|
-
values: string;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
interface ExecuteActionViaClapiProps {
|
|
182
|
-
bodyContent: ActionClapi;
|
|
183
|
-
method?: string;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
Cypress.Commands.add(
|
|
187
|
-
'executeActionViaClapi',
|
|
188
|
-
({
|
|
189
|
-
bodyContent,
|
|
190
|
-
method = 'POST'
|
|
191
|
-
}: ExecuteActionViaClapiProps): Cypress.Chainable => {
|
|
192
|
-
return cy.request({
|
|
193
|
-
body: bodyContent,
|
|
194
|
-
headers: {
|
|
195
|
-
'Content-Type': 'application/json',
|
|
196
|
-
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
197
|
-
},
|
|
198
|
-
method,
|
|
199
|
-
url: `${apiActionV1}?action=action&object=centreon_clapi`
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
Cypress.Commands.add(
|
|
205
|
-
'executeCommandsViaClapi',
|
|
206
|
-
(fixtureFile: string): Cypress.Chainable => {
|
|
207
|
-
return cy.fixture(fixtureFile).then((listRequestConfig) => {
|
|
208
|
-
cy.wrap(
|
|
209
|
-
Promise.all(
|
|
210
|
-
listRequestConfig.map((request: ActionClapi) =>
|
|
211
|
-
cy.executeActionViaClapi({ bodyContent: request })
|
|
212
|
-
)
|
|
213
|
-
)
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
|
|
219
175
|
Cypress.Commands.add('waitForContainerAndSetToken', (): Cypress.Chainable => {
|
|
220
176
|
return cy.setUserTokenApiV1();
|
|
221
177
|
});
|
|
@@ -399,10 +355,6 @@ declare global {
|
|
|
399
355
|
command,
|
|
400
356
|
name
|
|
401
357
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
402
|
-
executeActionViaClapi: (
|
|
403
|
-
props: ExecuteActionViaClapiProps
|
|
404
|
-
) => Cypress.Chainable;
|
|
405
|
-
executeCommandsViaClapi: (fixtureFile: string) => Cypress.Chainable;
|
|
406
358
|
getIframeBody: () => Cypress.Chainable;
|
|
407
359
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
408
360
|
getWebVersion: () => Cypress.Chainable;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/js-config",
|
|
3
3
|
"description": "Centreon Frontend shared build configuration",
|
|
4
|
-
"version": "23.10.11-
|
|
4
|
+
"version": "23.10.11-enhance-e2e-tests-update-develop.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|