Skip to content

Commit 19cf2ee

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

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { ClientEncryption, type MongoClient } from '../../mongodb';
55

66
const metadata: MongoDBMetadataUI = {
77
requires: {
8+
os: '!win32',
9+
topology: '!load-balanced',
810
mongodb: '>=4.2.0'
911
}
1012
};
@@ -25,7 +27,7 @@ describe('10. KMS TLS Tests', function () {
2527

2628
clientEncryption = new ClientEncryption(client, {
2729
keyVaultNamespace,
28-
kmsProviders: getCSFLEKMSProviders(),
30+
kmsProviders: { aws: getCSFLEKMSProviders().aws },
2931
tlsOptions: {
3032
aws: {
3133
tlsCAFile: process.env.CSFLE_TLS_CA_FILE,
@@ -47,6 +49,8 @@ describe('10. KMS TLS Tests', function () {
4749
error => error
4850
);
4951

52+
expect(error).to.exist;
53+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
5054
expect(error.cause.message, error.stack).to.include('certificate has expired');
5155
});
5256

@@ -58,6 +62,8 @@ describe('10. KMS TLS Tests', function () {
5862
error => error
5963
);
6064

65+
expect(error).to.exist;
66+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
6167
expect(error.cause.message, error.stack).to.include('does not match certificate');
6268
});
6369
});

0 commit comments

Comments
 (0)