@@ -28,6 +28,7 @@ describe('Kerberos', function () {
28
28
return ;
29
29
}
30
30
let krb5Uri = process . env . MONGODB_URI ;
31
+ const parts = krb5Uri . split ( '@' , 2 ) ;
31
32
32
33
if ( ! process . env . KRB5_PRINCIPAL ) {
33
34
console . error ( 'skipping Kerberos tests, KRB5_PRINCIPAL environment variable is not defined' ) ;
@@ -39,7 +40,6 @@ describe('Kerberos', function () {
39
40
if ( process . env . LDAPTEST_PASSWORD == null ) {
40
41
throw new Error ( 'The env parameter LDAPTEST_PASSWORD must be set' ) ;
41
42
}
42
- const parts = krb5Uri . split ( '@' , 2 ) ;
43
43
krb5Uri = `${ parts [ 0 ] } :${ process . env . LDAPTEST_PASSWORD } @${ parts [ 1 ] } ` ;
44
44
}
45
45
@@ -62,6 +62,37 @@ describe('Kerberos', function () {
62
62
} ) ;
63
63
} ) ;
64
64
65
+ context ( 'when passsing SERVICE_HOST' , function ( ) {
66
+ context ( 'when the SERVICE_HOST is invalid' , function ( ) {
67
+ const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
68
+ authMechanismProperties : {
69
+ SERVICE_HOST : 'example.com'
70
+ }
71
+ } ) ;
72
+
73
+ it ( 'fails to authenticate' , function ( ) {
74
+ return client . connect ( ) . catch ( e => {
75
+ expect ( e ) . to . exist ;
76
+ } ) ;
77
+ } ) ;
78
+ } ) ;
79
+
80
+ context ( 'when the SERVICE_HOST is valid' , function ( ) {
81
+ const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
82
+ authMechanismProperties : {
83
+ SERVICE_HOST : 'ldaptest.10gen.cc'
84
+ }
85
+ } ) ;
86
+
87
+ it ( 'authenticates' , function ( done ) {
88
+ client . connect ( function ( err , client ) {
89
+ expect ( err ) . to . not . exist ;
90
+ verifyKerberosAuthentication ( client , done ) ;
91
+ } ) ;
92
+ } ) ;
93
+ } ) ;
94
+ } ) ;
95
+
65
96
describe ( 'should use the SERVICE_NAME property' , function ( ) {
66
97
it ( 'as an option handed to the MongoClient' , function ( done ) {
67
98
const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
0 commit comments