@centreon/js-config 24.4.25 → 24.4.27

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.
@@ -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;
@@ -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "24.4.25",
4
+ "version": "24.4.27",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"