@@ -6,7 +6,7 @@ import * as sinon from 'sinon';
66import { setTimeout } from 'timers/promises' ;
77
88import { connect } from '../../../src/cmap/connect' ;
9- import { Connection , SizedMessageTransform } from '../../../src/cmap/connection' ;
9+ import { Connection , CryptoConnection , SizedMessageTransform } from '../../../src/cmap/connection' ;
1010import { MongoNetworkTimeoutError , MongoRuntimeError } from '../../../src/error' ;
1111import { MongoClientAuthProviders } from '../../../src/mongo_client_auth_providers' ;
1212import { isHello , MongoDBCollectionNamespace , ns , promiseWithResolvers } from '../../../src/utils' ;
@@ -401,4 +401,18 @@ describe('new Connection()', function () {
401401 expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
402402 } ) ;
403403 } ) ;
404+
405+ it ( 'CryptoConnection.command() throws if no autoEncrypter is configured' , async function ( ) {
406+ const error = await connect ( {
407+ ...connectionOptionsDefaults ,
408+ hostAddress : server . hostAddress ( ) ,
409+ authProviders : new MongoClientAuthProviders ( ) ,
410+ connectionType : CryptoConnection ,
411+ extendedMetadata : Promise . resolve ( { } )
412+ } ) . catch ( e => e ) ;
413+
414+ expect ( error )
415+ . to . be . instanceOf ( MongoRuntimeError )
416+ . to . match ( / N o A u t o E n c r y p t e r a v a i l a b l e f o r e n c r y p t i o n / ) ;
417+ } ) ;
404418} ) ;
0 commit comments