@@ -88,34 +88,39 @@ describe('Kerberos', function () {
8888 }
8989 } ) ;
9090
91- context ( 'when the value is true' , function ( ) {
92- it ( 'successfully authenticates' , function ( done ) {
93- const client = new MongoClient (
94- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:true&maxPoolSize=1`
95- ) ;
96- client . connect ( function ( err , client ) {
97- if ( err ) return done ( err ) ;
98- expect ( dns . resolveCname ) . to . be . calledOnce ;
99- verifyKerberosAuthentication ( client , done ) ;
91+ for ( const option of [ true , 'forward' ] ) {
92+ context ( `when the value is ${ option } ` , function ( ) {
93+ it ( 'authenticates with a forward cname lookup' , function ( done ) {
94+ const client = new MongoClient (
95+ `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:${ option } &maxPoolSize=1`
96+ ) ;
97+ client . connect ( function ( err , client ) {
98+ if ( err ) return done ( err ) ;
99+ expect ( dns . resolveCname ) . to . be . calledOnce ;
100+ verifyKerberosAuthentication ( client , done ) ;
101+ } ) ;
100102 } ) ;
101103 } ) ;
102- } ) ;
104+ }
103105
104- context ( 'when the value is forward' , function ( ) {
105- it ( 'successfully authenticates' , function ( done ) {
106- const client = new MongoClient (
107- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:forward&maxPoolSize=1`
108- ) ;
109- client . connect ( function ( err , client ) {
110- if ( err ) return done ( err ) ;
111- expect ( dns . resolveCname ) . to . be . calledOnce ;
112- verifyKerberosAuthentication ( client , done ) ;
106+ for ( const option of [ false , 'none' ] ) {
107+ context ( `when the value is ${ option } ` , function ( ) {
108+ it ( 'authenticates with no dns lookups' , function ( done ) {
109+ const client = new MongoClient (
110+ `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:${ option } &maxPoolSize=1`
111+ ) ;
112+ client . connect ( function ( err , client ) {
113+ if ( err ) return done ( err ) ;
114+ expect ( dns . resolveCname ) . to . not . be . called ;
115+ expect ( dns . lookup ) . to . not . be . called ;
116+ verifyKerberosAuthentication ( client , done ) ;
117+ } ) ;
113118 } ) ;
114119 } ) ;
115- } ) ;
120+ }
116121
117122 context ( 'when the value is forwardAndReverse' , function ( ) {
118- it ( 'successfully authenticates' , function ( done ) {
123+ it ( 'authenticates with a forward dns lookup and a reverse ptr lookup ' , function ( done ) {
119124 const client = new MongoClient (
120125 `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:forwardAndReverse&maxPoolSize=1`
121126 ) ;
@@ -127,34 +132,6 @@ describe('Kerberos', function () {
127132 } ) ;
128133 } ) ;
129134 } ) ;
130-
131- context ( 'when the value is false' , function ( ) {
132- it ( 'successfully authenticates' , function ( done ) {
133- const client = new MongoClient (
134- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false&maxPoolSize=1`
135- ) ;
136- client . connect ( function ( err , client ) {
137- if ( err ) return done ( err ) ;
138- expect ( dns . resolveCname ) . to . not . be . calledOnce ;
139- expect ( dns . lookup ) . to . not . be . calledOnce ;
140- verifyKerberosAuthentication ( client , done ) ;
141- } ) ;
142- } ) ;
143- } ) ;
144-
145- context ( 'when the value is none' , function ( ) {
146- it ( 'successfully authenticates' , function ( done ) {
147- const client = new MongoClient (
148- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:none&maxPoolSize=1`
149- ) ;
150- client . connect ( function ( err , client ) {
151- if ( err ) return done ( err ) ;
152- expect ( dns . resolveCname ) . to . not . be . calledOnce ;
153- expect ( dns . lookup ) . to . not . be . calledOnce ;
154- verifyKerberosAuthentication ( client , done ) ;
155- } ) ;
156- } ) ;
157- } ) ;
158135 } ) ;
159136
160137 // Unskip this test when a proper setup is available - see NODE-3060
0 commit comments