@@ -305,25 +305,25 @@ public function testCanVerifyIpInLiveModeWithCacheSystem($cacheAdapterName, $ori
305
305
306
306
$ this ->assertEquals (
307
307
'ban ' ,
308
- $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP ),
308
+ $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ,
309
309
'Get decisions for a bad IP (for the first time, it should be a cache miss) '
310
310
);
311
311
312
312
$ this ->assertEquals (
313
313
'ban ' ,
314
- $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP ),
314
+ $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ,
315
315
'Call the same thing for the second time (now it should be a cache hit) '
316
316
);
317
317
318
- $ cleanRemediation1stCall = $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP );
318
+ $ cleanRemediation1stCall = $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP )[ ' remediation ' ] ;
319
319
$ this ->assertEquals (
320
320
'bypass ' ,
321
321
$ cleanRemediation1stCall ,
322
322
'Get decisions for a clean IP for the first time (it should be a cache miss) '
323
323
);
324
324
325
325
// Call the same thing for the second time (now it should be a cache hit)
326
- $ cleanRemediation2ndCall = $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP );
326
+ $ cleanRemediation2ndCall = $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP )[ ' remediation ' ] ;
327
327
$ this ->assertEquals ('bypass ' , $ cleanRemediation2ndCall );
328
328
329
329
// Prune cache
@@ -336,13 +336,13 @@ public function testCanVerifyIpInLiveModeWithCacheSystem($cacheAdapterName, $ori
336
336
337
337
// Call one more time (should miss as the cache has been cleared)
338
338
339
- $ remediation3rdCall = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP );
339
+ $ remediation3rdCall = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ;
340
340
$ this ->assertEquals ('ban ' , $ remediation3rdCall );
341
341
342
342
// Reconfigure the bouncer to set maximum remediation level to "captcha"
343
343
$ bouncerConfigs ['bouncing_level ' ] = Constants::BOUNCING_LEVEL_FLEX ;
344
344
$ bouncer = new Bouncer ($ bouncerConfigs , $ this ->logger );
345
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP );
345
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ;
346
346
$ this ->assertEquals ('captcha ' , $ cappedRemediation , 'The remediation for the banned IP should now be "captcha" ' );
347
347
// Reset the max remediation level to its origin state
348
348
$ bouncerConfigs ['bouncing_level ' ] = Constants::BOUNCING_LEVEL_NORMAL ;
@@ -357,7 +357,7 @@ public function testCanVerifyIpInLiveModeWithCacheSystem($cacheAdapterName, $ori
357
357
TestHelpers::BAD_IP . '/ ' . TestHelpers::LARGE_IPV4_RANGE ,
358
358
'ban '
359
359
);
360
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP );
360
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ;
361
361
$ this ->assertEquals (
362
362
'ban ' ,
363
363
$ cappedRemediation ,
@@ -373,7 +373,7 @@ public function testCanVerifyIpInLiveModeWithCacheSystem($cacheAdapterName, $ori
373
373
TestHelpers::BAD_IPV6 . '/ ' . TestHelpers::IPV6_RANGE ,
374
374
'ban '
375
375
);
376
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 );
376
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 )[ ' remediation ' ] ;
377
377
$ this ->assertEquals (
378
378
'ban ' ,
379
379
$ cappedRemediation ,
@@ -387,7 +387,7 @@ public function testCanVerifyIpInLiveModeWithCacheSystem($cacheAdapterName, $ori
387
387
TestHelpers::BAD_IPV6 ,
388
388
'ban '
389
389
);
390
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 );
390
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 )[ ' remediation ' ] ;
391
391
$ this ->assertEquals (
392
392
'ban ' ,
393
393
$ cappedRemediation ,
@@ -432,27 +432,27 @@ public function testCanVerifyIpInStreamModeWithCacheSystem($cacheAdapterName, $o
432
432
433
433
$ this ->assertEquals (
434
434
'ban ' ,
435
- $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP ),
435
+ $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ,
436
436
'Get decisions for a bad IP for the first time (as the cache has been warmed up should be a cache hit) '
437
437
);
438
438
439
439
// Reconfigure the bouncer to set maximum remediation level to "captcha"
440
440
$ bouncerConfigs ['bouncing_level ' ] = Constants::BOUNCING_LEVEL_FLEX ;
441
441
$ bouncer = new Bouncer ($ bouncerConfigs , $ this ->logger );
442
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP );
442
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ;
443
443
$ this ->assertEquals ('captcha ' , $ cappedRemediation , 'The remediation for the banned IP should now be "captcha" ' );
444
444
$ bouncerConfigs ['bouncing_level ' ] = Constants::BOUNCING_LEVEL_NORMAL ;
445
445
$ bouncer = new Bouncer ($ bouncerConfigs , $ this ->logger );
446
446
$ this ->assertEquals (
447
447
'bypass ' ,
448
- $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP ),
448
+ $ bouncer ->getRemediationForIp (TestHelpers::CLEAN_IP )[ ' remediation ' ] ,
449
449
'Get decisions for a clean IP for the first time (as the cache has been warmed up should be a cache hit) '
450
450
);
451
451
452
452
// Preload the remediation to prepare the next tests.
453
453
$ this ->assertEquals (
454
454
'bypass ' ,
455
- $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP ),
455
+ $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP )[ ' remediation ' ] ,
456
456
'Preload the bypass remediation to prepare the next tests '
457
457
);
458
458
@@ -464,13 +464,13 @@ public function testCanVerifyIpInStreamModeWithCacheSystem($cacheAdapterName, $o
464
464
465
465
$ this ->assertEquals (
466
466
'ban ' ,
467
- $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP ),
467
+ $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP )[ ' remediation ' ] ,
468
468
'The new decision should now be added, so the previously clean IP should now be bad '
469
469
);
470
470
471
471
$ this ->assertEquals (
472
472
'bypass ' ,
473
- $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP ),
473
+ $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ,
474
474
'The old decisions should now be removed, so the previously bad IP should now be clean '
475
475
);
476
476
@@ -497,7 +497,7 @@ public function testCanVerifyIpInStreamModeWithCacheSystem($cacheAdapterName, $o
497
497
498
498
$ this ->assertEquals (
499
499
'ban ' ,
500
- $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP ),
500
+ $ bouncer ->getRemediationForIp (TestHelpers::NEWLY_BAD_IP )[ ' remediation ' ] ,
501
501
'The cache warm up should be stored across each instantiation '
502
502
);
503
503
@@ -520,13 +520,13 @@ public function testCanVerifyIpInStreamModeWithCacheSystem($cacheAdapterName, $o
520
520
// Pull updates
521
521
$ bouncer ->refreshBlocklistCache ();
522
522
523
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP );
523
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IP )[ ' remediation ' ] ;
524
524
$ this ->assertEquals (
525
525
'ban ' ,
526
526
$ cappedRemediation ,
527
527
'The remediation for the banned IP with a large range should be "ban" even in stream mode '
528
528
);
529
- $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 );
529
+ $ cappedRemediation = $ bouncer ->getRemediationForIp (TestHelpers::BAD_IPV6 )[ ' remediation ' ] ;
530
530
$ this ->assertEquals (
531
531
'bypass ' ,
532
532
$ cappedRemediation ,
@@ -710,12 +710,6 @@ public function testAppSecFlow()
710
710
);
711
711
}
712
712
713
- $ this ->assertEquals (
714
- ['bypass ' => 1 ],
715
- $ originCountItem ['clean ' ],
716
- 'The origin count for clean should be 1 '
717
- );
718
-
719
713
// Test 3: clean IP and clean request
720
714
$ bouncer ->clearCache ();
721
715
$ _SERVER ['REMOTE_ADDR ' ] = '127.0.0.1 ' ;
@@ -743,11 +737,6 @@ public function testAppSecFlow()
743
737
'The origin count for clean appsec should be 1 '
744
738
);
745
739
}
746
- $ this ->assertEquals (
747
- ['bypass ' => 1 ],
748
- $ originCountItem ['clean ' ],
749
- 'The origin count for clean should be 1 '
750
- );
751
740
}
752
741
753
742
/**
0 commit comments