@@ -23,7 +23,8 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
2323 beforeEach ( async function ( ) {
2424 // this fn stubs DNS resolution to always pass - so we are only checking pre-DNS validation
2525
26- sinon . stub ( dns . promises , 'resolve' ) . callsFake ( async ( ) => {
26+ const stub = sinon . stub ( dns . promises , 'resolve' ) ;
27+ stub . withArgs ( sinon . match . any , 'SRV' ) . callsFake ( async ( ) => {
2728 return [
2829 {
2930 name : 'resolved.mongo.localhost' ,
@@ -34,7 +35,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
3435 ] ;
3536 } ) ;
3637
37- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
38+ stub . withArgs ( sinon . match . any , 'TXT ' ) . callsFake ( async ( ) => {
3839 throw { code : 'ENODATA' } ;
3940 } ) ;
4041
@@ -84,9 +85,11 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
8485 * - the SRV mongodb+srv://blogs.mongodb.com resolving to blogs.evil.com
8586 * Remember, the domain of an SRV with one or two . separated parts is the SRVs entire hostname.
8687 */
88+ let stub ;
8789
8890 beforeEach ( async function ( ) {
89- sinon . stub ( dns . promises , 'resolve' ) . callsFake ( async ( ) => {
91+ stub = sinon . stub ( dns . promises , 'resolve' ) ;
92+ stub . withArgs ( sinon . match . any , 'TXT' ) . callsFake ( async ( ) => {
9093 throw { code : 'ENODATA' } ;
9194 } ) ;
9295 } ) ;
@@ -96,7 +99,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
9699 } ) ;
97100
98101 it ( 'an SRV with one domain level causes a runtime error' , async function ( ) {
99- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
102+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
100103 return [
101104 {
102105 name : 'localhost.mongodb' ,
@@ -115,7 +118,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
115118 } ) ;
116119
117120 it ( 'an SRV with two domain levels causes a runtime error' , async function ( ) {
118- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
121+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
119122 return [
120123 {
121124 name : 'test_1.evil.local' , // this string only ends with part of the domain, not all of it!
@@ -134,7 +137,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
134137 } ) ;
135138
136139 it ( 'an SRV with three or more domain levels causes a runtime error' , async function ( ) {
137- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
140+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
138141 return [
139142 {
140143 name : 'blogs.evil.com' ,
@@ -166,8 +169,11 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
166169 context (
167170 'when given a host from DNS resolution that is identical to the original SRVs hostname' ,
168171 function ( ) {
172+ let stub ;
173+
169174 beforeEach ( async function ( ) {
170- sinon . stub ( dns . promises , 'resolve' ) . callsFake ( async ( ) => {
175+ stub = sinon . stub ( dns . promises , 'resolve' ) ;
176+ stub . withArgs ( sinon . match . any , 'TXT' ) . callsFake ( async ( ) => {
171177 throw { code : 'ENODATA' } ;
172178 } ) ;
173179 } ) ;
@@ -177,7 +183,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
177183 } ) ;
178184
179185 it ( 'an SRV with one domain level causes a runtime error' , async function ( ) {
180- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
186+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
181187 return [
182188 {
183189 name : 'localhost' ,
@@ -198,7 +204,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
198204 } ) ;
199205
200206 it ( 'an SRV with two domain levels causes a runtime error' , async function ( ) {
201- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
207+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
202208 return [
203209 {
204210 name : 'mongo.local' ,
@@ -233,8 +239,11 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
233239 context (
234240 'when given a returned address that does NOT share the domain name of the SRV record because its missing a `.`' ,
235241 function ( ) {
242+ let stub ;
243+
236244 beforeEach ( async function ( ) {
237- sinon . stub ( dns . promises , 'resolve' ) . callsFake ( async ( ) => {
245+ stub = sinon . stub ( dns . promises , 'resolve' ) ;
246+ stub . withArgs ( sinon . match . any , 'TXT' ) . callsFake ( async ( ) => {
238247 throw { code : 'ENODATA' } ;
239248 } ) ;
240249 } ) ;
@@ -244,7 +253,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
244253 } ) ;
245254
246255 it ( 'an SRV with one domain level causes a runtime error' , async function ( ) {
247- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
256+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
248257 return [
249258 {
250259 name : 'test_1.cluster_1localhost' ,
@@ -263,7 +272,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
263272 } ) ;
264273
265274 it ( 'an SRV with two domain levels causes a runtime error' , async function ( ) {
266- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
275+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
267276 return [
268277 {
269278 name : 'test_1.my_hostmongo.local' ,
@@ -282,7 +291,7 @@ describe('Initial DNS Seedlist Discovery (Prose Tests)', () => {
282291 } ) ;
283292
284293 it ( 'an SRV with three domain levels causes a runtime error' , async function ( ) {
285- sinon . stub ( dns . promises , 'resolve ' ) . callsFake ( async ( ) => {
294+ stub . withArgs ( sinon . match . any , 'SRV ' ) . callsFake ( async ( ) => {
286295 return [
287296 {
288297 name : 'cluster.testmongodb.com' ,
0 commit comments