From 0b4c0213bff6303dcfc2a959bf62c9ecebd2cfac Mon Sep 17 00:00:00 2001 From: Julien Loizelet Date: Fri, 18 Oct 2024 16:41:56 +0900 Subject: [PATCH] test(*): Add some delay to make the test pass --- tests/Integration/AbstractBouncerTest.php | 7 ------- tests/Integration/WatcherClient.php | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/Integration/AbstractBouncerTest.php b/tests/Integration/AbstractBouncerTest.php index 7cba506..1d43393 100644 --- a/tests/Integration/AbstractBouncerTest.php +++ b/tests/Integration/AbstractBouncerTest.php @@ -1252,22 +1252,15 @@ public function testCanVerifyIpInStreamMode(): void $bouncer->getRemediationForIp(TestHelpers::NEWLY_BAD_IP), 'Preload the bypass remediation to prepare the next tests' ); - // Add and remove decision - $this->logger->info('DEBUG', ['message' => 'Start SecondState test']); $this->watcherClient->setSecondState(); - // Pull updates $bouncer->refreshBlocklistCache(); - - $this->logger->info('DEBUG', ['message' => 'Will check 3.4.5.6']); $this->assertEquals( 'ban', $bouncer->getRemediationForIp(TestHelpers::NEWLY_BAD_IP), 'The new decision should now be added, so the previously clean IP should now be bad' ); - - $this->logger->info('DEBUG', ['message' => 'Will check 1.2.3.4']); $this->assertEquals( 'bypass', $bouncer->getRemediationForIp(TestHelpers::BAD_IP), diff --git a/tests/Integration/WatcherClient.php b/tests/Integration/WatcherClient.php index 3909c06..9c3b07f 100644 --- a/tests/Integration/WatcherClient.php +++ b/tests/Integration/WatcherClient.php @@ -66,10 +66,12 @@ private function manageRequest( public function setInitialState(): void { $this->deleteAllDecisions(); + sleep(1); $now = new \DateTime(); $this->addDecision($now, '12h', '+12 hours', TestHelpers::BAD_IP, 'captcha'); $this->addDecision($now, '24h', self::HOURS24, TestHelpers::BAD_IP . '/' . TestHelpers::IP_RANGE, 'ban'); $this->addDecision($now, '24h', '+24 hours', TestHelpers::JAPAN, 'captcha', Constants::SCOPE_COUNTRY); + sleep(1); } /** Set the second watcher state */ @@ -77,6 +79,7 @@ public function setSecondState(): void { $this->logger->info('', ['message' => 'Set "second" state']); $this->deleteAllDecisions(); + sleep(1); $now = new \DateTime(); $this->addDecision($now, '36h', '+36 hours', TestHelpers::NEWLY_BAD_IP, 'ban'); $this->addDecision( @@ -89,6 +92,7 @@ public function setSecondState(): void $this->addDecision($now, '24h', self::HOURS24, TestHelpers::JAPAN, 'captcha', Constants::SCOPE_COUNTRY); $this->addDecision($now, '24h', self::HOURS24, TestHelpers::IP_JAPAN, 'ban'); $this->addDecision($now, '24h', self::HOURS24, TestHelpers::IP_FRANCE, 'ban'); + sleep(1); } public function setSimpleDecision(string $type = 'ban'): void