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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ConnectionDescription Authenticate(IConnection connection, ConnectionDesc
{
description = UpdateConnectionIdWithServerValue(description, connectionIdServerValue.Value);
}
else
else if (!description.HelloResult.IsMongocryptd) // mongocryptd doesn't provide ConnectionId
{
try
{
Expand Down Expand Up @@ -90,7 +90,7 @@ public async Task<ConnectionDescription> AuthenticateAsync(IConnection connectio
{
description = UpdateConnectionIdWithServerValue(description, connectionIdServerValue.Value);
}
else
else if (!description.HelloResult.IsMongocryptd) // mongocryptd doesn't provide ConnectionId
{
try
{
Expand Down
8 changes: 8 additions & 0 deletions src/MongoDB.Driver.Core/Core/Connections/HelloResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ public bool IsArbiter
get { return ServerType == ServerType.ReplicaSetArbiter; }
}

/// <summary>
/// Gets a value indicating whether this instance is a mongocryptd.
/// </summary>
/// <value>
/// <c>true</c> if this instance is a mongocryptd; otherwise, <c>false</c>.
/// </value>
public bool IsMongocryptd => _wrapped.TryGetValue("iscryptd", out var isCryptd) && isCryptd.IsBoolean ? isCryptd.ToBoolean() : false;

/// <summary>
/// Gets a value indicating whether this instance is a replica set member.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Net;
using FluentAssertions;
using MongoDB.Bson;
using MongoDB.Bson.TestHelpers.XunitExtensions;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.Compression;
using MongoDB.Driver.Core.Misc;
Expand Down Expand Up @@ -318,5 +319,19 @@ public void HelloOk_should_return_false_when_response_does_not_contain_helloOk()
var subject = new HelloResult(doc);
subject.HelloOk.Should().BeFalse();
}

[Theory]
[ParameterAttributeData]
public void IsMongocryptd_should_return_expected_result([Values(false, true, null)] bool? isMongocryptd)
{
var helloResultDocument = new BsonDocument
{
{ "iscryptd", () => isMongocryptd.Value, isMongocryptd.HasValue }
};

var subject = new HelloResult(helloResultDocument);

subject.IsMongocryptd.Should().Be(isMongocryptd.GetValueOrDefault());
}
}
}