@@ -594,7 +594,7 @@ describe('MongoClient.close() Integration', () => {
594594 describe ( 'AutoEncrypter' , ( ) => {
595595 const metadata : MongoDBMetadataUI = {
596596 requires : {
597- os : 'linux ' ,
597+ os : '!win32 ' ,
598598 mongodb : '>=4.2.0' ,
599599 clientSideEncryption : true
600600 }
@@ -619,70 +619,21 @@ describe('MongoClient.close() Integration', () => {
619619
620620 const keyVaultClient = new MongoClient ( uri ) ;
621621 await keyVaultClient . connect ( ) ;
622- await keyVaultClient . db ( 'keyvault' ) . collection ( 'datakeys' ) ;
622+ await keyVaultClient . db ( 'keyvault' ) . createCollection ( 'datakeys' ) ;
623623
624624 const clientEncryption = new mongodb . ClientEncryption ( keyVaultClient , {
625625 keyVaultNamespace : 'keyvault.datakeys' ,
626- kmsProviders
626+ kmsProviders,
627+ tlsOptions : { aws : { tlsCAFile : infiniteFile } }
627628 } ) ;
628- const dataKey = await clientEncryption . createDataKey ( provider , { masterKey } ) ;
629-
630- function getEncryptExtraOptions ( ) {
631- if (
632- typeof process . env . CRYPT_SHARED_LIB_PATH === 'string' &&
633- process . env . CRYPT_SHARED_LIB_PATH . length > 0
634- ) {
635- return { cryptSharedLibPath : process . env . CRYPT_SHARED_LIB_PATH } ;
636- }
637- return { } ;
638- }
639- const schemaMap = {
640- 'db.coll' : {
641- bsonType : 'object' ,
642- encryptMetadata : {
643- keyId : [ dataKey ]
644- } ,
645- properties : {
646- a : {
647- encrypt : {
648- bsonType : 'int' ,
649- algorithm : 'AEAD_AES_256_CBC_HMAC_SHA_512-Random' ,
650- keyId : [ dataKey ]
651- }
652- }
653- }
654- }
655- } ;
656- const encryptionOptions = {
657- autoEncryption : {
658- keyVaultNamespace : 'keyvault.datakeys' ,
659- kmsProviders,
660- extraOptions : getEncryptExtraOptions ( ) ,
661- schemaMap,
662- tlsOptions : { aws : { tlsCAFile : infiniteFile } }
663- }
664- } ;
665-
666- const encryptedClient = new MongoClient ( uri , encryptionOptions ) ;
667- await encryptedClient . connect ( ) ;
668629
669630 expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
670-
671- const insertPromise = encryptedClient
672- . db ( 'db' )
673- . collection ( 'coll' )
674- . insertOne ( { a : 1 } ) ;
675-
631+ const dataKeyProm = clientEncryption . createDataKey ( provider , { masterKey } ) ;
676632 expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
677-
678633 await keyVaultClient . close ( ) ;
679- await encryptedClient . close ( ) ;
680-
681- expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
682-
683- const err = await insertPromise . catch ( e => e ) ;
684- expect ( err ) . to . exist ;
685- expect ( err . errmsg ) . to . contain ( 'Error in KMS response' ) ;
634+ const error = await dataKeyProm . catch ( error => error ) ;
635+ expect ( error . message ) . to . equal ( 'KMS request failed' ) ;
636+ expect ( error . cause . name ) . to . equal ( 'MongoClientClosedError' ) ;
686637 }
687638 ) ;
688639 } ) ;
0 commit comments