@@ -3,6 +3,8 @@ const MongoClient = require('../..').MongoClient;
33const chai = require ( 'chai' ) ;
44const expect = chai . expect ;
55
6+ const clientOptions = parseInt ( process . env . UNIFIED ) ? { useUnifiedTopology : true } : { } ;
7+
68describe ( 'Kerberos' , function ( ) {
79 if ( process . env . MONGODB_URI == null ) {
810 console . log ( 'skipping Kerberos tests, MONGODB_URI environment variable is not defined' ) ;
@@ -19,7 +21,7 @@ describe('Kerberos', function() {
1921 }
2022
2123 it ( 'should authenticate with original uri' , function ( done ) {
22- const client = new MongoClient ( krb5Uri ) ;
24+ const client = new MongoClient ( krb5Uri , clientOptions ) ;
2325 client . connect ( function ( err , client ) {
2426 expect ( err ) . to . not . exist ;
2527 client
@@ -37,7 +39,8 @@ describe('Kerberos', function() {
3739
3840 it ( 'validate that SERVICE_REALM and CANONICALIZE_HOST_NAME can be passed in' , function ( done ) {
3941 const client = new MongoClient (
40- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false,SERVICE_REALM:windows&maxPoolSize=1`
42+ `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false,SERVICE_REALM:windows&maxPoolSize=1` ,
43+ clientOptions
4144 ) ;
4245 client . connect ( function ( err , client ) {
4346 expect ( err ) . to . not . exist ;
@@ -56,7 +59,8 @@ describe('Kerberos', function() {
5659
5760 it ( 'should authenticate with additional authentication properties' , function ( done ) {
5861 const client = new MongoClient (
59- `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false&maxPoolSize=1`
62+ `${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:false&maxPoolSize=1` ,
63+ clientOptions
6064 ) ;
6165 client . connect ( function ( err , client ) {
6266 expect ( err ) . to . not . exist ;
@@ -75,11 +79,13 @@ describe('Kerberos', function() {
7579
7680 it ( 'should fail to authenticate with bad credentials' , function ( done ) {
7781 const client = new MongoClient (
78- krb5Uri . replace ( encodeURIComponent ( process . env . KRB5_PRINCIPAL ) , 'bad%40creds.cc' )
82+ krb5Uri . replace ( encodeURIComponent ( process . env . KRB5_PRINCIPAL ) , 'bad%40creds.cc' ) ,
83+ clientOptions
7984 ) ;
8085 client . connect ( function ( err ) {
8186 expect ( err ) . to . exist ;
8287 expect ( err . message ) . to . match ( / A u t h e n t i c a t i o n f a i l e d / ) ;
88+ expect ( client . isConnected ( ) ) . to . be . false ;
8389 done ( ) ;
8490 } ) ;
8591 } ) ;
0 commit comments