Add DNS diagnostics across dataplane and client
This commit is contained in:
@@ -192,7 +192,15 @@ test('connectivity use case keeps applied priority, selected fallback and error
|
||||
test('diagnostics settings validate and replace one canonical revision', () => {
|
||||
let state = {
|
||||
revision: 7,
|
||||
diagnostics: { configured: false, customServices: [], hiddenServiceIds: [] },
|
||||
diagnostics: {
|
||||
configured: false,
|
||||
customServices: [],
|
||||
hiddenServiceIds: [],
|
||||
customDnsResolvers: [{
|
||||
id: 'custom-dns-office', label: 'Office', kind: 'dns', endpoint: '192.168.1.1',
|
||||
}],
|
||||
customDnsDomains: [{ id: 'custom-domain-office', label: 'Office', hostname: 'office.example.com' }],
|
||||
},
|
||||
};
|
||||
const useCase = createConnectivityDiagnosticsUseCase({
|
||||
state: {
|
||||
@@ -212,6 +220,10 @@ test('diagnostics settings validate and replace one canonical revision', () => {
|
||||
configured: true,
|
||||
customServices: [{ id: 'custom-status', label: 'Status', url: 'https://example.com/status' }],
|
||||
hiddenServiceIds: ['speedtest'],
|
||||
customDnsResolvers: [{
|
||||
id: 'custom-dns-office', label: 'Office', kind: 'dns', endpoint: '192.168.1.1',
|
||||
}],
|
||||
customDnsDomains: [{ id: 'custom-domain-office', label: 'Office', hostname: 'office.example.com' }],
|
||||
});
|
||||
assert.equal(state.revision, 8);
|
||||
assert.throws(() => useCase.updateSettings({ customServices: [], hiddenServiceIds: [] }, 7), {
|
||||
@@ -245,6 +257,11 @@ test('connectivity route preserves exact URL, defaults and raw response', async
|
||||
calls.push(args);
|
||||
return { checkedAt: 'now', vpn: { server: null } };
|
||||
},
|
||||
dnsCatalog: async () => ({ resolvers: [{ id: 'google-dns' }], domains: [] }),
|
||||
runDns: async (...args) => {
|
||||
calls.push(['dns', ...args]);
|
||||
return { checkedAt: 'dns-now', results: [] };
|
||||
},
|
||||
updateSettings: (...args) => calls.push(['settings', ...args]),
|
||||
},
|
||||
readBody: async () => {
|
||||
@@ -276,6 +293,16 @@ test('connectivity route preserves exact URL, defaults and raw response', async
|
||||
assert.deepEqual(calls.at(-1), ['settings', body.settings, 4]);
|
||||
assert.equal(settingsResponse.payload.success, true);
|
||||
|
||||
const catalogResponse = routeResponse();
|
||||
assert.equal(await route.handle({ method: 'GET', url: '/api/diagnostics/dns' }, catalogResponse), true);
|
||||
assert.deepEqual(catalogResponse.payload, { resolvers: [{ id: 'google-dns' }], domains: [] });
|
||||
|
||||
body = { domainId: 'youtube', resolverId: 'google-dns' };
|
||||
const dnsResponse = routeResponse();
|
||||
assert.equal(await route.handle({ method: 'POST', url: '/api/diagnostics/dns' }, dnsResponse), true);
|
||||
assert.deepEqual(calls.at(-1), ['dns', 'youtube', 'google-dns']);
|
||||
assert.deepEqual(dnsResponse.payload, { checkedAt: 'dns-now', results: [] });
|
||||
|
||||
for (const [method, url] of [
|
||||
['GET', '/api/diagnostics/connectivity'],
|
||||
['POST', '/api/diagnostics/connectivity?target=all'],
|
||||
@@ -284,7 +311,7 @@ test('connectivity route preserves exact URL, defaults and raw response', async
|
||||
]) {
|
||||
assert.equal(await route.handle({ method, url }, routeResponse()), false);
|
||||
}
|
||||
assert.equal(bodyReads, 3);
|
||||
assert.equal(bodyReads, 4);
|
||||
});
|
||||
|
||||
test('a targeted IP row uses three samples and keeps the majority address', async () => {
|
||||
|
||||
Reference in New Issue
Block a user