@@ -116,10 +116,12 @@ describe('Complex filters combinations for elastic queries', () => {
116116 let report2InternalId ;
117117 let report3InternalId ;
118118 let report4InternalId ;
119+ let report5InternalId ;
119120 const report1StixId = 'report--994491f0-f114-4e41-bcf0-3288c0324f01' ;
120121 const report2StixId = 'report--994491f0-f114-4e41-bcf0-3288c0324f02' ;
121122 const report3StixId = 'report--994491f0-f114-4e41-bcf0-3288c0324f03' ;
122123 const report4StixId = 'report--994491f0-f114-4e41-bcf0-3288c0324f04' ;
124+ const report5StixId = 'report--994491f0-f114-4e41-bcf0-3288c0324f05' ;
123125 let marking1StixId ;
124126 let marking1Id ;
125127 let marking2StixId ;
@@ -196,6 +198,17 @@ describe('Complex filters combinations for elastic queries', () => {
196198 confidence : 40 ,
197199 } ,
198200 } ;
201+ const REPORT5 = {
202+ input : {
203+ name : 'Report5' ,
204+ description : null ,
205+ stix_id : report5StixId ,
206+ published : '2025-09-15T00:51:35.000Z' ,
207+ report_types : [ 'threat-report' , 'internal-report' , 'global-report' ] ,
208+ objectMarking : [ ] ,
209+ confidence : 11 ,
210+ } ,
211+ } ;
199212 const report1 = await queryAsAdmin ( {
200213 query : CREATE_QUERY ,
201214 variables : REPORT1 ,
@@ -212,6 +225,10 @@ describe('Complex filters combinations for elastic queries', () => {
212225 query : CREATE_QUERY ,
213226 variables : REPORT4 ,
214227 } ) ;
228+ const report5 = await queryAsAdmin ( {
229+ query : CREATE_QUERY ,
230+ variables : REPORT5 ,
231+ } ) ;
215232 expect ( report1 ) . not . toBeNull ( ) ;
216233 expect ( report1 . data . reportAdd ) . not . toBeNull ( ) ;
217234 expect ( report1 . data . reportAdd . name ) . toEqual ( 'Report1' ) ;
@@ -224,10 +241,14 @@ describe('Complex filters combinations for elastic queries', () => {
224241 expect ( report4 ) . not . toBeNull ( ) ;
225242 expect ( report4 . data . reportAdd ) . not . toBeNull ( ) ;
226243 expect ( report4 . data . reportAdd . name ) . toEqual ( 'Report4' ) ;
244+ expect ( report5 ) . not . toBeNull ( ) ;
245+ expect ( report5 . data . reportAdd ) . not . toBeNull ( ) ;
246+ expect ( report5 . data . reportAdd . name ) . toEqual ( 'Report5' ) ;
227247 report1InternalId = report1 . data . reportAdd . id ;
228248 report2InternalId = report2 . data . reportAdd . id ;
229249 report3InternalId = report3 . data . reportAdd . id ;
230250 report4InternalId = report4 . data . reportAdd . id ;
251+ report5InternalId = report5 . data . reportAdd . id ;
231252 // Fetch a location and an intrusion set internal ids
232253 const location = await storeLoadById ( testContext , ADMIN_USER , 'location--c3794ffd-0e71-4670-aa4d-978b4cbdc72c' , ENTITY_TYPE_LOCATION ) ;
233254 locationInternalId = location . internal_id ;
@@ -265,9 +286,9 @@ describe('Complex filters combinations for elastic queries', () => {
265286 } ,
266287 } ,
267288 } ) ;
268- expect ( queryResult . data . reports . edges . length ) . toEqual ( 5 ) ; // the 4 reports created + the report in DATA-TEST-STIX2_v2.json
289+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 6 ) ; // the 5 reports created + the report in DATA-TEST-STIX2_v2.json
269290 queryResult = await queryAsAdmin ( { query : REPORT_LIST_QUERY } ) ;
270- expect ( queryResult . data . reports . edges . length ) . toEqual ( 5 ) ;
291+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 6 ) ;
271292 } ) ;
272293 it ( 'should list entities according to filters: one filter' , async ( ) => {
273294 // report_types = threat-report
@@ -289,7 +310,7 @@ describe('Complex filters combinations for elastic queries', () => {
289310 } ,
290311 } ,
291312 } ) ;
292- expect ( queryResult . data . reports . edges . length ) . toEqual ( 3 ) ; // the reports created + the report in DATA-TEST-STIX2_v2.json
313+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 4 ) ; // 3 of the created reports + the report in DATA-TEST-STIX2_v2.json
293314 } ) ;
294315 it ( 'should list entities according to filters: filters with different operators' , async ( ) => {
295316 // (report_types = threat-report) AND (report_types != internal-report)
@@ -347,7 +368,7 @@ describe('Complex filters combinations for elastic queries', () => {
347368 } ,
348369 } ,
349370 } ) ;
350- expect ( queryResult . data . reports . edges . length ) . toEqual ( 3 ) ; // report1 and report3 and report in DATA-TEST-STIX2_v2.json
371+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 4 ) ; // report1, report3, report5 and report in DATA-TEST-STIX2_v2.json
351372 expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report1' ) ) . toBeTruthy ( ) ;
352373 expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report3' ) ) . toBeTruthy ( ) ;
353374 expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) ) . includes ( 'A demo report for testing purposes' ) . toBeTruthy ( ) ;
@@ -398,7 +419,7 @@ describe('Complex filters combinations for elastic queries', () => {
398419 } ,
399420 } ,
400421 } ) ;
401- expect ( queryResult . data . reports . edges . length ) . toEqual ( 4 ) ; // 3 of the reports created + the report in DATA-TEST-STIX2_v2.json
422+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 5 ) ; // 4 of the reports created + the report in DATA-TEST-STIX2_v2.json
402423 // (report_types = internal-report AND threat-report)
403424 queryResult = await queryAsAdmin ( {
404425 query : REPORT_LIST_QUERY ,
@@ -418,8 +439,9 @@ describe('Complex filters combinations for elastic queries', () => {
418439 } ,
419440 } ,
420441 } ) ;
421- expect ( queryResult . data . reports . edges . length ) . toEqual ( 1 ) ;
422- expect ( queryResult . data . reports . edges [ 0 ] . node . name ) . toEqual ( 'Report2' ) ;
442+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 2 ) ;
443+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report2' ) ) . toBeTruthy ( ) ;
444+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report5' ) ) . toBeTruthy ( ) ;
423445 } ) ;
424446 it ( 'should list entities according to filters: filters and filter groups' , async ( ) => {
425447 // (report_types = threat-report AND published before 30/12/2021)
@@ -700,8 +722,9 @@ describe('Complex filters combinations for elastic queries', () => {
700722 } ,
701723 } ,
702724 } ) ;
703- expect ( queryResult . data . reports . edges . length ) . toEqual ( 1 ) ;
704- expect ( queryResult . data . reports . edges [ 0 ] . node . name ) . toEqual ( 'Report3' ) ;
725+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 2 ) ;
726+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report3' ) ) . toBeTruthy ( ) ;
727+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report5' ) ) . toBeTruthy ( ) ;
705728 // test for 'not_nil': objectMarking is not empty
706729 queryResult = await queryAsAdmin ( {
707730 query : REPORT_LIST_QUERY ,
@@ -744,9 +767,10 @@ describe('Complex filters combinations for elastic queries', () => {
744767 } ,
745768 } ,
746769 } ) ;
747- expect ( queryResult . data . reports . edges . length ) . toEqual ( 2 ) ;
748- expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report3' ) ) . toBeTruthy ( ) ; // description is empty string
749- expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report4' ) ) . toBeTruthy ( ) ; // description is null
770+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 3 ) ;
771+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report3' ) ) . toBeTruthy ( ) ; // description is undefined
772+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report4' ) ) . toBeTruthy ( ) ; // description is empty string
773+ expect ( queryResult . data . reports . edges . map ( ( n ) => n . node . name ) . includes ( 'Report5' ) ) . toBeTruthy ( ) ; // description is null
750774 // description is not empty
751775 queryResult = await queryAsAdmin ( {
752776 query : REPORT_LIST_QUERY ,
@@ -957,7 +981,7 @@ describe('Complex filters combinations for elastic queries', () => {
957981 } ,
958982 } ,
959983 } ) ;
960- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 8 ) ; // 8 containers: 4 reports in this file + 1 report, 1 note, 1 observed-data, 1 opinion in DATA-TEST-STIXv2_v2
984+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 9 ) ; // 9 containers: 5 reports in this file + 1 report, 1 note, 1 observed-data, 1 opinion in DATA-TEST-STIXv2_v2
961985 // (entity_type = Report AND container)
962986 queryResult = await queryAsAdmin ( {
963987 query : LIST_QUERY ,
@@ -977,7 +1001,7 @@ describe('Complex filters combinations for elastic queries', () => {
9771001 } ,
9781002 } ,
9791003 } ) ;
980- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 5 ) ; // 5 reports
1004+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 6 ) ; // 5 reports created in this file + 1 report in DATA-TEST-STIXv2_v2
9811005 // (entity_type = Report AND Container AND Stix-Core-Object)
9821006 queryResult = await queryAsAdmin ( {
9831007 query : LIST_QUERY ,
@@ -997,7 +1021,7 @@ describe('Complex filters combinations for elastic queries', () => {
9971021 } ,
9981022 } ,
9991023 } ) ;
1000- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 5 ) ; // 5 reports
1024+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 6 ) ; // 5 reports created in this file + 1 report in DATA-TEST-STIXv2_v2
10011025 // (entity_type = Report AND Container AND Internal-Object)
10021026 queryResult = await queryAsAdmin ( {
10031027 query : LIST_QUERY ,
@@ -1277,7 +1301,7 @@ describe('Complex filters combinations for elastic queries', () => {
12771301 filters : undefined ,
12781302 } ,
12791303 } ) ;
1280- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 44 ) ;
1304+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 45 ) ;
12811305 // (source_reliability is empty)
12821306 queryResult = await queryAsAdmin ( {
12831307 query : LIST_QUERY ,
@@ -1297,7 +1321,7 @@ describe('Complex filters combinations for elastic queries', () => {
12971321 } ,
12981322 } ,
12991323 } ) ;
1300- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 33 ) ; // 44 entities - 11 entities with a source reliability = 33
1324+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 34 ) ; // 45 entities - 11 entities with a source reliability = 34
13011325 // (source_reliability is not empty)
13021326 queryResult = await queryAsAdmin ( {
13031327 query : LIST_QUERY ,
@@ -1357,7 +1381,7 @@ describe('Complex filters combinations for elastic queries', () => {
13571381 } ,
13581382 } ,
13591383 } ) ;
1360- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 38 ) ; // 44 entities - 6 entities with source reliability equals to A = 38
1384+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 39 ) ; // 45 entities - 6 entities with source reliability equals to A = 39
13611385 // (source_reliability = A - Completely reliable OR B - Usually reliable)
13621386 queryResult = await queryAsAdmin ( {
13631387 query : LIST_QUERY ,
@@ -1460,7 +1484,7 @@ describe('Complex filters combinations for elastic queries', () => {
14601484 } ,
14611485 } ,
14621486 } ) ;
1463- expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 31 ) ; // 44 - 11 with a source reliability - 2 with a reliability (and no source reliability) = 31
1487+ expect ( queryResult . data . globalSearch . edges . length ) . toEqual ( 32 ) ; // 45 - 11 with a source reliability - 2 with a reliability (and no source reliability) = 31
14641488 // (computed_reliability is not empty)
14651489 queryResult = await queryAsAdmin ( {
14661490 query : LIST_QUERY ,
@@ -2372,7 +2396,7 @@ describe('Complex filters combinations for elastic queries', () => {
23722396 } ,
23732397 } ,
23742398 } ) ;
2375- expect ( queryResult . data . reports . edges . length ) . toEqual ( 3 ) ; // the reports published in the last 3 years: report1, report2, report4
2399+ expect ( queryResult . data . reports . edges . length ) . toEqual ( 4 ) ; // the reports published in the last 3 years: report1, report2, report4, report5
23762400 } ) ;
23772401 it ( 'should test environment deleted' , async ( ) => {
23782402 const DELETE_REPORT_QUERY = gql `
@@ -2406,6 +2430,10 @@ describe('Complex filters combinations for elastic queries', () => {
24062430 query : DELETE_REPORT_QUERY ,
24072431 variables : { id : report4InternalId } ,
24082432 } ) ;
2433+ await queryAsAdmin ( {
2434+ query : DELETE_REPORT_QUERY ,
2435+ variables : { id : report5InternalId } ,
2436+ } ) ;
24092437 await queryAsAdmin ( {
24102438 query : DELETE_MARKING_QUERY ,
24112439 variables : { id : marking1Id } ,
@@ -2428,6 +2456,9 @@ describe('Complex filters combinations for elastic queries', () => {
24282456 queryResult = await queryAsAdmin ( { query : READ_REPORT_QUERY , variables : { id : report4StixId } } ) ;
24292457 expect ( queryResult ) . not . toBeNull ( ) ;
24302458 expect ( queryResult . data . report ) . toBeNull ( ) ;
2459+ queryResult = await queryAsAdmin ( { query : READ_REPORT_QUERY , variables : { id : report5StixId } } ) ;
2460+ expect ( queryResult ) . not . toBeNull ( ) ;
2461+ expect ( queryResult . data . report ) . toBeNull ( ) ;
24312462 queryResult = await queryAsAdmin ( { query : READ_MARKING_QUERY , variables : { id : marking1StixId } } ) ;
24322463 expect ( queryResult ) . not . toBeNull ( ) ;
24332464 expect ( queryResult . data . markingDefinition ) . toBeNull ( ) ;
0 commit comments