@@ -311,6 +311,7 @@ test("matchFilters", async function (t) {
311
311
{ allowed : false , matchedExpressions : [ ] , undeterminedExpressions : [ ] } ,
312
312
) ;
313
313
} ) ;
314
+
314
315
await t . test ( "should deny w/o `allowIfMatch` and a match" , async function ( ) {
315
316
assert . deepEqual (
316
317
await matchFilters (
@@ -341,4 +342,64 @@ test("matchFilters", async function (t) {
341
342
) ;
342
343
} ,
343
344
) ;
345
+
346
+ const tenExpressions = Array . from ( { length : 10 } , function ( _ , index ) {
347
+ return "ip.src == 127.0.0." + index ;
348
+ } ) ;
349
+
350
+ await t . test ( "should work w/ `10` expressions" , async function ( ) {
351
+ assert . deepEqual (
352
+ await matchFilters (
353
+ exampleContext ,
354
+ { ip : "127.0.0.127" } ,
355
+ tenExpressions ,
356
+ false ,
357
+ ) ,
358
+ { allowed : true , matchedExpressions : [ ] , undeterminedExpressions : [ ] } ,
359
+ ) ;
360
+ } ) ;
361
+
362
+ await t . test ( "should fail w/ `11` expressions" , async function ( ) {
363
+ await assert . rejects (
364
+ matchFilters (
365
+ exampleContext ,
366
+ { ip : "127.0.0.127" } ,
367
+ [ ...tenExpressions , "ip.src == 127.0.0.10" ] ,
368
+ false ,
369
+ ) ,
370
+ / F a i l e d t o m a t c h f i l t e r s : o n l y ` 1 0 ` e x p r e s s i o n s m a y b e p a s s e d / ,
371
+ ) ;
372
+ } ) ;
373
+
374
+ await t . test ( "should work w/ `1024` bytes" , async function ( ) {
375
+ const tenThousandTwentyFourBytes =
376
+ 'http.host eq "' + "a" . repeat ( 1009 ) + '"' ;
377
+ assert . equal ( new Blob ( [ tenThousandTwentyFourBytes ] ) . size , 1024 ) ;
378
+
379
+ assert . deepEqual (
380
+ await matchFilters (
381
+ exampleContext ,
382
+ { ip : "127.0.0.1" } ,
383
+ [ tenThousandTwentyFourBytes ] ,
384
+ false ,
385
+ ) ,
386
+ { allowed : true , matchedExpressions : [ ] , undeterminedExpressions : [ ] } ,
387
+ ) ;
388
+ } ) ;
389
+
390
+ await t . test ( "should fail w/ `1025` bytes" , async function ( ) {
391
+ const tenThousandTwentyFiveBytes =
392
+ 'http.host eq "' + "a" . repeat ( 1010 ) + '"' ;
393
+ assert . equal ( new Blob ( [ tenThousandTwentyFiveBytes ] ) . size , 1025 ) ;
394
+
395
+ await assert . rejects (
396
+ matchFilters (
397
+ exampleContext ,
398
+ { ip : "127.0.0.127" } ,
399
+ [ tenThousandTwentyFiveBytes ] ,
400
+ false ,
401
+ ) ,
402
+ / F a i l e d t o m a t c h f i l t e r s : o n l y ` 1 0 2 4 ` b y t e s m a y b e p a s s e d i n e x p r e s s i o n / ,
403
+ ) ;
404
+ } ) ;
344
405
} ) ;
0 commit comments