Skip to content

Commit bf18fa9

Browse files
CSHARP-4319: FLE - maxWireVersion should run on Mongo Server 4.0.x. (#878)
1 parent 1343620 commit bf18fa9

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/ClientSideEncryptionTestRunner.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,20 @@ private AutoEncryptionOptions ConfigureAutoEncryptionOptions(BsonDocument autoEn
266266
case "bypassQueryAnalysis":
267267
autoEncryptionOptions = autoEncryptionOptions.With(bypassQueryAnalysis: option.Value.ToBoolean());
268268
break;
269-
269+
case "extraOptions":
270+
foreach (var extraOption in option.Value.AsBsonDocument.Elements)
271+
{
272+
switch (extraOption.Name)
273+
{
274+
case "mongocryptdBypassSpawn":
275+
extraOptions.Add(extraOption.Name, extraOption.Value.ToBoolean());
276+
break;
277+
default:
278+
throw new Exception($"Unexpected extra option {extraOption.Name}.");
279+
}
280+
}
281+
autoEncryptionOptions = autoEncryptionOptions.With(extraOptions: extraOptions);
282+
break;
270283
default:
271284
throw new Exception($"Unexpected auto encryption option {option.Name}.");
272285
}
@@ -330,11 +343,6 @@ private void ReplaceTypeAssertionWithActual(BsonArray actual, BsonArray expected
330343
public class TestCaseFactory : JsonDrivenTestCaseFactory
331344
{
332345
#region static
333-
private static readonly string[] __ignoredTestNames =
334-
{
335-
// https://jira.mongodb.org/browse/SPEC-1403
336-
"maxWireVersion.json:operation fails with maxWireVersion < 8"
337-
};
338346
private static readonly string[] __versionedApiIgnoredTestNames =
339347
{
340348
// https://jira.mongodb.org/browse/SERVER-58293
@@ -348,7 +356,7 @@ public class TestCaseFactory : JsonDrivenTestCaseFactory
348356
// protected methods
349357
protected override IEnumerable<JsonDrivenTestCase> CreateTestCases(BsonDocument document)
350358
{
351-
var testCases = base.CreateTestCases(document).Where(test => !__ignoredTestNames.Any(ignoredName => test.Name.EndsWith(ignoredName)));
359+
var testCases = base.CreateTestCases(document);
352360
if (CoreTestConfiguration.RequireApiVersion)
353361
{
354362
testCases = testCases.Where(test => !__versionedApiIgnoredTestNames.Any(ignoredName => test.Name.EndsWith(ignoredName)));

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/EncryptionTestHelper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ string GetEnvironmentVariableOrDefaultOrThrowIfNothing(string variableName, stri
106106

107107
public static void ConfigureDefaultExtraOptions(Dictionary<string, object> extraOptions)
108108
{
109+
if (CoreTestConfiguration.MaxWireVersion < WireVersion.Server42)
110+
{
111+
// CSFLE is supported starting from server 4.2
112+
return;
113+
}
114+
109115
Ensure.IsNotNull(extraOptions, nameof(extraOptions));
110116

111117
if (!extraOptions.TryGetValue("mongocryptdSpawnPath", out object value))

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/tests/legacy/maxWireVersion.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"runOn": [
33
{
4-
"maxServerVersion": "4.0"
4+
"maxServerVersion": "4.0.99"
55
}
66
],
77
"database_name": "default",

tests/MongoDB.Driver.Tests/Specifications/client-side-encryption/tests/legacy/maxWireVersion.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
runOn:
2-
- maxServerVersion: "4.0"
2+
- maxServerVersion: "4.0.99"
33
database_name: &database_name "default"
44
collection_name: &collection_name "default"
55

@@ -19,4 +19,4 @@ tests:
1919
arguments:
2020
document: { encrypted_string: "string0" }
2121
result:
22-
errorContains: "Auto-encryption requires a minimum MongoDB version of 4.2"
22+
errorContains: "Auto-encryption requires a minimum MongoDB version of 4.2"

0 commit comments

Comments
 (0)