Skip to content
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
16 changes: 16 additions & 0 deletions tests/MongoDB.Driver.TestHelpers/Core/CoreTestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
using MongoDB.Driver.Core.Operations;
using MongoDB.Driver.Core.Servers;
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
using MongoDB.Driver.Encryption;
using MongoDB.Driver.TestHelpers;
using Xunit.Sdk;

namespace MongoDB.Driver
{
Expand Down Expand Up @@ -344,6 +347,19 @@ public static BsonDocument GetServerParameters()
}
}

public static bool ShouldSkipMongocryptdTests_SERVER_106469() =>
RequirePlatform.GetCurrentOperatingSystem() == SupportedOperatingSystem.Windows &&
ServerVersion >= new SemanticVersion(8, 1, 9999);

public static void SkipMongocryptdTests_SERVER_106469(bool checkForSharedLib = false)
{
if (ShouldSkipMongocryptdTests_SERVER_106469() &&
(!checkForSharedLib || GetCryptSharedLibPath() == null))
{
throw new SkipException("Test skipped because of SERVER-106469.");
}
}

internal static ICoreSessionHandle StartSession()
{
return StartSession(__cluster.Value);
Expand Down
24 changes: 20 additions & 4 deletions tests/MongoDB.Driver.Tests/Encryption/AutoEncryptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using MongoDB.Driver.Core.TestHelpers.Logging;
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
using MongoDB.Driver.Encryption;
using MongoDB.Driver.TestHelpers;
using MongoDB.Driver.Tests.Specifications.client_side_encryption;
using MongoDB.TestHelpers.XunitExtensions;
using Xunit;
Expand Down Expand Up @@ -87,13 +88,28 @@ public async Task Mongocryptd_should_be_initialized_when_auto_encryption([Values

var coll = client.GetDatabase(__collectionNamespace.DatabaseNamespace.DatabaseName).GetCollection<BsonDocument>(__collectionNamespace.CollectionName);

if (async)
try
{
await coll.InsertOneAsync(new BsonDocument());
if (async)
{
await coll.InsertOneAsync(new BsonDocument());
}
else
{
coll.InsertOne(new BsonDocument());
}
}
else
catch (Exception ex)
{
coll.InsertOne(new BsonDocument());
if (CoreTestConfiguration.ShouldSkipMongocryptdTests_SERVER_106469())
{
ex.Should().BeOfType<MongoEncryptionException>();
return;
}
else
{
throw;
}
}

mongocryptdClient.IsValueCreated.Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class ClientSideEncryptionTestRunner : MongoClientJsonDrivenTestRunnerBas
public ClientSideEncryptionTestRunner(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public ClientEncryptionProseTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
_cluster = CoreTestConfiguration.Cluster;

CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469(checkForSharedLib: true);
}

// public methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
Expand All @@ -27,6 +28,7 @@
using MongoDB.Driver.Core.TestHelpers.Logging;
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
using MongoDB.Driver.Encryption;
using MongoDB.Driver.TestHelpers;
using MongoDB.TestHelpers.XunitExtensions;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -63,15 +65,17 @@ public void Snapshot_and_causal_consistent_session_is_not_allowed()
public async Task Ensure_explicit_session_raises_error_if_connection_does_not_support_sessions([Values(true, false)] bool async)
{
RequireServer.Check().Supports(Feature.ClientSideEncryption);
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();

using var mongocryptdContext = GetMongocryptdContext();
using var session = mongocryptdContext.MongoClient.StartSession();

var exception = async ?
await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.FindAsync(session, FilterDefinition<BsonDocument>.Empty)) :
Record.Exception(() => mongocryptdContext.MongocryptdCollection.Find(session, FilterDefinition<BsonDocument>.Empty).ToList());
exception.Should().BeOfType<MongoClientException>().Subject.Message.Should().Be("Sessions are not supported.");


exception.Should().BeOfType<MongoClientException>().Subject.Message.Should().Be("Sessions are not supported.");
exception = async ?
await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.InsertOneAsync(session, new BsonDocument())) :
Record.Exception(() => mongocryptdContext.MongocryptdCollection.InsertOne(session, new BsonDocument()));
Expand All @@ -84,6 +88,7 @@ await Record.ExceptionAsync(() => mongocryptdContext.MongocryptdCollection.FindA
public async Task Ensure_implicit_session_is_ignored_if_connection_does_not_support_sessions([Values(true, false)] bool async)
{
RequireServer.Check().Supports(Feature.ClientSideEncryption);
CoreTestConfiguration.SkipMongocryptdTests_SERVER_106469();

using var mongocryptdContext = GetMongocryptdContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using MongoDB.Bson;
using MongoDB.Driver.Core.Configuration;
using MongoDB.Driver.Core.Misc;
using MongoDB.Driver.Encryption;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -112,6 +115,21 @@ public void Explicit_encryption_with_libmongocrypt_package_works()
var result = collection.Find(FilterDefinition<BsonDocument>.Empty).First();
_output.WriteLine(result.ToJson());
}
catch (Exception ex)
{
// SERVER-106469
#pragma warning disable CS0618 // Type or member is obsolete
var serverVersion = client.Cluster.Description.Servers[0].Version;
#pragma warning restore CS0618 // Type or member is obsolete
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
serverVersion >= new SemanticVersion(8, 1, 9999))
{
ex.Should().BeOfType<MongoEncryptionException>();
return;
}

throw;
}
finally
{
ClusterRegistry.Instance.UnregisterAndDisposeCluster(client.Cluster);
Expand Down