@@ -41,6 +41,7 @@ describe('Kerberos', function () {
41
41
return ;
42
42
}
43
43
let krb5Uri = process . env . MONGODB_URI ;
44
+ const parts = krb5Uri . split ( '@' , 2 ) ;
44
45
45
46
if ( ! process . env . KRB5_PRINCIPAL ) {
46
47
console . error ( 'skipping Kerberos tests, KRB5_PRINCIPAL environment variable is not defined' ) ;
@@ -52,7 +53,6 @@ describe('Kerberos', function () {
52
53
if ( process . env . LDAPTEST_PASSWORD == null ) {
53
54
throw new Error ( 'The env parameter LDAPTEST_PASSWORD must be set' ) ;
54
55
}
55
- const parts = krb5Uri . split ( '@' , 2 ) ;
56
56
krb5Uri = `${ parts [ 0 ] } :${ process . env . LDAPTEST_PASSWORD } @${ parts [ 1 ] } ` ;
57
57
}
58
58
@@ -65,6 +65,10 @@ describe('Kerberos', function () {
65
65
} ) ;
66
66
67
67
it ( 'validate that gssapiCanonicalizeHostName can be passed in' , function ( done ) {
68
+ if ( process . platform === 'darwin' ) {
69
+ this . test . skipReason = 'DNS does not resolve with proper CNAME record on evergreen MacOS' ;
70
+ this . skip ( ) ;
71
+ }
68
72
const client = new MongoClient (
69
73
`${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,gssapiCanonicalizeHostName:true&maxPoolSize=1`
70
74
) ;
@@ -76,6 +80,10 @@ describe('Kerberos', function () {
76
80
} ) ;
77
81
78
82
it ( 'validate that CANONICALIZE_HOST_NAME can be passed in' , function ( done ) {
83
+ if ( process . platform === 'darwin' ) {
84
+ this . test . skipReason = 'DNS does not resolve with proper CNAME record on evergreen MacOS' ;
85
+ this . skip ( ) ;
86
+ }
79
87
const client = new MongoClient (
80
88
`${ krb5Uri } &authMechanismProperties=SERVICE_NAME:mongodb,CANONICALIZE_HOST_NAME:true&maxPoolSize=1`
81
89
) ;
@@ -97,6 +105,42 @@ describe('Kerberos', function () {
97
105
} ) ;
98
106
} ) ;
99
107
108
+ context ( 'when passing SERVICE_HOST as an auth mech option' , function ( ) {
109
+ context ( 'when the SERVICE_HOST is invalid' , function ( ) {
110
+ const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
111
+ authMechanismProperties : {
112
+ SERVICE_HOST : 'example.com'
113
+ }
114
+ } ) ;
115
+
116
+ it ( 'fails to authenticate' , async function ( ) {
117
+ let expectedError ;
118
+ await client . connect ( ) . catch ( e => {
119
+ expectedError = e ;
120
+ } ) ;
121
+ if ( ! expectedError ) {
122
+ expect . fail ( 'Expected connect with invalid SERVICE_HOST to fail' ) ;
123
+ }
124
+ expect ( expectedError . message ) . to . match ( / G S S f a i l u r e | U N K N O W N _ S E R V E R / ) ;
125
+ } ) ;
126
+ } ) ;
127
+
128
+ context ( 'when the SERVICE_HOST is valid' , function ( ) {
129
+ const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
130
+ authMechanismProperties : {
131
+ SERVICE_HOST : 'ldaptest.10gen.cc'
132
+ }
133
+ } ) ;
134
+
135
+ it ( 'authenticates' , function ( done ) {
136
+ client . connect ( function ( err , client ) {
137
+ expect ( err ) . to . not . exist ;
138
+ verifyKerberosAuthentication ( client , done ) ;
139
+ } ) ;
140
+ } ) ;
141
+ } ) ;
142
+ } ) ;
143
+
100
144
describe ( 'should use the SERVICE_NAME property' , function ( ) {
101
145
it ( 'as an option handed to the MongoClient' , function ( done ) {
102
146
const client = new MongoClient ( `${ krb5Uri } &maxPoolSize=1` , {
0 commit comments