Skip to content

CSHARP-4319: FLE - maxWireVersion should run on Mongo Server 4.0.x. #878

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 3 commits into from
Sep 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,20 @@ private AutoEncryptionOptions ConfigureAutoEncryptionOptions(BsonDocument autoEn
case "bypassQueryAnalysis":
autoEncryptionOptions = autoEncryptionOptions.With(bypassQueryAnalysis: option.Value.ToBoolean());
break;

case "extraOptions":
foreach (var extraOption in option.Value.AsBsonDocument.Elements)
{
switch (extraOption.Name)
{
case "mongocryptdBypassSpawn":
extraOptions.Add(extraOption.Name, extraOption.Value.ToBoolean());
break;
default:
throw new Exception($"Unexpected extra option {extraOption.Name}.");
}
}
autoEncryptionOptions = autoEncryptionOptions.With(extraOptions: extraOptions);
break;
default:
throw new Exception($"Unexpected auto encryption option {option.Name}.");
}
Expand Down Expand Up @@ -330,11 +343,6 @@ private void ReplaceTypeAssertionWithActual(BsonArray actual, BsonArray expected
public class TestCaseFactory : JsonDrivenTestCaseFactory
{
#region static
private static readonly string[] __ignoredTestNames =
{
// https://jira.mongodb.org/browse/SPEC-1403
"maxWireVersion.json:operation fails with maxWireVersion < 8"
};
private static readonly string[] __versionedApiIgnoredTestNames =
{
// https://jira.mongodb.org/browse/SERVER-58293
Expand All @@ -348,7 +356,7 @@ public class TestCaseFactory : JsonDrivenTestCaseFactory
// protected methods
protected override IEnumerable<JsonDrivenTestCase> CreateTestCases(BsonDocument document)
{
var testCases = base.CreateTestCases(document).Where(test => !__ignoredTestNames.Any(ignoredName => test.Name.EndsWith(ignoredName)));
var testCases = base.CreateTestCases(document);
if (CoreTestConfiguration.RequireApiVersion)
{
testCases = testCases.Where(test => !__versionedApiIgnoredTestNames.Any(ignoredName => test.Name.EndsWith(ignoredName)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ string GetEnvironmentVariableOrDefaultOrThrowIfNothing(string variableName, stri

public static void ConfigureDefaultExtraOptions(Dictionary<string, object> extraOptions)
{
if (CoreTestConfiguration.MaxWireVersion < WireVersion.Server42)
{
// CSFLE is supported starting from server 4.2
return;
}

Ensure.IsNotNull(extraOptions, nameof(extraOptions));

if (!extraOptions.TryGetValue("mongocryptdSpawnPath", out object value))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"runOn": [
{
"maxServerVersion": "4.0"
"maxServerVersion": "4.0.99"
}
],
"database_name": "default",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runOn:
- maxServerVersion: "4.0"
- maxServerVersion: "4.0.99"
database_name: &database_name "default"
collection_name: &collection_name "default"

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