Skip to content

Commit 4121ec6

Browse files
authored
test(NODE-4251): sync csfle create spec tests (#3271)
1 parent 1cc2c4b commit 4121ec6

13 files changed

+1735
-11
lines changed

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ else
5656
source "$DRIVERS_TOOLS"/.evergreen/csfle/set-temp-creds.sh
5757
fi
5858

59-
npm install mongodb-client-encryption@">=2.2.0-alpha.0"
59+
npm install mongodb-client-encryption@">=2.2.0-alpha.2"
6060
npm install @mongodb-js/zstd
6161
npm install snappy
6262

src/cmap/connection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,6 @@ export class CryptoConnection extends Connection {
727727
callback(err, null);
728728
return;
729729
}
730-
731730
super.command(ns, encrypted, options, (err, response) => {
732731
if (err || response == null) {
733732
callback(err, response);

src/encrypter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export class Encrypter {
8383

8484
clonedOptions.minPoolSize = 0;
8585

86+
clonedOptions.promoteValues = false;
87+
clonedOptions.promoteLongs = false;
88+
8689
internalClient = new MongoClient(uri, clonedOptions);
8790
this[kInternalClient] = internalClient;
8891

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ const skippedMaxWireVersionTest = 'operation fails with maxWireVersion < 8';
6060
const SKIPPED_TESTS = new Set([
6161
...(isAuthEnabled
6262
? skippedAuthTests.concat(skippedMaxWireVersionTest)
63-
: [skippedMaxWireVersionTest]),
64-
// TODO(NODE-4288): Fix FLE 2 tests
65-
'default state collection names are applied',
66-
'drop removes all state collections',
67-
'CreateCollection from encryptedFields.',
68-
'DropCollection from encryptedFields',
69-
'DropCollection from remote encryptedFields'
63+
: [skippedMaxWireVersionTest])
7064
]);
7165

7266
describe('Client Side Encryption', function () {
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.1.10"
5+
}
6+
],
7+
"database_name": "default",
8+
"collection_name": "default",
9+
"data": [],
10+
"tests": [
11+
{
12+
"description": "create is OK",
13+
"clientOptions": {
14+
"autoEncryptOpts": {
15+
"kmsProviders": {
16+
"local": {
17+
"key": {
18+
"$binary": {
19+
"base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk",
20+
"subType": "00"
21+
}
22+
}
23+
}
24+
}
25+
}
26+
},
27+
"operations": [
28+
{
29+
"name": "dropCollection",
30+
"object": "database",
31+
"arguments": {
32+
"collection": "unencryptedCollection"
33+
}
34+
},
35+
{
36+
"name": "createCollection",
37+
"object": "database",
38+
"arguments": {
39+
"collection": "unencryptedCollection",
40+
"validator": {
41+
"unencrypted_string": "foo"
42+
}
43+
}
44+
},
45+
{
46+
"name": "assertCollectionExists",
47+
"object": "testRunner",
48+
"arguments": {
49+
"database": "default",
50+
"collection": "unencryptedCollection"
51+
}
52+
}
53+
]
54+
},
55+
{
56+
"description": "createIndexes is OK",
57+
"clientOptions": {
58+
"autoEncryptOpts": {
59+
"kmsProviders": {
60+
"local": {
61+
"key": {
62+
"$binary": {
63+
"base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk",
64+
"subType": "00"
65+
}
66+
}
67+
}
68+
}
69+
}
70+
},
71+
"operations": [
72+
{
73+
"name": "dropCollection",
74+
"object": "database",
75+
"arguments": {
76+
"collection": "unencryptedCollection"
77+
}
78+
},
79+
{
80+
"name": "createCollection",
81+
"object": "database",
82+
"arguments": {
83+
"collection": "unencryptedCollection"
84+
}
85+
},
86+
{
87+
"name": "runCommand",
88+
"object": "database",
89+
"arguments": {
90+
"command": {
91+
"createIndexes": "unencryptedCollection",
92+
"indexes": [
93+
{
94+
"name": "name",
95+
"key": {
96+
"name": 1
97+
}
98+
}
99+
]
100+
}
101+
}
102+
},
103+
{
104+
"name": "assertIndexExists",
105+
"object": "testRunner",
106+
"arguments": {
107+
"database": "default",
108+
"collection": "unencryptedCollection",
109+
"index": "name"
110+
}
111+
}
112+
]
113+
}
114+
]
115+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
runOn:
2+
- minServerVersion: "4.1.10"
3+
database_name: &database_name "default"
4+
collection_name: &collection_name "default"
5+
6+
data: []
7+
tests:
8+
- description: "create is OK"
9+
clientOptions:
10+
autoEncryptOpts:
11+
kmsProviders:
12+
local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
13+
operations:
14+
# Drop to remove a collection that may exist from previous test runs.
15+
- name: dropCollection
16+
object: database
17+
arguments:
18+
collection: "unencryptedCollection"
19+
- name: createCollection
20+
object: database
21+
arguments:
22+
collection: "unencryptedCollection"
23+
validator:
24+
unencrypted_string: "foo"
25+
- name: assertCollectionExists
26+
object: testRunner
27+
arguments:
28+
database: *database_name
29+
collection: "unencryptedCollection"
30+
- description: "createIndexes is OK"
31+
clientOptions:
32+
autoEncryptOpts:
33+
kmsProviders:
34+
local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
35+
operations:
36+
# Drop to remove a collection that may exist from previous test runs.
37+
- name: dropCollection
38+
object: database
39+
arguments:
40+
collection: "unencryptedCollection"
41+
- name: createCollection
42+
object: database
43+
arguments:
44+
collection: "unencryptedCollection"
45+
- name: runCommand
46+
object: database
47+
arguments:
48+
command:
49+
createIndexes: "unencryptedCollection"
50+
indexes:
51+
- name: "name"
52+
key: { name: 1 }
53+
- name: assertIndexExists
54+
object: testRunner
55+
arguments:
56+
database: *database_name
57+
collection: "unencryptedCollection"
58+
index: name

test/spec/client-side-encryption/tests/fle2-CreateCollection.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,18 @@
14691469
"database_name": "default"
14701470
}
14711471
},
1472+
{
1473+
"command_started_event": {
1474+
"command": {
1475+
"listCollections": 1,
1476+
"filter": {
1477+
"name": "encryptedCollection"
1478+
}
1479+
},
1480+
"command_name": "listCollections",
1481+
"database_name": "default"
1482+
}
1483+
},
14721484
{
14731485
"command_started_event": {
14741486
"command": {
@@ -1829,6 +1841,18 @@
18291841
"database_name": "default"
18301842
}
18311843
},
1844+
{
1845+
"command_started_event": {
1846+
"command": {
1847+
"listCollections": 1,
1848+
"filter": {
1849+
"name": "encryptedCollection"
1850+
}
1851+
},
1852+
"command_name": "listCollections",
1853+
"database_name": "default"
1854+
}
1855+
},
18321856
{
18331857
"command_started_event": {
18341858
"command": {
@@ -2132,6 +2156,18 @@
21322156
"database_name": "default"
21332157
}
21342158
},
2159+
{
2160+
"command_started_event": {
2161+
"command": {
2162+
"listCollections": 1,
2163+
"filter": {
2164+
"name": "encryptedCollection"
2165+
}
2166+
},
2167+
"command_name": "listCollections",
2168+
"database_name": "default"
2169+
}
2170+
},
21352171
{
21362172
"command_started_event": {
21372173
"command": {

test/spec/client-side-encryption/tests/fle2-CreateCollection.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# This test requires libmongocrypt 1.5.0-alpha2.
12
runOn:
23
- minServerVersion: "6.0.0"
34
# FLE 2 Encrypted collections are not supported on standalone.
@@ -821,6 +822,13 @@ tests:
821822
encryptedFields: *encrypted_fields5
822823
command_name: create
823824
database_name: *database_name
825+
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
826+
- command_started_event:
827+
command:
828+
listCollections: 1
829+
filter: { name: "encryptedCollection" }
830+
command_name: listCollections
831+
database_name: *database_name
824832
# Index on __safeContents__ is then created.
825833
- command_started_event:
826834
command:
@@ -1028,6 +1036,13 @@ tests:
10281036
encryptedFields: *encrypted_fields6
10291037
command_name: create
10301038
database_name: *database_name
1039+
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
1040+
- command_started_event:
1041+
command:
1042+
listCollections: 1
1043+
filter: { name: "encryptedCollection" }
1044+
command_name: listCollections
1045+
database_name: *database_name
10311046
# Index on __safeContents__ is then created.
10321047
- command_started_event:
10331048
command:
@@ -1201,6 +1216,13 @@ tests:
12011216
encryptedFields: *encrypted_fields7
12021217
command_name: create
12031218
database_name: *database_name
1219+
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
1220+
- command_started_event:
1221+
command:
1222+
listCollections: 1
1223+
filter: { name: "encryptedCollection" }
1224+
command_name: listCollections
1225+
database_name: *database_name
12041226
# Index on __safeContents__ is then created.
12051227
- command_started_event:
12061228
command:

0 commit comments

Comments
 (0)