@@ -3,11 +3,16 @@ import { expect } from 'chai';
3
3
import { waitMesurementFinish } from '../utils.js' ;
4
4
5
5
describe ( 'dns mesurement' , ( ) => {
6
+ const resolver = '1.1.1.1' ;
7
+
6
8
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 ( ) ;
11
16
12
17
const response = await waitMesurementFinish ( id ) ;
13
18
@@ -18,13 +23,16 @@ describe('dns mesurement', () => {
18
23
} ) ;
19
24
20
25
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
+ } ,
26
34
} ,
27
- } } ) . json ( ) ;
35
+ } ) . json ( ) ;
28
36
29
37
const response = await waitMesurementFinish ( id ) ;
30
38
@@ -35,36 +43,46 @@ describe('dns mesurement', () => {
35
43
} ) ;
36
44
37
45
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
+ } ) ;
42
54
43
55
expect ( response . statusCode ) . to . equal ( 400 ) ;
44
56
} ) ;
45
57
46
58
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
+ } ,
52
66
} ,
53
- } , throwHttpErrors : false } ) ;
67
+ throwHttpErrors : false ,
68
+ } ) ;
54
69
55
70
expect ( response . statusCode ) . to . equal ( 400 ) ;
56
71
} ) ;
57
72
58
73
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
+ } ,
65
83
} ,
66
84
} ,
67
- } } ) . json ( ) ;
85
+ } ) . json ( ) ;
68
86
69
87
const response = await waitMesurementFinish ( id ) ;
70
88
@@ -74,15 +92,18 @@ describe('dns mesurement', () => {
74
92
} ) ;
75
93
76
94
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
+ } ,
83
104
} ,
84
105
} ,
85
- } } ) . json ( ) ;
106
+ } ) . json ( ) ;
86
107
87
108
const response = await waitMesurementFinish ( id ) ;
88
109
0 commit comments