@centreon/js-config 24.4.31 → 24.5.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.
- package/cypress/component/commands.tsx +5 -3
- package/cypress/e2e/commands/configuration.ts +165 -0
- package/cypress/e2e/configuration.ts +1 -1
- package/cypress/e2e/tasks.ts +1 -1
- package/package.json +1 -1
- package/webpack/base/index.js +1 -1
- package/webpack/patch/module.js +8 -34
- package/webpack/plugins/TransformPreloadScript.js +37 -0
- package/webpack/plugins/WriteRemoteEntryNameToModuleFederation.js +30 -0
|
@@ -62,6 +62,7 @@ interface Query {
|
|
|
62
62
|
|
|
63
63
|
export interface InterceptAPIRequestProps<T> {
|
|
64
64
|
alias: string;
|
|
65
|
+
delay?: number;
|
|
65
66
|
method: Method;
|
|
66
67
|
path: string;
|
|
67
68
|
query?: Query;
|
|
@@ -77,7 +78,8 @@ Cypress.Commands.add(
|
|
|
77
78
|
response,
|
|
78
79
|
alias,
|
|
79
80
|
query,
|
|
80
|
-
statusCode = 200
|
|
81
|
+
statusCode = 200,
|
|
82
|
+
delay = 500
|
|
81
83
|
}: InterceptAPIRequestProps<T>): void => {
|
|
82
84
|
cy.interceptRequest(
|
|
83
85
|
method,
|
|
@@ -86,14 +88,14 @@ Cypress.Commands.add(
|
|
|
86
88
|
const getQuery = req?.url?.searchParams?.get(query?.name);
|
|
87
89
|
if (query && equals(query.value, getQuery)) {
|
|
88
90
|
return res(
|
|
89
|
-
ctx.delay(
|
|
91
|
+
ctx.delay(delay),
|
|
90
92
|
ctx.json(response),
|
|
91
93
|
ctx.status(statusCode)
|
|
92
94
|
);
|
|
93
95
|
}
|
|
94
96
|
if (!getQuery && isNil(query)) {
|
|
95
97
|
return res(
|
|
96
|
-
ctx.delay(
|
|
98
|
+
ctx.delay(delay),
|
|
97
99
|
ctx.json(response),
|
|
98
100
|
ctx.status(statusCode)
|
|
99
101
|
);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
|
+
import { Action } from 'e2e/features/ACLs/commands';
|
|
4
|
+
|
|
3
5
|
const apiBase = '/centreon/api';
|
|
4
6
|
const apiActionV1 = `${apiBase}/index.php`;
|
|
5
7
|
|
|
@@ -496,9 +498,172 @@ Cypress.Commands.add(
|
|
|
496
498
|
}
|
|
497
499
|
);
|
|
498
500
|
|
|
501
|
+
interface ACLGroup {
|
|
502
|
+
alias?: string | null;
|
|
503
|
+
contacts?: string[];
|
|
504
|
+
contactGroups?: string[];
|
|
505
|
+
name: string;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
Cypress.Commands.add(
|
|
509
|
+
'addACLGroup',
|
|
510
|
+
({
|
|
511
|
+
alias = null,
|
|
512
|
+
contacts = [],
|
|
513
|
+
contactGroups = [],
|
|
514
|
+
name
|
|
515
|
+
}: ACLGroup): Cypress.Chainable => {
|
|
516
|
+
const ACLGroupALias = alias === null ? name : alias;
|
|
517
|
+
|
|
518
|
+
return cy
|
|
519
|
+
.executeActionViaClapi({
|
|
520
|
+
bodyContent: {
|
|
521
|
+
action: 'ADD',
|
|
522
|
+
object: 'ACLGROUP',
|
|
523
|
+
values: `${name};${ACLGroupALias}`
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
.then(() => {
|
|
527
|
+
if (contacts) {
|
|
528
|
+
contacts.map((contact) => {
|
|
529
|
+
cy.executeActionViaClapi({
|
|
530
|
+
bodyContent: {
|
|
531
|
+
action: 'ADDCONTACT',
|
|
532
|
+
object: 'ACLGROUP',
|
|
533
|
+
values: `${name};${contact}`
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
if (contactGroups) {
|
|
539
|
+
contactGroups.map((contactGroup) => {
|
|
540
|
+
cy.executeActionViaClapi({
|
|
541
|
+
bodyContent: {
|
|
542
|
+
action: 'ADDCONTACTGROUP',
|
|
543
|
+
object: 'ACLGROUP',
|
|
544
|
+
values: `${name};${contactGroup}`
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
interface ACLMenu {
|
|
554
|
+
name: string;
|
|
555
|
+
rule?: string[];
|
|
556
|
+
alias?: string | null;
|
|
557
|
+
includeChildren?: boolean;
|
|
558
|
+
readOnly?: boolean;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
Cypress.Commands.add(
|
|
562
|
+
'addACLMenu',
|
|
563
|
+
({
|
|
564
|
+
name,
|
|
565
|
+
rule = [],
|
|
566
|
+
alias = null,
|
|
567
|
+
includeChildren = true,
|
|
568
|
+
readOnly = false
|
|
569
|
+
}: ACLMenu): Cypress.Chainable => {
|
|
570
|
+
const ACLMenuAlias = alias === null ? name : alias;
|
|
571
|
+
const action = readOnly ? 'GRANTRO' : 'GRANTRW';
|
|
572
|
+
const children = includeChildren ? '1' : '0';
|
|
573
|
+
|
|
574
|
+
return cy
|
|
575
|
+
.executeActionViaClapi({
|
|
576
|
+
bodyContent: {
|
|
577
|
+
action: 'ADD',
|
|
578
|
+
object: 'ACLMENU',
|
|
579
|
+
values: `${name};${ACLMenuAlias}`
|
|
580
|
+
}
|
|
581
|
+
})
|
|
582
|
+
.then(() => {
|
|
583
|
+
if (rule.length == 0) {
|
|
584
|
+
return cy.wrap(null);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
let ruleCommand = '';
|
|
588
|
+
rule.map((rulePage, index) => {
|
|
589
|
+
ruleCommand += rulePage + (index == rule.length - 1 ? '' : ';');
|
|
590
|
+
});
|
|
591
|
+
cy.executeActionViaClapi({
|
|
592
|
+
bodyContent: {
|
|
593
|
+
action: action,
|
|
594
|
+
object: 'ACLMENU',
|
|
595
|
+
values: `${name};${children};${ruleCommand}`
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
return cy.wrap(null);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
|
|
603
|
+
interface ACLAction {
|
|
604
|
+
name: string;
|
|
605
|
+
description: string;
|
|
606
|
+
actions?: Action[];
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
Cypress.Commands.add(
|
|
610
|
+
'addACLAction',
|
|
611
|
+
({ name, description, actions = [] }: ACLAction): Cypress.Chainable => {
|
|
612
|
+
return cy
|
|
613
|
+
.executeActionViaClapi({
|
|
614
|
+
bodyContent: {
|
|
615
|
+
action: 'ADD',
|
|
616
|
+
object: 'ACLACTION',
|
|
617
|
+
values: `${name};${description}`
|
|
618
|
+
}
|
|
619
|
+
})
|
|
620
|
+
.then(() => {
|
|
621
|
+
if (actions.length == 0) {
|
|
622
|
+
return cy.wrap(null);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
let actionCommand = '';
|
|
626
|
+
actions.map((action, index) => {
|
|
627
|
+
actionCommand += action + (index == actions.length - 1 ? '' : '|');
|
|
628
|
+
});
|
|
629
|
+
cy.executeActionViaClapi({
|
|
630
|
+
bodyContent: {
|
|
631
|
+
action: 'GRANT',
|
|
632
|
+
object: 'ACLACTION',
|
|
633
|
+
values: `${name};${actionCommand}`
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
return cy.wrap(null);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
interface ACLResource {
|
|
642
|
+
name: string;
|
|
643
|
+
alias?: string | null;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
Cypress.Commands.add(
|
|
647
|
+
'addACLResource',
|
|
648
|
+
({ name, alias = null }: ACLResource): Cypress.Chainable => {
|
|
649
|
+
const ACLResourcesAlias = alias === null ? name : alias;
|
|
650
|
+
return cy.executeActionViaClapi({
|
|
651
|
+
bodyContent: {
|
|
652
|
+
action: 'ADD',
|
|
653
|
+
object: 'ACLRESOURCE',
|
|
654
|
+
values: `${name};${ACLResourcesAlias}`
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
);
|
|
659
|
+
|
|
499
660
|
declare global {
|
|
500
661
|
namespace Cypress {
|
|
501
662
|
interface Chainable {
|
|
663
|
+
addACLAction: (props: ACLAction) => Cypress.Chainable;
|
|
664
|
+
addACLGroup: (props: ACLGroup) => Cypress.Chainable;
|
|
665
|
+
addACLMenu: (props: ACLMenu) => Cypress.Chainable;
|
|
666
|
+
addACLResource: (props: ACLResource) => Cypress.Chainable;
|
|
502
667
|
addCheckCommand: (props: CheckCommand) => Cypress.Chainable;
|
|
503
668
|
addContact: (props: Contact) => Cypress.Chainable;
|
|
504
669
|
addContactGroup: (props: ContactGroup) => Cypress.Chainable;
|
|
@@ -59,7 +59,7 @@ export default ({
|
|
|
59
59
|
},
|
|
60
60
|
env: {
|
|
61
61
|
...env,
|
|
62
|
-
DATABASE_IMAGE: 'bitnami/mariadb:10.
|
|
62
|
+
DATABASE_IMAGE: 'bitnami/mariadb:10.11',
|
|
63
63
|
OPENID_IMAGE_VERSION: process.env.MAJOR || '24.04',
|
|
64
64
|
SAML_IMAGE_VERSION: process.env.MAJOR || '24.04',
|
|
65
65
|
WEB_IMAGE_OS: 'alma9',
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -106,7 +106,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
106
106
|
const { exitCode, output } = await getContainer(name).exec([
|
|
107
107
|
'bash',
|
|
108
108
|
'-c',
|
|
109
|
-
command
|
|
109
|
+
`${command}${command.match(/[\n\r]/) ? '' : ' 2>&1'}`
|
|
110
110
|
]);
|
|
111
111
|
|
|
112
112
|
return { exitCode, output };
|
package/package.json
CHANGED
package/webpack/base/index.js
CHANGED
package/webpack/patch/module.js
CHANGED
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
1
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
7
|
-
}
|
|
3
|
+
const WriteRemoteEntryNameToModuleFederation = require('../plugins/WriteRemoteEntryNameToModuleFederation');
|
|
4
|
+
const TransformPreloadScript = require('../plugins/TransformPreloadScript');
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
|
|
11
|
-
const newFederatedComponentConfiguration = {
|
|
12
|
-
...this.federatedComponentConfiguration,
|
|
13
|
-
remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
|
|
14
|
-
assetName.match(/(^remoteEntry)\S+.js$/),
|
|
15
|
-
),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
if (!fs.existsSync(compiler.options.output.path)) {
|
|
19
|
-
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(
|
|
23
|
-
`${compiler.options.output.path}/moduleFederation.json`,
|
|
24
|
-
JSON.stringify(newFederatedComponentConfiguration, null, 2),
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = ({
|
|
31
|
-
outputPath,
|
|
32
|
-
federatedComponentConfiguration,
|
|
33
|
-
}) => ({
|
|
6
|
+
module.exports = ({ outputPath, federatedComponentConfiguration }) => ({
|
|
34
7
|
output: {
|
|
35
8
|
library: '[chunkhash:8]',
|
|
36
|
-
path: outputPath
|
|
9
|
+
path: outputPath
|
|
37
10
|
},
|
|
38
11
|
plugins: [
|
|
39
12
|
new CleanWebpackPlugin({
|
|
40
13
|
cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
|
|
41
14
|
dangerouslyAllowCleanPatternsOutsideProject: true,
|
|
42
|
-
dry: false
|
|
15
|
+
dry: false
|
|
43
16
|
}),
|
|
44
|
-
new
|
|
45
|
-
|
|
17
|
+
new WriteRemoteEntryNameToModuleFederation(federatedComponentConfiguration),
|
|
18
|
+
new TransformPreloadScript(federatedComponentConfiguration)
|
|
19
|
+
]
|
|
46
20
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const swc = require('@swc/core');
|
|
4
|
+
|
|
5
|
+
module.exports = class TransformPreloadScript {
|
|
6
|
+
constructor(federatedComponentConfiguration) {
|
|
7
|
+
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
compiler.hooks.done.tap('CentreonModulePlugin', () => {
|
|
12
|
+
if (!fs.existsSync(compiler.options.output.path)) {
|
|
13
|
+
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (this.federatedComponentConfiguration.preloadScript) {
|
|
17
|
+
const { code } = swc.transformFileSync(
|
|
18
|
+
`./${this.federatedComponentConfiguration.preloadScript}.ts`,
|
|
19
|
+
{
|
|
20
|
+
filename: `${this.federatedComponentConfiguration.preloadScript}.ts`,
|
|
21
|
+
jsc: {
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: 'typescript'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
minify: true
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
`${compiler.options.output.path}/${this.federatedComponentConfiguration.preloadScript}.js`,
|
|
32
|
+
code
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
module.exports = class WriteRemoteEntryNameToModuleFederation {
|
|
4
|
+
constructor(federatedComponentConfiguration) {
|
|
5
|
+
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
compiler.hooks.done.tap(
|
|
10
|
+
'WriteRemoteEntryNameToModuleFederation',
|
|
11
|
+
(stats) => {
|
|
12
|
+
const newFederatedComponentConfiguration = {
|
|
13
|
+
...this.federatedComponentConfiguration,
|
|
14
|
+
remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
|
|
15
|
+
assetName.match(/(^remoteEntry)\S+.js$/)
|
|
16
|
+
)
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(compiler.options.output.path)) {
|
|
20
|
+
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(
|
|
24
|
+
`${compiler.options.output.path}/moduleFederation.json`,
|
|
25
|
+
JSON.stringify(newFederatedComponentConfiguration, null, 2)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
};
|