@@ -415,6 +415,9 @@ describe('Client Side Encryption Functional', function () {
415
415
) ;
416
416
417
417
describe ( 'CSOT on ClientEncryption' , function ( ) {
418
+ const metadata : MongoDBMetadataUI = {
419
+ requires : { clientSideEncryption : true , mongodb : '>=4.4' }
420
+ } ;
418
421
function makeBlockingFailFor ( command : string , blockTimeMS : number ) {
419
422
beforeEach ( async function ( ) {
420
423
const utilClient = this . configuration . newClient ( ) ;
@@ -441,24 +444,26 @@ describe('Client Side Encryption Functional', function () {
441
444
} ) ;
442
445
}
443
446
444
- async function expectCSOTTimeout ( fn : ( ) => Promise < void > ) {
445
- const start = performance . now ( ) ;
446
- const error = await fn ( ) . then (
447
- ( ) => null ,
448
- error => error
449
- ) ;
450
- const end = performance . now ( ) ;
451
- if ( error ?. name === 'MongoBulkWriteError' ) {
452
- expect ( error )
453
- . to . have . property ( 'errorResponse' )
454
- . that . is . instanceOf ( MongoOperationTimeoutError ) ;
455
- } else {
456
- expect ( error ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
457
- }
458
- expect ( end - start ) . to . be . within ( 500 , 1000 ) ;
447
+ function expectCSOTTimeout ( fn : ( ) => Promise < void > ) {
448
+ return async ( ) => {
449
+ const start = performance . now ( ) ;
450
+ const error = await fn ( ) . then (
451
+ ( ) => null ,
452
+ error => error
453
+ ) ;
454
+ const end = performance . now ( ) ;
455
+ if ( error ?. name === 'MongoBulkWriteError' ) {
456
+ expect ( error )
457
+ . to . have . property ( 'errorResponse' )
458
+ . that . is . instanceOf ( MongoOperationTimeoutError ) ;
459
+ } else {
460
+ expect ( error ) . to . be . instanceOf ( MongoOperationTimeoutError ) ;
461
+ }
462
+ expect ( end - start ) . to . be . within ( 498 , 1000 ) ;
463
+ } ;
459
464
}
460
465
461
- let client ;
466
+ let client : MongoClient ;
462
467
let clientEncryption : ClientEncryption ;
463
468
464
469
beforeEach ( async function ( ) {
@@ -497,71 +502,85 @@ describe('Client Side Encryption Functional', function () {
497
502
sinon . restore ( ) ;
498
503
} ) ;
499
504
500
- it ( 'throws a timeout error if the bulk operation takes too long' , async function ( ) {
501
- await expectCSOTTimeout ( async ( ) => {
505
+ it (
506
+ 'throws a timeout error if the bulk operation takes too long' ,
507
+ metadata ,
508
+ expectCSOTTimeout ( async ( ) => {
502
509
await clientEncryption . rewrapManyDataKey ( { _id : new UUID ( ) } , { provider : 'local' } ) ;
503
- } ) ;
504
- } ) ;
510
+ } )
511
+ ) ;
505
512
} ) ;
506
513
507
514
describe ( 'deleteKey' , function ( ) {
508
515
makeBlockingFailFor ( 'delete' , 2000 ) ;
509
516
510
- it ( 'throws a timeout error if the delete operation takes too long' , async function ( ) {
511
- await expectCSOTTimeout ( async ( ) => {
517
+ it (
518
+ 'throws a timeout error if the delete operation takes too long' ,
519
+ metadata ,
520
+ expectCSOTTimeout ( async ( ) => {
512
521
await clientEncryption . deleteKey ( new UUID ( ) ) ;
513
- } ) ;
514
- } ) ;
522
+ } )
523
+ ) ;
515
524
} ) ;
516
525
517
526
describe ( 'getKey' , function ( ) {
518
527
makeBlockingFailFor ( 'find' , 2000 ) ;
519
528
520
- it ( 'throws a timeout error if the bulk operation takes too long' , async function ( ) {
521
- await expectCSOTTimeout ( async ( ) => {
529
+ it (
530
+ 'throws a timeout error if the bulk operation takes too long' ,
531
+ metadata ,
532
+ expectCSOTTimeout ( async ( ) => {
522
533
await clientEncryption . getKey ( new UUID ( ) ) ;
523
- } ) ;
524
- } ) ;
534
+ } )
535
+ ) ;
525
536
} ) ;
526
537
527
538
describe ( 'getKeys' , function ( ) {
528
539
makeBlockingFailFor ( 'find' , 2000 ) ;
529
540
530
- it ( 'throws a timeout error if the find operation takes too long' , async function ( ) {
531
- await expectCSOTTimeout ( async ( ) => {
541
+ it (
542
+ 'throws a timeout error if the find operation takes too long' ,
543
+ metadata ,
544
+ expectCSOTTimeout ( async ( ) => {
532
545
await clientEncryption . getKeys ( ) . toArray ( ) ;
533
- } ) ;
534
- } ) ;
546
+ } )
547
+ ) ;
535
548
} ) ;
536
549
537
550
describe ( 'removeKeyAltName' , function ( ) {
538
551
makeBlockingFailFor ( 'findAndModify' , 2000 ) ;
539
552
540
- it ( 'throws a timeout error if the findAndModify operation takes too long' , async function ( ) {
541
- await expectCSOTTimeout ( async ( ) => {
553
+ it (
554
+ 'throws a timeout error if the findAndModify operation takes too long' ,
555
+ metadata ,
556
+ expectCSOTTimeout ( async ( ) => {
542
557
await clientEncryption . removeKeyAltName ( new UUID ( ) , 'blah' ) ;
543
- } ) ;
544
- } ) ;
558
+ } )
559
+ ) ;
545
560
} ) ;
546
561
547
562
describe ( 'addKeyAltName' , function ( ) {
548
563
makeBlockingFailFor ( 'findAndModify' , 2000 ) ;
549
564
550
- it ( 'throws a timeout error if the findAndModify operation takes too long' , async function ( ) {
551
- await expectCSOTTimeout ( async ( ) => {
565
+ it (
566
+ 'throws a timeout error if the findAndModify operation takes too long' ,
567
+ metadata ,
568
+ expectCSOTTimeout ( async ( ) => {
552
569
await clientEncryption . addKeyAltName ( new UUID ( ) , 'blah' ) ;
553
- } ) ;
554
- } ) ;
570
+ } )
571
+ ) ;
555
572
} ) ;
556
573
557
574
describe ( 'getKeyByAltName' , function ( ) {
558
575
makeBlockingFailFor ( 'find' , 2000 ) ;
559
576
560
- it ( 'throws a timeout error if the find operation takes too long' , async function ( ) {
561
- await expectCSOTTimeout ( async ( ) => {
577
+ it (
578
+ 'throws a timeout error if the find operation takes too long' ,
579
+ metadata ,
580
+ expectCSOTTimeout ( async ( ) => {
562
581
await clientEncryption . getKeyByAltName ( 'blah' ) ;
563
- } ) ;
564
- } ) ;
582
+ } )
583
+ ) ;
565
584
} ) ;
566
585
} ) ;
567
586
} ) ;
0 commit comments