Skip to content

Commit 0b4c021

Browse files
test(*): Add some delay to make the test pass
1 parent 6ba2a18 commit 0b4c021

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

tests/Integration/AbstractBouncerTest.php

-7
Original file line numberDiff line numberDiff line change
@@ -1252,22 +1252,15 @@ public function testCanVerifyIpInStreamMode(): void
12521252
$bouncer->getRemediationForIp(TestHelpers::NEWLY_BAD_IP),
12531253
'Preload the bypass remediation to prepare the next tests'
12541254
);
1255-
12561255
// Add and remove decision
1257-
$this->logger->info('DEBUG', ['message' => 'Start SecondState test']);
12581256
$this->watcherClient->setSecondState();
1259-
12601257
// Pull updates
12611258
$bouncer->refreshBlocklistCache();
1262-
1263-
$this->logger->info('DEBUG', ['message' => 'Will check 3.4.5.6']);
12641259
$this->assertEquals(
12651260
'ban',
12661261
$bouncer->getRemediationForIp(TestHelpers::NEWLY_BAD_IP),
12671262
'The new decision should now be added, so the previously clean IP should now be bad'
12681263
);
1269-
1270-
$this->logger->info('DEBUG', ['message' => 'Will check 1.2.3.4']);
12711264
$this->assertEquals(
12721265
'bypass',
12731266
$bouncer->getRemediationForIp(TestHelpers::BAD_IP),

tests/Integration/WatcherClient.php

+4
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,20 @@ private function manageRequest(
6666
public function setInitialState(): void
6767
{
6868
$this->deleteAllDecisions();
69+
sleep(1);
6970
$now = new \DateTime();
7071
$this->addDecision($now, '12h', '+12 hours', TestHelpers::BAD_IP, 'captcha');
7172
$this->addDecision($now, '24h', self::HOURS24, TestHelpers::BAD_IP . '/' . TestHelpers::IP_RANGE, 'ban');
7273
$this->addDecision($now, '24h', '+24 hours', TestHelpers::JAPAN, 'captcha', Constants::SCOPE_COUNTRY);
74+
sleep(1);
7375
}
7476

7577
/** Set the second watcher state */
7678
public function setSecondState(): void
7779
{
7880
$this->logger->info('', ['message' => 'Set "second" state']);
7981
$this->deleteAllDecisions();
82+
sleep(1);
8083
$now = new \DateTime();
8184
$this->addDecision($now, '36h', '+36 hours', TestHelpers::NEWLY_BAD_IP, 'ban');
8285
$this->addDecision(
@@ -89,6 +92,7 @@ public function setSecondState(): void
8992
$this->addDecision($now, '24h', self::HOURS24, TestHelpers::JAPAN, 'captcha', Constants::SCOPE_COUNTRY);
9093
$this->addDecision($now, '24h', self::HOURS24, TestHelpers::IP_JAPAN, 'ban');
9194
$this->addDecision($now, '24h', self::HOURS24, TestHelpers::IP_FRANCE, 'ban');
95+
sleep(1);
9296
}
9397

9498
public function setSimpleDecision(string $type = 'ban'): void

0 commit comments

Comments
 (0)