@@ -45,14 +45,16 @@ import {
4545 type TopologyOpeningEvent ,
4646 WriteConcern
4747} from '../../mongodb' ;
48- import { getEnvironmentalOptions } from '../../tools/utils' ;
48+ import { getEncryptExtraOptions , getEnvironmentalOptions } from '../../tools/utils' ;
4949import type { TestConfiguration } from '../runner/config' ;
5050import { EntityEventRegistry } from './entity_event_registry' ;
5151import { trace } from './runner' ;
5252import type { ClientEntity , EntityDescription , ExpectedLogMessage } from './schema' ;
5353import {
5454 createClientEncryption ,
55+ getCSFLETestDataFromEnvironment ,
5556 makeConnectionString ,
57+ mergeKMSProviders ,
5658 patchCollectionOptions ,
5759 patchDbOptions
5860} from './unified-utils' ;
@@ -236,6 +238,29 @@ export class UnifiedMongoClient extends MongoClient {
236238 config . setupLogging ?.( options , description . id ) ;
237239 }
238240
241+ if ( description . autoEncryptOpts ) {
242+ const { kmsProviders : kmsProvidersFromEnvironment } = getCSFLETestDataFromEnvironment (
243+ process . env
244+ ) ;
245+
246+ const extraOptions =
247+ getEncryptExtraOptions ( ) . cryptSharedLibPath != null
248+ ? {
249+ cryptSharedLibPath : getEncryptExtraOptions ( ) . cryptSharedLibPath ,
250+ ...description . autoEncryptOpts . extraOptions
251+ }
252+ : { } ;
253+
254+ options . autoEncryption = {
255+ ...description . autoEncryptOpts ,
256+ kmsProviders : mergeKMSProviders (
257+ description . autoEncryptOpts . kmsProviders ,
258+ kmsProvidersFromEnvironment
259+ ) ,
260+ extraOptions
261+ } ;
262+ }
263+
239264 super ( uri , options ) ;
240265 this . observedEventEmitter . on ( 'error' , ( ) => null ) ;
241266 this . logCollector = logCollector ;
0 commit comments