@@ -51,13 +51,11 @@ describe('TLS Support', function () {
51
51
expect ( client . options ) . property ( 'tlsCertificateKeyFile' , TLS_CERT_KEY_FILE ) ;
52
52
expect ( client . options ) . not . have . property ( 'ca' ) ;
53
53
expect ( client . options ) . not . have . property ( 'key' ) ;
54
- expect ( client . options ) . not . have . property ( 'cert' ) ;
55
54
56
55
await client . connect ( ) ;
57
56
58
57
expect ( client . options ) . property ( 'ca' ) . to . exist ;
59
58
expect ( client . options ) . property ( 'key' ) . to . exist ;
60
- expect ( client . options ) . property ( 'cert' ) . to . exist ;
61
59
} ) ;
62
60
63
61
context ( 'when client has been opened and closed more than once' , function ( ) {
@@ -108,6 +106,42 @@ describe('TLS Support', function () {
108
106
} ) ;
109
107
} ) ;
110
108
} ) ;
109
+
110
+ context ( 'when tlsCertificateKeyFile is provided, but tlsCAFile is missing' , ( ) => {
111
+ let client : MongoClient ;
112
+ beforeEach ( ( ) => {
113
+ client = new MongoClient ( CONNECTION_STRING , {
114
+ tls : true ,
115
+ tlsCertificateKeyFile : TLS_CERT_KEY_FILE
116
+ } ) ;
117
+ } ) ;
118
+ afterEach ( async ( ) => {
119
+ if ( client ) await client . close ( ) ;
120
+ } ) ;
121
+
122
+ it ( 'throws an error' , async ( ) => {
123
+ const err = await client . connect ( ) . catch ( e => e ) ;
124
+ expect ( err ) . to . be . instanceOf ( Error ) ;
125
+ } ) ;
126
+ } ) ;
127
+
128
+ context ( 'when tlsCAFile is provided, but tlsCertificateKeyFile is missing' , ( ) => {
129
+ let client : MongoClient ;
130
+ beforeEach ( ( ) => {
131
+ client = new MongoClient ( CONNECTION_STRING , {
132
+ tls : true ,
133
+ tlsCAFile : TLS_CA_FILE
134
+ } ) ;
135
+ } ) ;
136
+ afterEach ( async ( ) => {
137
+ if ( client ) await client . close ( ) ;
138
+ } ) ;
139
+
140
+ it ( 'throws an error' , async ( ) => {
141
+ const err = await client . connect ( ) . catch ( e => e ) ;
142
+ expect ( err ) . to . be . instanceOf ( Error ) ;
143
+ } ) ;
144
+ } ) ;
111
145
} ) ;
112
146
113
147
function makeConnectionTest ( connectionString : string , clientOptions ?: MongoClientOptions ) {
0 commit comments