11'use strict' ;
22
33const assert = require ( 'assert' ) ;
4- const EJSON = require ( 'bson' ) . EJSON ;
4+ const mdb = require ( 'mongodb' ) ;
55
66describe ( 'environmental variables' , ( ) => {
7- it ( 'MONGODB_URI is set' , async function ( ) {
8- const uri = process . env . MONGODB_URI ;
7+ it ( 'MONGODB_TEST_URI is set' , async function ( ) {
8+ const uri = process . env . MONGOOSE_TEST_URI ;
99 assert . ok ( uri ) ;
1010 } ) ;
1111
@@ -14,3 +14,32 @@ describe('environmental variables', () => {
1414 assert . ok ( shared_library_path ) ;
1515 } ) ;
1616} ) ;
17+
18+ describe ( 'basic integration' , ( ) => {
19+ it ( 'supports mongodb csfle auto-encryption integration' , async ( ) => {
20+ // 1. Create a MongoClient configured with auto encryption (referred to as `client_encrypted`)
21+ const client = new mdb . MongoClient (
22+ process . env . MONGOOSE_TEST_URI ,
23+ {
24+ autoEncryption : {
25+ keyVaultNamespace : 'keyvault.datakeys' ,
26+ kmsProviders : { local : { key : Buffer . from (
27+ 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk' ,
28+ 'base64'
29+ )
30+ } } ,
31+ extraOptions : {
32+ cryptdSharedLibRequired : true ,
33+ cryptSharedLibPath : process . env . CRYPT_SHARED_LIB_PATH
34+ }
35+ }
36+ }
37+ ) ;
38+ await client . connect ( ) ;
39+ const insertResult = await client
40+ . db ( 'db' )
41+ . collection ( 'coll' )
42+ . insertOne ( { unencrypted : 'test' } ) ;
43+ assert . ok ( insertResult . insertedId ) ;
44+ } ) ;
45+ } ) ;
0 commit comments