Skip to content

Commit 20a640b

Browse files
CSHARP-4153: Add FLE 2 API to AutoEncryptionOpts. (#793)
CSHARP-4160: Add FLE 2 test for compactStructuredEncryptionData. CSHARP-4157: Add FLE 2 API to ClientEncryptionOpts. CSHARp-4175: Ban comparisons to encrypted fields in collection validator and partialFilterExpression. Co-authored-by: Boris <[email protected]>
1 parent 826d8db commit 20a640b

File tree

84 files changed

+7967
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+7967
-341
lines changed

build.cake

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,37 @@ Task("TestCsfleWithMockedKms")
416416
);
417417
});
418418

419-
Task("TestCsfleWithMockedKmsnet472").IsDependentOn("TestCsfleWithMockedKms");
419+
Task("TestCsfleWithMockedKmsNet472").IsDependentOn("TestCsfleWithMockedKms");
420420
Task("TestCsfleWithMockedKmsNetStandard20").IsDependentOn("TestCsfleWithMockedKms");
421421
Task("TestCsfleWithMockedKmsNetStandard21").IsDependentOn("TestCsfleWithMockedKms");
422422

423+
Task("TestMongocryptd")
424+
.IsDependentOn("Build")
425+
.DoesForEach(
426+
items: GetFiles("./**/*.Tests.csproj"),
427+
action: (BuildConfig buildConfig, Path testProject) =>
428+
{
429+
var settings = new DotNetCoreTestSettings
430+
{
431+
NoBuild = true,
432+
NoRestore = true,
433+
Configuration = configuration,
434+
Loggers = CreateLoggers(),
435+
ArgumentCustomization = args => args.Append("-- RunConfiguration.TargetPlatform=x64"),
436+
Filter = "Category=\"CSFLE\"",
437+
Framework = buildConfig.Framework
438+
};
439+
440+
DotNetCoreTest(
441+
testProject.FullPath,
442+
settings
443+
);
444+
});
445+
446+
Task("TestMongocryptdNet472").IsDependentOn("TestMongocryptd");
447+
Task("TestMongocryptdNetStandard20").IsDependentOn("TestMongocryptd");
448+
Task("TestMongocryptdNetStandard21").IsDependentOn("TestMongocryptd");
449+
423450
Task("Docs")
424451
.IsDependentOn("ApiDocs")
425452
.IsDependentOn("RefDocs");

evergreen/evergreen.yml

Lines changed: 96 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ stepback: true
1313
command_type: system
1414

1515
# Protect ourself against rogue test case, or curl gone wild, that runs forever
16-
# 45 minutes: 20 minutes is a normal test run + up to 10 minutes for test setup + 15 minutes for longer macOS tests
17-
exec_timeout_secs: 2700
16+
# 60 minutes: 20 minutes is a normal test run + up to 10 minutes for test setup + 15 minutes for longer macOS tests + 15 minutes for longer macOS 1015 tests
17+
exec_timeout_secs: 3600
1818

