Skip to content

test(NODE-4251): sync csfle create spec tests #3271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ else
source "$DRIVERS_TOOLS"/.evergreen/csfle/set-temp-creds.sh
fi

npm install mongodb-client-encryption@">=2.2.0-alpha.0"
npm install mongodb-client-encryption@">=2.2.0-alpha.2"
npm install @mongodb-js/zstd
npm install snappy

Expand Down
1 change: 0 additions & 1 deletion src/cmap/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ export class CryptoConnection extends Connection {
callback(err, null);
return;
}

super.command(ns, encrypted, options, (err, response) => {
if (err || response == null) {
callback(err, response);
Expand Down
3 changes: 3 additions & 0 deletions src/encrypter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export class Encrypter {

clonedOptions.minPoolSize = 0;

clonedOptions.promoteValues = false;
clonedOptions.promoteLongs = false;

internalClient = new MongoClient(uri, clonedOptions);
this[kInternalClient] = internalClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,7 @@ const skippedMaxWireVersionTest = 'operation fails with maxWireVersion < 8';
const SKIPPED_TESTS = new Set([
...(isAuthEnabled
? skippedAuthTests.concat(skippedMaxWireVersionTest)
: [skippedMaxWireVersionTest]),
// TODO(NODE-4288): Fix FLE 2 tests
'default state collection names are applied',
'drop removes all state collections',
'CreateCollection from encryptedFields.',
'DropCollection from encryptedFields',
'DropCollection from remote encryptedFields'
: [skippedMaxWireVersionTest])
]);

describe('Client Side Encryption', function () {
Expand Down
115 changes: 115 additions & 0 deletions test/spec/client-side-encryption/tests/create-and-createIndexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"runOn": [
{
"minServerVersion": "4.1.10"
}
],
"database_name": "default",
"collection_name": "default",
"data": [],
"tests": [
{
"description": "create is OK",
"clientOptions": {
"autoEncryptOpts": {
"kmsProviders": {
"local": {
"key": {
"$binary": {
"base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk",
"subType": "00"
}
}
}
}
}
},
"operations": [
{
"name": "dropCollection",
"object": "database",
"arguments": {
"collection": "unencryptedCollection"
}
},
{
"name": "createCollection",
"object": "database",
"arguments": {
"collection": "unencryptedCollection",
"validator": {
"unencrypted_string": "foo"
}
}
},
{
"name": "assertCollectionExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "unencryptedCollection"
}
}
]
},
{
"description": "createIndexes is OK",
"clientOptions": {
"autoEncryptOpts": {
"kmsProviders": {
"local": {
"key": {
"$binary": {
"base64": "Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk",
"subType": "00"
}
}
}
}
}
},
"operations": [
{
"name": "dropCollection",
"object": "database",
"arguments": {
"collection": "unencryptedCollection"
}
},
{
"name": "createCollection",
"object": "database",
"arguments": {
"collection": "unencryptedCollection"
}
},
{
"name": "runCommand",
"object": "database",
"arguments": {
"command": {
"createIndexes": "unencryptedCollection",
"indexes": [
{
"name": "name",
"key": {
"name": 1
}
}
]
}
}
},
{
"name": "assertIndexExists",
"object": "testRunner",
"arguments": {
"database": "default",
"collection": "unencryptedCollection",
"index": "name"
}
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
runOn:
- minServerVersion: "4.1.10"
database_name: &database_name "default"
collection_name: &collection_name "default"

data: []
tests:
- description: "create is OK"
clientOptions:
autoEncryptOpts:
kmsProviders:
local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
operations:
# Drop to remove a collection that may exist from previous test runs.
- name: dropCollection
object: database
arguments:
collection: "unencryptedCollection"
- name: createCollection
object: database
arguments:
collection: "unencryptedCollection"
validator:
unencrypted_string: "foo"
- name: assertCollectionExists
object: testRunner
arguments:
database: *database_name
collection: "unencryptedCollection"
- description: "createIndexes is OK"
clientOptions:
autoEncryptOpts:
kmsProviders:
local: {'key': {'$binary': {'base64': 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk', 'subType': '00'}}}
operations:
# Drop to remove a collection that may exist from previous test runs.
- name: dropCollection
object: database
arguments:
collection: "unencryptedCollection"
- name: createCollection
object: database
arguments:
collection: "unencryptedCollection"
- name: runCommand
object: database
arguments:
command:
createIndexes: "unencryptedCollection"
indexes:
- name: "name"
key: { name: 1 }
- name: assertIndexExists
object: testRunner
arguments:
database: *database_name
collection: "unencryptedCollection"
index: name
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,18 @@
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
"listCollections": 1,
"filter": {
"name": "encryptedCollection"
}
},
"command_name": "listCollections",
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
Expand Down Expand Up @@ -1829,6 +1841,18 @@
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
"listCollections": 1,
"filter": {
"name": "encryptedCollection"
}
},
"command_name": "listCollections",
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
Expand Down Expand Up @@ -2132,6 +2156,18 @@
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
"listCollections": 1,
"filter": {
"name": "encryptedCollection"
}
},
"command_name": "listCollections",
"database_name": "default"
}
},
{
"command_started_event": {
"command": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This test requires libmongocrypt 1.5.0-alpha2.
runOn:
- minServerVersion: "6.0.0"
# FLE 2 Encrypted collections are not supported on standalone.
Expand Down Expand Up @@ -821,6 +822,13 @@ tests:
encryptedFields: *encrypted_fields5
command_name: create
database_name: *database_name
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
- command_started_event:
command:
listCollections: 1
filter: { name: "encryptedCollection" }
command_name: listCollections
database_name: *database_name
# Index on __safeContents__ is then created.
- command_started_event:
command:
Expand Down Expand Up @@ -1028,6 +1036,13 @@ tests:
encryptedFields: *encrypted_fields6
command_name: create
database_name: *database_name
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
- command_started_event:
command:
listCollections: 1
filter: { name: "encryptedCollection" }
command_name: listCollections
database_name: *database_name
# Index on __safeContents__ is then created.
- command_started_event:
command:
Expand Down Expand Up @@ -1201,6 +1216,13 @@ tests:
encryptedFields: *encrypted_fields7
command_name: create
database_name: *database_name
# libmongocrypt requests listCollections to get a schema for the "createIndexes" command.
- command_started_event:
command:
listCollections: 1
filter: { name: "encryptedCollection" }
command_name: listCollections
database_name: *database_name
# Index on __safeContents__ is then created.
- command_started_event:
command:
Expand Down
Loading