Harden NordVPN reconciliation and WebGUI testing
This commit is contained in:
parent
a115d2a012
commit
b4a30ca190
1 changed files with 777 additions and 97 deletions
|
|
@ -27,6 +27,44 @@ final class StoreAndInspectorTest extends TestCase
|
|||
$this->assertSame(1, $requests);
|
||||
|
||||
unlink($path);
|
||||
unlink($path . '.refreshed');
|
||||
rmdir($directory);
|
||||
}
|
||||
|
||||
public function testEndpointRefreshDefersAfterFailure(): void
|
||||
{
|
||||
$directory = sys_get_temp_dir() . '/nordvpn-endpoints-' . bin2hex(random_bytes(8));
|
||||
$path = $directory . '/endpoints.txt';
|
||||
$now = time();
|
||||
$requests = 0;
|
||||
$api = new NordApi(static function () use (&$requests): array {
|
||||
$requests++;
|
||||
throw new RuntimeException('Synthetic endpoint failure.');
|
||||
});
|
||||
$store = new EndpointStore($path, static function () use (&$now): int {
|
||||
return $now;
|
||||
});
|
||||
|
||||
try {
|
||||
$store->refreshIfStale($api);
|
||||
$this->fail('Expected endpoint refresh to fail.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Synthetic endpoint failure.', $exception->getMessage());
|
||||
}
|
||||
$this->assertTrue($store->retryPending());
|
||||
$this->assertFalse($store->refreshIfStale($api));
|
||||
$this->assertSame(1, $requests);
|
||||
|
||||
$now += 301;
|
||||
try {
|
||||
$store->refreshIfStale($api);
|
||||
$this->fail('Expected endpoint refresh retry to fail.');
|
||||
} catch (RuntimeException $exception) {
|
||||
$this->assertSame('Synthetic endpoint failure.', $exception->getMessage());
|
||||
}
|
||||
$this->assertSame(2, $requests);
|
||||
|
||||
unlink($path . '.retry');
|
||||
rmdir($directory);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue