@@ -3,6 +3,8 @@ const MongoClient = require('../..').MongoClient;
3
3
const chai = require ( 'chai' ) ;
4
4
const expect = chai . expect ;
5
5
6
+ const clientOptions = parseInt ( process . env . UNIFIED ) ? { useUnifiedTopology : true } : { } ;
7
+
6
8
describe ( 'Kerberos' , function ( ) {
7
9
if ( process . env . MONGODB_URI == null ) {
8
10
console . log ( 'skipping Kerberos tests, MONGODB_URI environment variable is not defined' ) ;
@@ -19,7 +21,7 @@ describe('Kerberos', function() {
19
21
}
20
22
21
23
it ( 'should authenticate with original uri' , function ( done ) {
22
- const client = new MongoClient ( krb5Uri ) ;
24
+ const client = new MongoClient ( krb5Uri , clientOptions ) ;
23
25
client . connect ( function ( err , client ) {
24
26
expect ( err ) . to . not . exist ;
25
27
client
@@ -37,7 +39,8 @@ describe('Kerberos', function() {
37
39
38
40
it ( 'validate that SERVICE_REALM and CANONICALIZE_HOST_NAME can be passed in' , function ( done ) {
39
41
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
41
44
) ;
42
45
client . connect ( function ( err , client ) {
43
46
expect ( err ) . to . not . exist ;
@@ -56,7 +59,8 @@ describe('Kerberos', function() {
56
59
57
60
it ( 'should authenticate with additional authentication properties' , function ( done ) {
58
61
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
60
64
) ;
61
65
client . connect ( function ( err , client ) {
62
66
expect ( err ) . to . not . exist ;
@@ -75,11 +79,13 @@ describe('Kerberos', function() {
75
79
76
80
it ( 'should fail to authenticate with bad credentials' , function ( done ) {
77
81
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
79
84
) ;
80
85
client . connect ( function ( err ) {
81
86
expect ( err ) . to . exist ;
82
87
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 ;
83
89
done ( ) ;
84
90
} ) ;
85
91
} ) ;
0 commit comments