@@ -463,16 +463,10 @@ describe('ClientEncryption integration tests', function () {
463
463
let client : MongoClient ;
464
464
let clientEncryption : ClientEncryption ;
465
465
let collection : Collection < DataKey > ;
466
- // Data Key Stuff
467
- const AWS_ACCESS_KEY_ID = process . env . AWS_ACCESS_KEY_ID ;
468
- const AWS_SECRET_ACCESS_KEY = process . env . AWS_SECRET_ACCESS_KEY ;
469
- const AWS_REGION = 'us-east-1' ;
470
- const AWS_CMK_ID = 'dummy-cmk-id' ;
471
466
472
467
const kmsProviders = {
473
- aws : { accessKeyId : AWS_ACCESS_KEY_ID , secretAccessKey : AWS_SECRET_ACCESS_KEY }
468
+ local : { key : Buffer . alloc ( 96 ) }
474
469
} ;
475
- const dataKeyOptions = { masterKey : { key : AWS_CMK_ID , region : AWS_REGION } } ;
476
470
477
471
beforeEach ( function ( ) {
478
472
client = this . configuration . newClient ( ) ;
@@ -487,41 +481,32 @@ describe('ClientEncryption integration tests', function () {
487
481
await client ?. close ( ) ;
488
482
} ) ;
489
483
490
- function makeOptions ( keyAltNames ) {
491
- expect ( dataKeyOptions . masterKey ) . to . be . an ( 'object' ) ;
492
- expect ( dataKeyOptions . masterKey . key ) . to . be . a ( 'string' ) ;
493
- expect ( dataKeyOptions . masterKey . region ) . to . be . a ( 'string' ) ;
494
-
495
- return {
496
- masterKey : {
497
- key : dataKeyOptions . masterKey . key ,
498
- region : dataKeyOptions . masterKey . region
499
- } ,
500
- keyAltNames
501
- } ;
502
- }
503
-
504
484
describe ( 'errors' , function ( ) {
505
485
for ( const val of [ 42 , 'hello' , { keyAltNames : 'foobar' } , / f o o b a r / ] ) {
506
486
it ( `should fail if typeof keyAltNames = ${ typeof val } ` , metadata , async function ( ) {
507
- const options = makeOptions ( val ) ;
508
- const error = await clientEncryption . createDataKey ( 'aws' , options ) . catch ( error => error ) ;
487
+ const error = await clientEncryption . createDataKey ( 'local' , {
488
+ // @ts -expect-error Invalid type tests
489
+ keyAltNames : val
490
+ } ) . catch ( error => error ) ;
509
491
expect ( error ) . to . be . instanceOf ( MongoCryptInvalidArgumentError ) ;
510
492
} ) ;
511
493
}
512
494
513
495
for ( const val of [ undefined , null , 42 , { keyAltNames : 'foobar' } , [ 'foobar' ] , / f o o b a r / ] ) {
514
496
it ( `should fail if typeof keyAltNames[x] = ${ typeof val } ` , metadata , async function ( ) {
515
- const options = makeOptions ( [ val ] ) ;
516
- const error = await clientEncryption . createDataKey ( 'aws' , options ) . catch ( error => error ) ;
497
+ const error = await clientEncryption . createDataKey ( 'local' , {
498
+ // @ts -expect-error Invalid type tests
499
+ keyAltNames : [ val ]
500
+ } ) . catch ( error => error ) ;
517
501
expect ( error ) . to . be . instanceOf ( MongoCryptInvalidArgumentError ) ;
518
502
} ) ;
519
503
}
520
504
} ) ;
521
505
522
506
it ( 'should create a key with keyAltNames' , metadata , async function ( ) {
523
- const options = makeOptions ( [ 'foobar' ] ) ;
524
- const dataKey = await clientEncryption . createDataKey ( 'aws' , options ) ;
507
+ const dataKey = await clientEncryption . createDataKey ( 'local' , {
508
+ keyAltNames : [ 'foobar' ]
509
+ } ) ;
525
510
const document = await collection . findOne ( { keyAltNames : 'foobar' } ) ;
526
511
expect ( document ) . to . be . an ( 'object' ) ;
527
512
expect ( document ) . to . have . property ( 'keyAltNames' ) . that . includes . members ( [ 'foobar' ] ) ;
@@ -530,8 +515,10 @@ describe('ClientEncryption integration tests', function () {
530
515
531
516
it ( 'should create a key with multiple keyAltNames' , metadata , async function ( ) {
532
517
const dataKey = await clientEncryption . createDataKey (
533
- 'aws' ,
534
- makeOptions ( [ 'foobar' , 'fizzbuzz' ] )
518
+ 'local' ,
519
+ {
520
+ keyAltNames : [ 'foobar' , 'fizzbuzz' ]
521
+ }
535
522
) ;
536
523
const docs = await Promise . all ( [
537
524
collection . findOne ( { keyAltNames : 'foobar' } ) ,
@@ -557,7 +544,9 @@ describe('ClientEncryption integration tests', function () {
557
544
558
545
const valueToEncrypt = 'foobar' ;
559
546
560
- const keyId = await clientEncryption . createDataKey ( 'aws' , makeOptions ( [ keyAltName ] ) ) ;
547
+ const keyId = await clientEncryption . createDataKey ( 'local' , {
548
+ keyAltNames : [ keyAltName ]
549
+ } ) ;
561
550
const encryptedValue = await clientEncryption . encrypt ( valueToEncrypt , { keyId, algorithm } ) ;
562
551
const encryptedValue2 = await clientEncryption . encrypt ( valueToEncrypt , {
563
552
keyAltName,
0 commit comments