Skip to content

Commit 5bf954d

Browse files
committed
chore: metadata and range
1 parent b9f5b23 commit 5bf954d

File tree

1 file changed

+63
-44
lines changed

1 file changed

+63
-44
lines changed

test/integration/client-side-encryption/driver.test.ts

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ describe('Client Side Encryption Functional', function () {
415415
);
416416

417417
describe('CSOT on ClientEncryption', function () {
418+
const metadata: MongoDBMetadataUI = {
419+
requires: { clientSideEncryption: true, mongodb: '>=4.4' }
420+
};
418421
function makeBlockingFailFor(command: string, blockTimeMS: number) {
419422
beforeEach(async function () {
420423
const utilClient = this.configuration.newClient();
@@ -441,24 +444,26 @@ describe('Client Side Encryption Functional', function () {
441444
});
442445
}
443446

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+
};
459464
}
460465

461-
let client;
466+
let client: MongoClient;
462467
let clientEncryption: ClientEncryption;
463468

464469
beforeEach(async function () {
@@ -497,71 +502,85 @@ describe('Client Side Encryption Functional', function () {
497502
sinon.restore();
498503
});
499504

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 () => {
502509
await clientEncryption.rewrapManyDataKey({ _id: new UUID() }, { provider: 'local' });
503-
});
504-
});
510+
})
511+
);
505512
});
506513

507514
describe('deleteKey', function () {
508515
makeBlockingFailFor('delete', 2000);
509516

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 () => {
512521
await clientEncryption.deleteKey(new UUID());
513-
});
514-
});
522+
})
523+
);
515524
});
516525

517526
describe('getKey', function () {
518527
makeBlockingFailFor('find', 2000);
519528

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 () => {
522533
await clientEncryption.getKey(new UUID());
523-
});
524-
});
534+
})
535+
);
525536
});
526537

527538
describe('getKeys', function () {
528539
makeBlockingFailFor('find', 2000);
529540

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 () => {
532545
await clientEncryption.getKeys().toArray();
533-
});
534-
});
546+
})
547+
);
535548
});
536549

537550
describe('removeKeyAltName', function () {
538551
makeBlockingFailFor('findAndModify', 2000);
539552

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 () => {
542557
await clientEncryption.removeKeyAltName(new UUID(), 'blah');
543-
});
544-
});
558+
})
559+
);
545560
});
546561

547562
describe('addKeyAltName', function () {
548563
makeBlockingFailFor('findAndModify', 2000);
549564

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 () => {
552569
await clientEncryption.addKeyAltName(new UUID(), 'blah');
553-
});
554-
});
570+
})
571+
);
555572
});
556573

557574
describe('getKeyByAltName', function () {
558575
makeBlockingFailFor('find', 2000);
559576

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 () => {
562581
await clientEncryption.getKeyByAltName('blah');
563-
});
564-
});
582+
})
583+
);
565584
});
566585
});
567586
});

0 commit comments

Comments
 (0)