Skip to content

Commit 2b70d56

Browse files
committed
test: ensure proper error properties in tests
1 parent 8e43f11 commit 2b70d56

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

test/csfle-kms-providers.js renamed to test/csfle-kms-providers.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
import { type KMSProviders } from './mongodb';
22

33
const csfleKMSProviders = {
44
aws: {
@@ -22,7 +22,7 @@ const csfleKMSProviders = {
2222
}
2323
};
2424

25-
function getCSFLEKMSProviders() {
25+
export function getCSFLEKMSProviders(): KMSProviders {
2626
return JSON.parse(JSON.stringify(csfleKMSProviders));
2727
}
2828

@@ -37,10 +37,7 @@ const keys = [
3737
];
3838

3939
const isInEnvironment = key => typeof process.env[key] === 'string' && process.env[key].length > 0;
40-
const missingKeys = keys.filter(key => !isInEnvironment(key)).join(',');
4140

42-
module.exports = {
43-
getCSFLEKMSProviders,
44-
kmsCredentialsPresent: missingKeys === '',
45-
missingKeys
46-
};
41+
export const missingKeys = keys.filter(key => !isInEnvironment(key)).join(',');
42+
43+
export const kmsCredentialsPresent = missingKeys === '';

test/integration/client-side-encryption/client_side_encryption.prose.10.kms_tls.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('10. KMS TLS Tests', function () {
2525

2626
clientEncryption = new ClientEncryption(client, {
2727
keyVaultNamespace,
28-
kmsProviders: getCSFLEKMSProviders(),
28+
kmsProviders: { aws: getCSFLEKMSProviders().aws },
2929
tlsOptions: {
3030
aws: {
3131
tlsCAFile: process.env.CSFLE_TLS_CA_FILE,
@@ -47,6 +47,8 @@ describe('10. KMS TLS Tests', function () {
4747
error => error
4848
);
4949

50+
expect(error).to.exist;
51+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
5052
expect(error.cause.message, error.stack).to.include('certificate has expired');
5153
});
5254

@@ -58,6 +60,8 @@ describe('10. KMS TLS Tests', function () {
5860
error => error
5961
);
6062

63+
expect(error).to.exist;
64+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
6165
expect(error.cause.message, error.stack).to.include('does not match certificate');
6266
});
6367
});

0 commit comments

Comments
 (0)