@centreon/js-config 24.4.26 → 24.4.28

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.
@@ -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(500),
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(500),
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;
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": "24.4.26",
4
+ "version": "24.4.28",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -63,7 +63,7 @@ const getBaseConfiguration = ({
63
63
  },
64
64
  {
65
65
  'react-i18next': {
66
- requiredVersion: '11.x',
66
+ requiredVersion: '14.x',
67
67
  singleton: true
68
68
  }
69
69
  },