@@ -16,15 +16,13 @@ async function verifyKerberosAuthentication(client) {
1616 expect ( docs ) . to . have . nested . property ( '[0].kerberos' , true ) ;
1717}
1818
19- describe ( 'Kerberos' , function ( ) {
20- let resolvePtrSpy ;
21- let resolveCnameSpy ;
19+ describe . only ( 'Kerberos' , function ( ) {
20+ let resolveSpy ;
2221 let client ;
2322
2423 beforeEach ( ( ) => {
2524 sinon . spy ( dns , 'lookup' ) ;
26- resolvePtrSpy = sinon . spy ( dns , 'resolvePtr' ) ;
27- resolveCnameSpy = sinon . spy ( dns , 'resolveCname' ) ;
25+ resolveSpy = sinon . spy ( dns , 'resolve' ) ;
2826 } ) ;
2927
3028 afterEach ( function ( ) {
@@ -65,7 +63,7 @@ describe('Kerberos', function () {
6563 `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:forward&maxPoolSize=1`
6664 ) ;
6765 await client . connect ( ) ;
68- expect ( dns . resolveCname ) . to . be . calledOnceWith ( host ) ;
66+ expect ( resolveSpy . withArgs ( sinon . match . string , 'SRV' ) ) . to . be . calledOnceWith ( host ) ;
6967 await verifyKerberosAuthentication ( client ) ;
7068 } ) ;
7169 } ) ;
@@ -77,7 +75,7 @@ describe('Kerberos', function () {
7775 `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:${ option } &maxPoolSize=1`
7876 ) ;
7977 await client . connect ( ) ;
80- expect ( dns . resolveCname ) . to . not . be . called ;
78+ expect ( resolveSpy . withArgs ( 'CNAME' ) ) . to . not . be . called ;
8179 // There are 2 calls to establish connection, however they use the callback form of dns.lookup
8280 expect ( dns . lookup ) . to . not . be . called ;
8381 await verifyKerberosAuthentication ( client ) ;
@@ -89,8 +87,8 @@ describe('Kerberos', function () {
8987 context ( `when the value is ${ option } ` , function ( ) {
9088 context ( 'when the reverse lookup succeeds' , function ( ) {
9189 beforeEach ( function ( ) {
92- resolvePtrSpy . restore ( ) ;
93- sinon . stub ( dns , 'resolvePtr ' ) . resolves ( [ host ] ) ;
90+ resolveSpy . restore ( ) ;
91+ resolveSpy . withArgs ( sinon . match . string , 'PTR ' ) . resolves ( [ host ] ) ;
9492 } ) ;
9593
9694 it ( 'authenticates with a forward dns lookup and a reverse ptr lookup' , async function ( ) {
@@ -101,15 +99,15 @@ describe('Kerberos', function () {
10199 // There are 2 calls to establish connection, however they use the callback form of dns.lookup
102100 // 1 dns.promises.lookup call in canonicalization.
103101 expect ( dns . lookup ) . to . be . calledOnce ;
104- expect ( dns . resolvePtr ) . to . be . calledOnce ;
102+ expect ( resolveSpy . withArgs ( sinon . match . string , 'PTR' ) ) . to . be . calledOnce ;
105103 await verifyKerberosAuthentication ( client ) ;
106104 } ) ;
107105 } ) ;
108106
109107 context ( 'when the reverse lookup is empty' , function ( ) {
110108 beforeEach ( function ( ) {
111- resolvePtrSpy . restore ( ) ;
112- sinon . stub ( dns , 'resolvePtr ' ) . resolves ( [ ] ) ;
109+ resolveSpy . restore ( ) ;
110+ resolveSpy . withArgs ( sinon . match . string , 'PTR ' ) . resolves ( [ ] ) ;
113111 } ) ;
114112
115113 it ( 'authenticates with a fallback cname lookup' , async function ( ) {
@@ -122,17 +120,17 @@ describe('Kerberos', function () {
122120 // 1 dns.promises.lookup call in canonicalization.
123121 expect ( dns . lookup ) . to . be . calledOnce ;
124122 // This fails.
125- expect ( dns . resolvePtr ) . to . be . calledOnce ;
123+ expect ( resolveSpy . withArgs ( sinon . match . string , 'PTR' ) ) . to . be . calledOnce ;
126124 // Expect the fallback to the host name.
127- expect ( dns . resolveCname ) . to . not . be . called ;
125+ expect ( resolveSpy . withArgs ( sinon . match . string , 'CNAME' ) ) . to . not . be . called ;
128126 await verifyKerberosAuthentication ( client ) ;
129127 } ) ;
130128 } ) ;
131129
132130 context ( 'when the reverse lookup fails' , function ( ) {
133131 beforeEach ( function ( ) {
134- resolvePtrSpy . restore ( ) ;
135- sinon . stub ( dns , 'resolvePtr ' ) . rejects ( new Error ( 'not found' ) ) ;
132+ resolveSpy . restore ( ) ;
133+ resolveSpy . withArgs ( sinon . match . string , 'PTR ' ) . rejects ( new Error ( 'not found' ) ) ;
136134 } ) ;
137135
138136 it ( 'authenticates with a fallback cname lookup' , async function ( ) {
@@ -145,17 +143,17 @@ describe('Kerberos', function () {
145143 // 1 dns.promises.lookup call in canonicalization.
146144 expect ( dns . lookup ) . to . be . calledOnce ;
147145 // This fails.
148- expect ( dns . resolvePtr ) . to . be . calledOnce ;
146+ expect ( resolveSpy . withArgs ( sinon . match . string , 'PTR' ) ) . to . be . calledOnce ;
149147 // Expect the fallback to be called.
150- expect ( dns . resolveCname ) . to . be . calledOnceWith ( host ) ;
148+ expect ( resolveSpy . withArgs ( sinon . match . string , 'CNAME' ) ) . to . be . calledOnceWith ( host ) ;
151149 await verifyKerberosAuthentication ( client ) ;
152150 } ) ;
153151 } ) ;
154152
155153 context ( 'when the cname lookup fails' , function ( ) {
156154 beforeEach ( function ( ) {
157- resolveCnameSpy . restore ( ) ;
158- sinon . stub ( dns , 'resolveCname ' ) . rejects ( new Error ( 'not found' ) ) ;
155+ resolveSpy . restore ( ) ;
156+ resolveSpy . withArgs ( sinon . match . string , 'CNAME ' ) . rejects ( new Error ( 'not found' ) ) ;
159157 } ) ;
160158
161159 it ( 'authenticates with a fallback host name' , async function ( ) {
@@ -167,16 +165,16 @@ describe('Kerberos', function () {
167165 // 1 dns.promises.lookup call in canonicalization.
168166 expect ( dns . lookup ) . to . be . calledOnce ;
169167 // This fails.
170- expect ( dns . resolvePtr ) . to . be . calledOnce ;
168+ expect ( resolveSpy . withArgs ( sinon . match . string , 'PTR' ) ) . to . be . calledOnce ;
171169 // Expect the fallback to be called.
172- expect ( dns . resolveCname ) . to . be . calledOnceWith ( host ) ;
170+ expect ( resolveSpy . withArgs ( sinon . match . string , 'CNAME' ) ) . to . be . calledOnceWith ( host ) ;
173171 await verifyKerberosAuthentication ( client ) ;
174172 } ) ;
175173 } ) ;
176174
177175 context ( 'when the cname lookup is empty' , function ( ) {
178176 beforeEach ( function ( ) {
179- resolveCnameSpy . restore ( ) ;
177+ resolveSpy . restore ( ) ;
180178 sinon . stub ( dns , 'resolveCname' ) . resolves ( [ ] ) ;
181179 } ) ;
182180
@@ -189,9 +187,9 @@ describe('Kerberos', function () {
189187 // 1 dns.promises.lookup call in canonicalization.
190188 expect ( dns . lookup ) . to . be . calledOnce ;
191189 // This fails.
192- expect ( dns . resolvePtr ) . to . be . calledOnce ;
190+ expect ( resolveSpy . withArgs ( sinon . match . string , 'PTR' ) ) . to . be . calledOnce ;
193191 // Expect the fallback to be called.
194- expect ( dns . resolveCname ) . to . be . calledOnceWith ( host ) ;
192+ expect ( resolveSpy . withArgs ( sinon . match . string , 'CNAME' ) ) . to . be . calledOnceWith ( host ) ;
195193 await verifyKerberosAuthentication ( client ) ;
196194 } ) ;
197195 } ) ;
0 commit comments