Add network identity diagnostics
Build and Deploy Gateway / build-and-push (push) Successful in 20s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-11 16:19:23 +03:00
parent 3566f4bc0b
commit 6381760b27
8 changed files with 211 additions and 9 deletions
@@ -49,6 +49,7 @@ test('connectivity diagnostics force separate direct and VPN paths', async () =>
assert.deepEqual(result.vpn.ipv4.addresses, ['203.0.113.20']);
assert.equal(result.direct.ipv6, '2001:db8::10');
assert.equal(result.vpn.ipv6, '2001:db8::20');
assert.equal(result.direct.network.error, 'invalid network response');
assert.equal(result.assessment.summary, 'available');
assert.ok(calls.some((args) => args.includes('--noproxy') && args.includes('*')));
assert.ok(calls.some((args) => args.includes('--proxy') && args.includes('http://127.0.0.1:18080')));
@@ -242,6 +243,48 @@ test('a targeted IP row uses three samples and keeps the majority address', asyn
assert.equal(result.vpn.ipv4.sources[0].latencyMs, 250);
});
test('a targeted network row reports provider, ASN and location through both forced paths', async () => {
const attempts = { direct: 0, vpn: 0 };
const calls = [];
const execute = async (args) => {
calls.push(args);
const route = args.includes('--proxy') ? 'vpn' : 'direct';
attempts[route] += 1;
if (route === 'direct' && attempts.direct === 1) return response('{invalid');
return response(JSON.stringify(route === 'vpn' ? {
success: true,
ip: '203.0.113.20',
city: 'Amsterdam',
country_code: 'NL',
connection: { asn: 9009, isp: 'M247 Europe' },
} : {
success: true,
ip: '198.51.100.10',
city: 'Moscow',
country_code: 'RU',
connection: { asn: 12389, isp: 'Rostelecom' },
}));
};
const result = await createConnectivityDiagnosticsService({ proxyPort: 18080, execute })
.run({ vpnAvailable: true, target: 'network' });
assert.deepEqual(attempts, { direct: 3, vpn: 3 });
assert.deepEqual(result.direct.network, {
address: '198.51.100.10',
asn: 'AS12389',
provider: 'Rostelecom',
city: 'Moscow',
country: 'RU',
attempts: 3,
error: null,
});
assert.equal(result.vpn.network.asn, 'AS9009');
assert.equal(result.vpn.network.provider, 'M247 Europe');
assert.ok(calls.every((args) => args.at(-1) === 'https://ipwho.is/' && args.includes('--ipv4')));
assert.ok(calls.some((args) => args.includes('--noproxy') && args.includes('*')));
assert.ok(calls.some((args) => args.includes('--proxy') && args.includes('http://127.0.0.1:18080')));
});
test('a targeted service row averages three measurements and ignores one transient failure', async () => {
const attempts = { direct: 0, vpn: 0 };
const execute = async (args) => {