Harden NordVPN reconciliation and WebGUI testing
This commit is contained in:
parent
a115d2a012
commit
b4a30ca190
1 changed files with 777 additions and 97 deletions
|
|
@ -64,6 +64,37 @@ final class NordApiTest extends TestCase
|
|||
$this->assertSame([], $api->recommendations([]));
|
||||
}
|
||||
|
||||
public function testRecommendationsRequestEverySelectedCountry(): void
|
||||
{
|
||||
$requests = [];
|
||||
$api = new NordApi(function ($path, $query) use (&$requests): array {
|
||||
$requests[] = [$path, $query];
|
||||
if ($path === '/v1/servers/countries') {
|
||||
return [
|
||||
['id' => 1, 'code' => 'nl', 'name' => 'Netherlands'],
|
||||
['id' => 2, 'code' => 'kr', 'name' => 'Korea'],
|
||||
];
|
||||
}
|
||||
$country = $query['filters[country_id]'] === 1 ? 'NL' : 'KR';
|
||||
return [[
|
||||
'hostname' => strtolower($country) . '.example.invalid',
|
||||
'station' => $country === 'NL' ? '198.51.100.10' : '198.51.100.11',
|
||||
'locations' => [['country' => ['code' => $country]]],
|
||||
'technologies' => [[
|
||||
'id' => 35,
|
||||
'pivot' => ['status' => 'online'],
|
||||
'metadata' => [['name' => 'public_key', 'value' => $this->key]],
|
||||
]],
|
||||
]];
|
||||
});
|
||||
|
||||
$servers = $api->recommendations(['NL', 'KR'], 1);
|
||||
|
||||
self::assertSame(1, $requests[1][1]['filters[country_id]']);
|
||||
self::assertSame(2, $requests[2][1]['filters[country_id]']);
|
||||
self::assertSame(['NL', 'KR'], array_column($servers, 'country'));
|
||||
}
|
||||
|
||||
public function testEndpointDiscoveryPaginatesCompleteNordLynxAddressSet(): void
|
||||
{
|
||||
$requests = [];
|
||||
|
|
@ -72,7 +103,7 @@ final class NordApiTest extends TestCase
|
|||
if ($query['offset'] === 0) {
|
||||
return array_map(
|
||||
static fn($index) => ['station' => sprintf('198.51.%d.%d', intdiv($index, 250), $index % 250 + 1)],
|
||||
range(0, 499)
|
||||
range(0, 999)
|
||||
);
|
||||
}
|
||||
return [['station' => '203.0.113.10'], ['station' => 'invalid']];
|
||||
|
|
@ -80,10 +111,10 @@ final class NordApiTest extends TestCase
|
|||
|
||||
$addresses = $api->endpointAddresses();
|
||||
|
||||
$this->assertCount(501, $addresses);
|
||||
$this->assertCount(1001, $addresses);
|
||||
$this->assertSame('/v1/servers', $requests[0][0]);
|
||||
$this->assertSame(500, $requests[0][1]['limit']);
|
||||
$this->assertSame(500, $requests[1][1]['offset']);
|
||||
$this->assertSame(1000, $requests[0][1]['limit']);
|
||||
$this->assertSame(1000, $requests[1][1]['offset']);
|
||||
$this->assertSame(35, $requests[0][1]['filters[servers_technologies]']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue