7
7
editorQuery ,
8
8
getOrganizationIdByName ,
9
9
getUserIdByEmail ,
10
- participantQuery ,
11
10
PLATFORM_ORGANIZATION ,
12
11
queryAsAdmin ,
13
12
securityQuery ,
@@ -73,7 +72,22 @@ const EDIT_AUTHORIZED_MEMBERS_QUERY = gql`
73
72
}
74
73
` ;
75
74
76
- /* describe('Case Incident Response standard behavior with authorized_members activation from entity', () => {
75
+ const PLATFORM_ORGANIZATION_QUERY = gql `
76
+ mutation PoliciesFieldPatchMutation($id: ID!, $input: [EditInput]!) {
77
+ settingsEdit(id: $id) {
78
+ fieldPatch(input: $input) {
79
+ platform_organization {
80
+ id
81
+ name
82
+ }
83
+ enterprise_edition
84
+ id
85
+ }
86
+ }
87
+ }
88
+ ` ;
89
+
90
+ describe ( 'Case Incident Response standard behavior with authorized_members activation from entity' , ( ) => {
77
91
let caseIncident : CaseIncident ;
78
92
let userEditorId : string ;
79
93
// 1. On créé un case incident => on vérifie que l'editor y a accès, que les authorized members sont vide, que le user access right est admin
@@ -420,6 +434,9 @@ describe('Case Incident Response standard behavior with authorized_members activ
420
434
421
435
describe ( 'Case Incident Response and organization sharing standard behavior without platform organization' , ( ) => {
422
436
let caseIrId : string ;
437
+ let organizationId : string ;
438
+ let settingsInternalId : string ;
439
+ // 1. On créé un case incident et on le partage à une orga différente de l'orga de editor
423
440
it ( 'should Case Incident Response created' , async ( ) => {
424
441
// Create Case Incident Response
425
442
const caseIRCreateQueryResult = await adminQuery ( {
@@ -436,45 +453,78 @@ describe('Case Incident Response and organization sharing standard behavior with
436
453
expect ( caseIRCreateQueryResult ?. data ?. caseIncidentAdd . authorized_members ) . toEqual ( [ ] ) ; // authorized members not activated
437
454
caseIrId = caseIRCreateQueryResult ?. data ?. caseIncidentAdd . id ;
438
455
} ) ;
439
- it('should access Case Incident Response', async () => {
440
- const caseIRQueryResult = await securityQuery({ query: READ_QUERY, variables: { id: caseIrId } });
441
- expect(caseIRQueryResult).not.toBeNull();
442
- expect(caseIRQueryResult?.data?.caseIncident).not.toBeUndefined();
443
- expect(caseIRQueryResult?.data?.caseIncident.id).toEqual(caseIrId);
444
- });
445
- it('should Authorized Members activated', async () => {
446
- await queryAsAdmin({
447
- query: EDIT_AUTHORIZED_MEMBERS_QUERY,
456
+ it ( 'should EE activated' , async ( ) => {
457
+ // Get settings ID
458
+ const SETTINGS_READ_QUERY = gql `
459
+ query settings {
460
+ settings {
461
+ id
462
+ platform_organization {
463
+ id
464
+ name
465
+ }
466
+ }
467
+ }
468
+ ` ;
469
+ const queryResult = await adminQuery ( { query : SETTINGS_READ_QUERY , variables : { } } ) ;
470
+ settingsInternalId = queryResult . data ?. settings ?. id ;
471
+
472
+ // Set plateform organization
473
+ const EEqueryResult = await adminQuery ( {
474
+ query : PLATFORM_ORGANIZATION_QUERY ,
448
475
variables : {
449
- id: caseIrId ,
476
+ id : settingsInternalId ,
450
477
input : [
451
- {
452
- id: ADMIN_USER.id,
453
- access_right: 'admin'
454
- }
478
+ { key : 'enterprise_edition' , value : new Date ( ) . getTime ( ) } ,
455
479
]
456
480
}
457
481
} ) ;
458
- // Verify if authorized members have been edited
459
- const caseIRUpdatedQueryResult = await adminQuery({
460
- query: READ_QUERY,
461
- variables: { id: caseIrId }
462
- });
463
- expect(caseIRUpdatedQueryResult).not.toBeNull();
464
- expect(caseIRUpdatedQueryResult?.data?.caseIncident.authorized_members).not.toBeUndefined();
465
- expect(caseIRUpdatedQueryResult?.data?.caseIncident.authorized_members).toEqual([
466
- {
467
- id: ADMIN_USER.id,
468
- access_right: 'admin'
482
+ expect ( EEqueryResult ) . not . toBeNull ( ) ;
483
+ expect ( EEqueryResult ?. data ?. settingsEdit . fieldPatch . enterprise_edition ) . not . toBeUndefined ( ) ;
484
+ } ) ;
485
+ it ( 'should share Case Incident Response with Organization' , async ( ) => {
486
+ // Get organization id
487
+ organizationId = await getOrganizationIdByName ( PLATFORM_ORGANIZATION . name ) ;
488
+ const ORGANIZATION_SHARING_QUERY = gql `
489
+ mutation StixCoreObjectSharingGroupAddMutation(
490
+ $id: ID!
491
+ $organizationId: ID!
492
+ ) {
493
+ stixCoreObjectEdit(id: $id) {
494
+ restrictionOrganizationAdd(organizationId: $organizationId) {
495
+ id
496
+ objectOrganization {
497
+ id
498
+ name
499
+ }
500
+ }
501
+ }
469
502
}
470
- ]);
503
+ ` ;
504
+
505
+ const organizationSharingQueryResult = await adminQuery ( {
506
+ query : ORGANIZATION_SHARING_QUERY ,
507
+ variables : { id : caseIrId , organizationId : PLATFORM_ORGANIZATION . id }
508
+ } ) ;
509
+ expect ( organizationSharingQueryResult ) . not . toBeNull ( ) ;
510
+ expect ( organizationSharingQueryResult ?. data ?. stixCoreObjectEdit . restrictionOrganizationAdd ) . not . toBeNull ( ) ;
511
+ expect ( organizationSharingQueryResult ?. data ?. stixCoreObjectEdit . restrictionOrganizationAdd . objectOrganization [ 0 ] . name ) . toEqual ( PLATFORM_ORGANIZATION . name ) ;
471
512
} ) ;
472
- it('should not access Case Incident Response if not in authorized members', async () => {
513
+ // 2. On vérifie qu'editor a bien accès au case incident
514
+ it ( 'should Editor user from different organization access Case Incident Response' , async ( ) => {
515
+ const caseIRQueryResult = await editorQuery ( { query : READ_QUERY , variables : { id : caseIrId } } ) ;
516
+ expect ( caseIRQueryResult ) . not . toBeNull ( ) ;
517
+ expect ( caseIRQueryResult ?. data ?. caseIncident ) . not . toBeUndefined ( ) ;
518
+ expect ( caseIRQueryResult ?. data ?. caseIncident . id ) . toEqual ( caseIrId ) ;
519
+ } ) ;
520
+ // 3. On vérifie qu'un user faisant partie de l'orga a bien accès au case aussi
521
+ it ( 'should Security user from shared organization access Case Incident Response' , async ( ) => {
473
522
const caseIRQueryResult = await securityQuery ( { query : READ_QUERY , variables : { id : caseIrId } } ) ;
474
523
expect ( caseIRQueryResult ) . not . toBeNull ( ) ;
475
524
expect ( caseIRQueryResult ?. data ?. caseIncident ) . not . toBeUndefined ( ) ;
476
- expect(caseIRQueryResult?.data?.caseIncident).toBeNull( );
525
+ expect ( caseIRQueryResult ?. data ?. caseIncident . id ) . toEqual ( caseIrId ) ;
477
526
} ) ;
527
+ // 4. On delete le case avec l'admin
478
528
it ( 'should Case Incident Response deleted' , async ( ) => {
479
529
// Delete the case
480
530
await adminQuery ( {
@@ -486,28 +536,25 @@ describe('Case Incident Response and organization sharing standard behavior with
486
536
expect ( queryResult ) . not . toBeNull ( ) ;
487
537
expect ( queryResult ?. data ?. caseIncident ) . toBeNull ( ) ;
488
538
} ) ;
489
- }); */
539
+ it ( 'should EE deactivated' , async ( ) => {
540
+ const platformOrganization = await adminQuery ( {
541
+ query : PLATFORM_ORGANIZATION_QUERY ,
542
+ variables : { id : settingsInternalId ,
543
+ input : [
544
+ { key : 'enterprise_edition' , value : [ ] } ,
545
+ ] }
546
+ } ) ;
547
+ expect ( platformOrganization ) . not . toBeNull ( ) ;
548
+ expect ( platformOrganization ?. data ?. settingsEdit . fieldPatch . enterprise_edition ) . toBeNull ( ) ;
549
+ } ) ;
550
+ } ) ;
490
551
491
552
describe ( 'Case Incident Response and organization sharing standard behavior with platform organization' , ( ) => {
492
553
let platformOrganizationId : string ;
493
554
let testOrganizationId : string ;
494
555
let caseIrId : string ;
495
556
let userEditorId : string ;
496
557
let settingsInternalId : string ;
497
- const PLATFORM_ORGANIZATION_QUERY = gql `
498
- mutation PoliciesFieldPatchMutation($id: ID!, $input: [EditInput]!) {
499
- settingsEdit(id: $id) {
500
- fieldPatch(input: $input) {
501
- platform_organization {
502
- id
503
- name
504
- }
505
- enterprise_edition
506
- id
507
- }
508
- }
509
- }
510
- ` ;
511
558
// 1. 'should plateform organization sharing and EE activated' => OK avec PlaformOrganization
512
559
it ( 'should plateform organization sharing and EE activated' , async ( ) => {
513
560
// Get organization id
0 commit comments