1919
# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
2020
timeout:
@@ -292,6 +292,8 @@ functions:
292292
. ./evergreen/set-virtualenv.sh
293293
. ./evergreen/set-temp-fle-aws-creds.sh
294294
${PREPARE_SHELL}
295+
OS=${OS} \
296+
. ./evergreen/fetch-crypt_shared-library.sh
295297
OS=${OS} \
296298
evergreen/add-ca-certs.sh
297299
AUTH=${AUTH} \
@@ -339,6 +341,41 @@ functions:
339341
OS=${OS} \
340342
evergreen/cleanup-test-resources.sh
341343
344+
run-mongocryptd-tests:
345+
- command: shell.exec
346+
type: test
347+
params:
348+
working_dir: mongo-csharp-driver
349+
script: |
350+
set +x
351+
export FLE_AWS_ACCESS_KEY_ID=${FLE_AWS_ACCESS_KEY_ID}
352+
export FLE_AWS_SECRET_ACCESS_KEY=${FLE_AWS_SECRET_ACCESS_KEY}
353+
export FLE_AZURE_TENANT_ID=${FLE_AZURE_TENANT_ID}
354+
export FLE_AZURE_CLIENT_ID=${FLE_AZURE_CLIENT_ID}
355+
export FLE_AZURE_CLIENT_SECRET=${FLE_AZURE_CLIENT_SECRET}
356+
export FLE_GCP_EMAIL=${FLE_GCP_EMAIL}
357+
export FLE_GCP_PRIVATE_KEY=${FLE_GCP_PRIVATE_KEY}
358+
. ./evergreen/set-virtualenv.sh
359+
. ./evergreen/set-temp-fle-aws-creds.sh
360+
${PREPARE_SHELL}
361+
OS=${OS} \
362+
evergreen/add-ca-certs.sh
363+
AUTH=${AUTH} \
364+
SSL=${SSL} \
365+
MONGODB_URI="${MONGODB_URI}" \
366+
TOPOLOGY=${TOPOLOGY} \
367+
OS=${OS} \
368+
COMPRESSOR=${COMPRESSOR} \
369+
CLIENT_PEM=${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem \
370+
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
371+
TEST_MONGOCRYPTD="true" \
372+
TARGET="TestMongocryptd" \
373+
FRAMEWORK=${FRAMEWORK} \
374+
evergreen/run-tests.sh
375+
echo "Skipping certificate removal..."
376+
OS=${OS} \
377+
evergreen/cleanup-test-resources.sh
378+
342379
run-atlas-connectivity-tests:
343380
- command: shell.exec
344381
type: test
@@ -835,6 +872,27 @@ tasks:
835872
vars:
836873
FRAMEWORK: netstandard21
837874

875+
- name: test-mongocryptd-net472
876+
commands:
877+
- func: bootstrap-mongo-orchestration
878+
- func: run-mongocryptd-tests
879+
vars:
880+
FRAMEWORK: net472
881+
882+
- name: test-mongocryptd-netstandard20
883+
commands:
884+
- func: bootstrap-mongo-orchestration
885+
- func: run-mongocryptd-tests
886+
vars:
887+
FRAMEWORK: netstandard20
888+
889+
- name: test-mongocryptd-netstandard21
890+
commands:
891+
- func: bootstrap-mongo-orchestration
892+
- func: run-mongocryptd-tests
893+
vars:
894+
FRAMEWORK: netstandard21
895+
838896
- name: test-kms-tls-mocked-net472
839897
commands:
840898
- func: start-kms-mock-servers
@@ -1371,11 +1429,11 @@ axes:
13711429
variables:
13721430
OS: "ubuntu-1804"
13731431
run_on: ubuntu1804-test
1374-
- id: "macos-1014"
1375-
display_name: "macOS 10.14"
1432+
- id: "macos-1015"
1433+
display_name: "macOS 10.15"
13761434
variables:
1377-
OS: "macos-1014"
1378-
run_on: macos-1014
1435+
OS: "macos-1015"
1436+
run_on: macos-1015
13791437

13801438
- id: topology
13811439
display_name: Topology
@@ -1447,10 +1505,10 @@ buildvariants:
14471505
- ubuntu1804-test
14481506
tasks:
14491507
- name: compile
1450-
- name: macos1014-compile
1451-
display_name: "macOS 10.14 compile"
1508+
- name: macos1015-compile
1509+
display_name: "macOS 10.15 compile"
14521510
run_on:
1453-
- macos-1014
1511+
- macos-1015
14541512
tasks:
14551513
- name: compile
14561514

@@ -1499,7 +1557,7 @@ buildvariants:
14991557
- name: test-netstandard21
15001558

15011559
- matrix_name: "tests-snappy-compression-macOS"
1502-
matrix_spec: { compressor : "snappy", auth: "noauth", ssl: "nossl", version: ["5.0", "6.0", "rapid", "latest"], topology: "standalone", os: "macos-1014" }
1560+
matrix_spec: { compressor : "snappy", auth: "noauth", ssl: "nossl", version: ["5.0", "6.0", "rapid", "latest"], topology: "standalone", os: "macos-1015" }
15031561
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${os} "
15041562
tags: ["tests-variant"]
15051563
tasks:
@@ -1523,7 +1581,7 @@ buildvariants:
15231581
- name: test-netstandard21
15241582

15251583
- matrix_name: "tests-zstandard-compression-macOS"
1526-
matrix_spec: { compressor : "zstandard", auth: "noauth", ssl: "nossl", version: ["5.0", "6.0", "rapid", "latest"], topology: "standalone", os: "macos-1014" }
1584+
matrix_spec: { compressor : "zstandard", auth: "noauth", ssl: "nossl", version: ["5.0", "6.0", "rapid", "latest"], topology: "standalone", os: "macos-1015" }
15271585
display_name: "${version} ${compressor} ${topology} ${auth} ${ssl} ${os} "
15281586
tags: ["tests-variant"]
15291587
tasks:
@@ -1547,14 +1605,14 @@ buildvariants:
15471605
- name: test-netstandard21
15481606

15491607
- matrix_name: "secure-tests-macOS"
1550-
matrix_spec: { version: ["5.0", "6.0", "rapid", "latest"], topology: "replicaset", auth: "auth", ssl: "ssl", os: "macos-1014" }
1608+
matrix_spec: { version: ["5.0", "6.0", "rapid", "latest"], topology: "replicaset", auth: "auth", ssl: "ssl", os: "macos-1015" }
15511609
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
15521610
tags: ["tests-variant"]
15531611
tasks:
15541612
- name: test-netstandard21
15551613

15561614
- matrix_name: "unsecure-tests-macOS"
1557-
matrix_spec: { version: ["5.0", "6.0", "rapid", "latest"], topology: "replicaset", auth: "noauth", ssl: "nossl", os: "macos-1014" }
1615+
matrix_spec: { version: ["5.0", "6.0", "rapid", "latest"], topology: "replicaset", auth: "noauth", ssl: "nossl", os: "macos-1015" }
15581616
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
15591617
tags: ["tests-variant"]
15601618
tasks:
@@ -1661,21 +1719,42 @@ buildvariants:
16611719

16621720
- matrix_name: "csfle-with-mocked-kms-tests-windows"
16631721
matrix_spec: { os: "windows-64", ssl: "nossl", version: [ "5.0", "6.0", "rapid", "latest" ], topology: ["standalone"] }
1664-
display_name: "CSFLE Mocked KMS ${os}"
1722+
display_name: "CSFLE Mocked KMS ${version} ${os}"
16651723
tasks:
16661724
- name: test-kms-tls-mocked-net472
16671725
- name: test-kms-tls-mocked-netstandard20
16681726
- name: test-kms-tls-mocked-netstandard21
16691727

16701728
- matrix_name: "csfle-with-mocked-kms-tests-linux"
16711729
matrix_spec: { os: "ubuntu-1804", ssl: "nossl", version: [ "5.0", "6.0", "rapid", "latest" ], topology: ["standalone"] }
1672-
display_name: "CSFLE Mocked KMS ${os}"
1730+
display_name: "CSFLE Mocked KMS ${version} ${os}"
16731731
tasks:
16741732
- name: test-kms-tls-mocked-netstandard20
16751733
- name: test-kms-tls-mocked-netstandard21
16761734

16771735
- matrix_name: "csfle-with-mocked-kms-tests-macOS"
1678-
matrix_spec: { os: "macos-1014", ssl: "nossl", version: [ "5.0", "6.0", "rapid", "latest" ], topology: ["standalone"] }
1679-
display_name: "CSFLE Mocked KMS ${os}"
1736+
matrix_spec: { os: "macos-1015", ssl: "nossl", version: [ "5.0", "6.0", "rapid", "latest" ], topology: ["standalone"] }
1737+
display_name: "CSFLE Mocked KMS ${version} ${os}"
16801738
tasks:
16811739
- name: test-kms-tls-mocked-netstandard21
1740+
1741+
- matrix_name: "csfle1-windows"
1742+
matrix_spec: { os: "windows-64", ssl: "nossl", version: [ "4.2", "4.4", "5.0", "6.0", "latest" ], topology: ["replicaset"] }
1743+
display_name: "mongocryptd ${version} ${os}"
1744+
tasks:
1745+
- name: test-mongocryptd-net472
1746+
- name: test-mongocryptd-netstandard20
1747+
- name: test-mongocryptd-netstandard21
1748+
1749+
- matrix_name: "csfle1-linux"
1750+
matrix_spec: { os: "ubuntu-1804", ssl: "nossl", version: [ "4.2", "4.4", "5.0", "6.0", "latest" ], topology: ["replicaset"] }
1751+
display_name: "mongocryptd ${version} ${os}"
1752+
tasks:
1753+
- name: test-mongocryptd-netstandard20
1754+
- name: test-mongocryptd-netstandard21
1755+
1756+
- matrix_name: "csfle1-macOS"
1757+
matrix_spec: { os: "macos-1015", ssl: "nossl", version: [ "4.2", "4.4", "5.0", "6.0", "latest" ], topology: ["replicaset"] }
1758+
display_name: "mongocryptd ${version} ${os}"
1759+
tasks:
1760+
- name: test-mongocryptd-netstandard21
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Fetch csfle shared library.
4+
#
5+
# Environment variables used as input:
6+
# OS The current operating system
7+
# DRIVERS_TOOLS
8+
#
9+
# Environment variables produced as output:
10+
# MONGODB_CSFLE_PATH The MONGODB_CSFLE_PATH path
11+
12+
set -o xtrace # Write all commands first to stderr
13+
set -o errexit # Exit the script with an error if any of the commands fail
14+
15+
16+
PYTHON=$(OS=${OS} ${PROJECT_DIRECTORY}/evergreen/get-python-path.sh)
17+
$PYTHON -u ${DRIVERS_TOOLS}/.evergreen/mongodl.py --component crypt_shared --out ${DRIVERS_TOOLS}/evergreen/csfle --version 6.0.0-rc8
18+
19+
if [[ "$OS" =~ Windows|windows ]]; then
20+
export CRYPT_SHARED_LIB_PATH="${DRIVERS_TOOLS}/evergreen/csfle/bin/mongo_crypt_v1.dll"
21+
elif [[ "$OS" =~ Mac|mac ]]; then
22+
export CRYPT_SHARED_LIB_PATH="${DRIVERS_TOOLS}/evergreen/csfle/lib/mongo_crypt_v1.dylib"
23+
else
24+
export CRYPT_SHARED_LIB_PATH="${DRIVERS_TOOLS}/evergreen/csfle/lib/mongo_crypt_v1.so"
25+
fi
26+
27+
echo "crypt shared library path $CRYPT_SHARED_LIB_PATH"

evergreen/run-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ provision_compressor () {
6868
############################################
6969
# Main Program #
7070
############################################
71+
echo "CRYPT_SHARED_LIB_PATH:" $CRYPT_SHARED_LIB_PATH
72+
echo "TEST_MONGOCRYPTD:" $TEST_MONGOCRYPTD
7173
echo "Initial MongoDB URI:" $MONGODB_URI
7274
echo "Framework: " $FRAMEWORK
7375

src/MongoDB.Driver.Core/Core/Clusters/Cluster.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ protected virtual void Dispose(bool disposing)
187187
UpdateClusterDescription(newClusterDescription);
188188

189189
_rapidHeartbeatTimer.Dispose();
190+
_cryptClient?.Dispose();
190191
}
191192
}
192193

@@ -222,9 +223,9 @@ public virtual void Initialize()
222223
ThrowIfDisposed();
223224
if (_state.TryChange(State.Initial, State.Open))
224225
{
225-
if (_settings.KmsProviders != null || _settings.SchemaMap != null)
226+
if (_settings.CryptClientSettings != null)
226227
{
227-
_cryptClient = CryptClientCreator.CreateCryptClient(_settings.KmsProviders, _settings.SchemaMap);
228+
_cryptClient = CryptClientCreator.CreateCryptClient(_settings.CryptClientSettings);
228229
}
229230
}
230231
}

0 commit comments

Comments
 (0)