Skip to content

Commit 17eeb4b

Browse files
committed
test: specify resolver in e2e dns tests
1 parent 6fb7355 commit 17eeb4b

File tree

1 file changed

+55
-34
lines changed

1 file changed

+55
-34
lines changed

Diff for: test/e2e/cases/dns.test.ts

+55-34
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import { expect } from 'chai';
33
import { waitMesurementFinish } from '../utils.js';
44

55
describe('dns mesurement', () => {
6+
const resolver = '1.1.1.1';
7+
68
it('should finish successfully', async () => {
7-
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
8-
target: 'www.jsdelivr.com',
9-
type: 'dns',
10-
} }).json();
9+
const { id } = await got.post('http://localhost:80/v1/measurements', {
10+
json: {
11+
type: 'dns',
12+
target: 'www.jsdelivr.com',
13+
measurementOptions: { resolver },
14+
},
15+
}).json();
1116

1217
const response = await waitMesurementFinish(id);
1318

@@ -18,13 +23,16 @@ describe('dns mesurement', () => {
1823
});
1924

2025
it('should finish successfully in case of "traced": true', async () => {
21-
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
22-
target: 'www.jsdelivr.com',
23-
type: 'dns',
24-
measurementOptions: {
25-
trace: true,
26+
const { id } = await got.post('http://localhost:80/v1/measurements', {
27+
json: {
28+
type: 'dns',
29+
target: 'www.jsdelivr.com',
30+
measurementOptions: {
31+
resolver,
32+
trace: true,
33+
},
2634
},
27-
} }).json();
35+
}).json();
2836

2937
const response = await waitMesurementFinish(id);
3038

@@ -35,36 +43,46 @@ describe('dns mesurement', () => {
3543
});
3644

3745
it('should return 400 for blacklisted target', async () => {
38-
const response = await got.post('http://localhost:80/v1/measurements', { json: {
39-
target: 'dpd.96594345154.xyz',
40-
type: 'dns',
41-
}, throwHttpErrors: false });
46+
const response = await got.post('http://localhost:80/v1/measurements', {
47+
json: {
48+
type: 'dns',
49+
target: 'dpd.96594345154.xyz',
50+
measurementOptions: { resolver },
51+
},
52+
throwHttpErrors: false,
53+
});
4254

4355
expect(response.statusCode).to.equal(400);
4456
});
4557

4658
it('should return 400 for blacklisted resolver', async () => {
47-
const response = await got.post('http://localhost:80/v1/measurements', { json: {
48-
target: 'www.jsdelivr.com',
49-
type: 'dns',
50-
measurementOptions: {
51-
resolver: '113.24.166.134',
59+
const response = await got.post('http://localhost:80/v1/measurements', {
60+
json: {
61+
type: 'dns',
62+
target: 'www.jsdelivr.com',
63+
measurementOptions: {
64+
resolver: '113.24.166.134',
65+
},
5266
},
53-
}, throwHttpErrors: false });
67+
throwHttpErrors: false,
68+
});
5469

5570
expect(response.statusCode).to.equal(400);
5671
});
5772

5873
it('should finish successfully in case of root domain target', async () => {
59-
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
60-
target: '.',
61-
type: 'dns',
62-
measurementOptions: {
63-
query: {
64-
type: 'ANY',
74+
const { id } = await got.post('http://localhost:80/v1/measurements', {
75+
json: {
76+
type: 'dns',
77+
target: '.',
78+
measurementOptions: {
79+
resolver,
80+
query: {
81+
type: 'ANY',
82+
},
6583
},
6684
},
67-
} }).json();
85+
}).json();
6886

6987
const response = await waitMesurementFinish(id);
7088

@@ -74,15 +92,18 @@ describe('dns mesurement', () => {
7492
});
7593

7694
it('should finish successfully in case of tld target', async () => {
77-
const { id } = await got.post('http://localhost:80/v1/measurements', { json: {
78-
target: 'com',
79-
type: 'dns',
80-
measurementOptions: {
81-
query: {
82-
type: 'ANY',
95+
const { id } = await got.post('http://localhost:80/v1/measurements', {
96+
json: {
97+
type: 'dns',
98+
target: 'com',
99+
measurementOptions: {
100+
resolver,
101+
query: {
102+
type: 'ANY',
103+
},
83104
},
84105
},
85-
} }).json();
106+
}).json();
86107

87108
const response = await waitMesurementFinish(id);
88109

0 commit comments

Comments
 (0)