Skip to content

Commit a9b0672

Browse files
authored
Merge branch 'main' into NODE-6492-txn-prose
2 parents b74caff + 32b3e34 commit a9b0672

File tree

10 files changed

+192
-19
lines changed

10 files changed

+192
-19
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/change-streams/change_streams.prose.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ describe('Change Stream prose tests', function () {
992992
});
993993

994994
it('splits the event into multiple fragments', {
995-
metadata: { requires: { topology: '!single', mongodb: '>=7.0.0' } },
995+
metadata: { requires: { topology: '!single', mongodb: '>=6.0.9' } },
996996
test: async function () {
997997
// Insert into _C_ a document at least 10mb in size, e.g. { "value": "q"*10*1024*1024 }
998998
await collection.insertOne({ value: 'q'.repeat(10 * 1024 * 1024) });
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { expect } from 'chai';
2+
3+
import { getCSFLEKMSProviders } from '../../csfle-kms-providers';
4+
import { ClientEncryption, type MongoClient } from '../../mongodb';
5+
6+
const metadata: MongoDBMetadataUI = {
7+
requires: {
8+
clientSideEncryption: true,
9+
mongodb: '>=4.2.0'
10+
}
11+
};
12+
13+
describe('10. KMS TLS Tests', function () {
14+
const keyVaultNamespace = 'keyvault.datakeys';
15+
const masterKeyBase = {
16+
region: 'us-east-1',
17+
key: 'arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0'
18+
};
19+
20+
let client: MongoClient;
21+
let clientEncryption: ClientEncryption;
22+
23+
beforeEach(async function () {
24+
client = this.configuration.newClient();
25+
await client.connect();
26+
27+
clientEncryption = new ClientEncryption(client, {
28+
keyVaultNamespace,
29+
kmsProviders: { aws: getCSFLEKMSProviders().aws },
30+
tlsOptions: {
31+
aws: {
32+
tlsCAFile: process.env.CSFLE_TLS_CA_FILE,
33+
tlsCertificateKeyFile: process.env.CSFLE_TLS_CLIENT_CERT_FILE
34+
}
35+
}
36+
});
37+
});
38+
39+
afterEach(async function () {
40+
await client.close();
41+
});
42+
43+
it('should fail with an expired certificate', metadata, async function () {
44+
const masterKey = { ...masterKeyBase, endpoint: '127.0.0.1:9000' };
45+
46+
const error = await clientEncryption.createDataKey('aws', { masterKey }).then(
47+
() => null,
48+
error => error
49+
);
50+
51+
expect(error).to.exist;
52+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
53+
expect(error.cause.message, error.stack).to.include('certificate has expired');
54+
});
55+
56+
it('should fail with an invalid hostname', metadata, async function () {
57+
const masterKey = { ...masterKeyBase, endpoint: '127.0.0.1:9001' };
58+
59+
const error = await clientEncryption.createDataKey('aws', { masterKey }).then(
60+
() => null,
61+
error => error
62+
);
63+
64+
expect(error).to.exist;
65+
expect(error, error.stack).to.have.property('cause').that.is.instanceOf(Error);
66+
expect(error.cause.message, error.stack).to.include('does not match certificate');
67+
});
68+
});

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,11 +1351,6 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
13511351
});
13521352
});
13531353

1354-
// TODO(NODE-3151): Implement kms prose tests
1355-
describe('KMS TLS Tests', () => {
1356-
it.skip('TBD', () => {}).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
1357-
});
1358-
13591354
/**
13601355
* - Create client encryption no tls
13611356
* - Create client encryption with tls

test/spec/crud/unified/estimatedDocumentCount.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
"name": "estimatedDocumentCount",
250250
"object": "collection0",
251251
"expectError": {
252-
"isError": true
252+
"isClientError": true
253253
}
254254
}
255255
],

test/spec/crud/unified/estimatedDocumentCount.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ tests:
130130
- name: estimatedDocumentCount
131131
object: *collection0
132132
expectError:
133-
isError: true
133+
isClientError: true
134134
expectEvents:
135135
- client: *client0
136136
events:

test/spec/retryable-reads/unified/estimatedDocumentCount.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
"object": "collection1",
196196
"name": "estimatedDocumentCount",
197197
"expectError": {
198-
"isError": true
198+
"isClientError": true
199199
}
200200
}
201201
],
@@ -241,7 +241,7 @@
241241
"object": "collection0",
242242
"name": "estimatedDocumentCount",
243243
"expectError": {
244-
"isError": true
244+
"isClientError": true
245245
}
246246
}
247247
],

test/spec/retryable-reads/unified/estimatedDocumentCount.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ tests:
116116
object: *collection1
117117
name: estimatedDocumentCount
118118
expectError:
119-
isError: true
119+
isClientError: true
120120
expectEvents:
121121
-
122122
client: *client1
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"description": "expectedError-isClientError",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.0",
7+
"topologies": [
8+
"single",
9+
"replicaset"
10+
]
11+
},
12+
{
13+
"minServerVersion": "4.1.7",
14+
"topologies": [
15+
"sharded",
16+
"load-balanced"
17+
]
18+
}
19+
],
20+
"createEntities": [
21+
{
22+
"client": {
23+
"id": "client0",
24+
"useMultipleMongoses": false
25+
}
26+
},
27+
{
28+
"database": {
29+
"id": "database0",
30+
"client": "client0",
31+
"databaseName": "test"
32+
}
33+
}
34+
],
35+
"tests": [
36+
{
37+
"description": "isClientError considers network errors",
38+
"operations": [
39+
{
40+
"name": "failPoint",
41+
"object": "testRunner",
42+
"arguments": {
43+
"client": "client0",
44+
"failPoint": {
45+
"configureFailPoint": "failCommand",
46+
"mode": {
47+
"times": 1
48+
},
49+
"data": {
50+
"failCommands": [
51+
"ping"
52+
],
53+
"closeConnection": true
54+
}
55+
}
56+
}
57+
},
58+
{
59+
"name": "runCommand",
60+
"object": "database0",
61+
"arguments": {
62+
"commandName": "ping",
63+
"command": {
64+
"ping": 1
65+
}
66+
},
67+
"expectError": {
68+
"isClientError": true
69+
}
70+
}
71+
]
72+
}
73+
]
74+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
description: "expectedError-isClientError"
2+
3+
schemaVersion: "1.3"
4+
5+
runOnRequirements:
6+
- minServerVersion: "4.0"
7+
topologies: [single, replicaset]
8+
- minServerVersion: "4.1.7"
9+
topologies: [sharded, load-balanced]
10+
11+
createEntities:
12+
- client:
13+
id: &client0 client0
14+
useMultipleMongoses: false
15+
- database:
16+
id: &database0 database0
17+
client: *client0
18+
databaseName: &database0Name test
19+
20+
tests:
21+
- description: "isClientError considers network errors"
22+
operations:
23+
- name: failPoint
24+
object: testRunner
25+
arguments:
26+
client: *client0
27+
failPoint:
28+
configureFailPoint: failCommand
29+
mode: { times: 1 }
30+
data:
31+
failCommands: [ ping ]
32+
closeConnection: true
33+
- name: runCommand
34+
object: *database0
35+
arguments:
36+
commandName: ping
37+
command: { ping: 1 }
38+
expectError:
39+
isClientError: true

0 commit comments

Comments
 (0)