Skip to content

Commit 89f8f20

Browse files
authored
CSHARP-3660: Updated server error codes and internal/private variables/fields/methods to use modern terminology. (#534)
1 parent cf62d15 commit 89f8f20

File tree

52 files changed

+321
-363
lines changed

Some content is hidden

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

52 files changed

+321
-363
lines changed

src/MongoDB.Driver.Core/Core/Authentication/DefaultAuthenticator.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ namespace MongoDB.Driver.Core.Authentication
2525
{
2626
/// <summary>
2727
/// The default authenticator.
28-
/// If saslSupportedMechs is not present in the isMaster results for mechanism negotiation
28+
/// If saslSupportedMechs is not present in the hello or legacy hello results for mechanism negotiation
2929
/// uses SCRAM-SHA-1 when talking to servers >= 3.0. Prior to server 3.0, uses MONGODB-CR.
30-
/// Else, uses SCRAM-SHA-256 if present in the list of mechanisms. Otherwise, uses
30+
/// Else, uses SCRAM-SHA-256 if present in the list of mechanisms. Otherwise, uses
3131
/// SCRAM-SHA-1 the default, regardless of whether SCRAM-SHA-1 is in the list.
3232
/// </summary>
3333
public class DefaultAuthenticator : IAuthenticator
@@ -82,18 +82,18 @@ public void Authenticate(IConnection connection, ConnectionDescription descripti
8282
Ensure.IsNotNull(description, nameof(description));
8383

8484
// If we don't have SaslSupportedMechs as part of the response, that means we didn't piggyback the initial
85-
// isMaster request and should query the server (provided that the server >= 4.0), merging results into
85+
// hello or legacy hello request and should query the server (provided that the server >= 4.0), merging results into
8686
// a new ConnectionDescription
8787
if (!description.IsMasterResult.HasSaslSupportedMechs
8888
&& Feature.ScramSha256Authentication.IsSupported(description.ServerVersion))
8989
{
90-
var command = CustomizeInitialIsMasterCommand(IsMasterHelper.CreateCommand());
91-
var isMasterProtocol = IsMasterHelper.CreateProtocol(command, _serverApi);
92-
var isMasterResult = IsMasterHelper.GetResult(connection, isMasterProtocol, cancellationToken);
93-
var mergedIsMasterResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(isMasterResult.Wrapped));
90+
var command = CustomizeInitialIsMasterCommand(HelloHelper.CreateCommand());
91+
var helloProtocol = HelloHelper.CreateProtocol(command, _serverApi);
92+
var helloResult = HelloHelper.GetResult(connection, helloProtocol, cancellationToken);
93+
var mergedHelloResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(helloResult.Wrapped));
9494
description = new ConnectionDescription(
9595
description.ConnectionId,
96-
mergedIsMasterResult,
96+
mergedHelloResult,
9797
description.BuildInfoResult);
9898
}
9999

@@ -108,18 +108,18 @@ public async Task AuthenticateAsync(IConnection connection, ConnectionDescriptio
108108
Ensure.IsNotNull(description, nameof(description));
109109

110110
// If we don't have SaslSupportedMechs as part of the response, that means we didn't piggyback the initial
111-
// isMaster request and should query the server (provided that the server >= 4.0), merging results into
111+
// hello or legacy hello request and should query the server (provided that the server >= 4.0), merging results into
112112
// a new ConnectionDescription
113113
if (!description.IsMasterResult.HasSaslSupportedMechs
114114
&& Feature.ScramSha256Authentication.IsSupported(description.ServerVersion))
115115
{
116-
var command = CustomizeInitialIsMasterCommand(IsMasterHelper.CreateCommand());
117-
var isMasterProtocol = IsMasterHelper.CreateProtocol(command, _serverApi);
118-
var isMasterResult = await IsMasterHelper.GetResultAsync(connection, isMasterProtocol, cancellationToken).ConfigureAwait(false);
119-
var mergedIsMasterResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(isMasterResult.Wrapped));
116+
var command = CustomizeInitialIsMasterCommand(HelloHelper.CreateCommand());
117+
var helloProtocol = HelloHelper.CreateProtocol(command, _serverApi);
118+
var helloResult = await HelloHelper.GetResultAsync(connection, helloProtocol, cancellationToken).ConfigureAwait(false);
119+
var mergedHelloResult = new IsMasterResult(description.IsMasterResult.Wrapped.Merge(helloResult.Wrapped));
120120
description = new ConnectionDescription(
121121
description.ConnectionId,
122-
mergedIsMasterResult,
122+
mergedHelloResult,
123123
description.BuildInfoResult);
124124
}
125125

@@ -144,7 +144,7 @@ private static BsonDocument CreateSaslSupportedMechsRequest(string authenticatio
144144
// see https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst#defaults
145145
private IAuthenticator CreateAuthenticator(IConnection connection, ConnectionDescription description)
146146
{
147-
// If a saslSupportedMechs field was present in the isMaster results for mechanism negotiation,
147+
// If a saslSupportedMechs field was present in the hello or legacy hello results for mechanism negotiation,
148148
// then it MUST be inspected to select a default mechanism.
149149
if (description.IsMasterResult.HasSaslSupportedMechs)
150150
{
@@ -154,7 +154,7 @@ private IAuthenticator CreateAuthenticator(IConnection connection, ConnectionDes
154154
? (IAuthenticator)new ScramSha256Authenticator(_credential, _randomStringGenerator, _serverApi)
155155
: new ScramSha1Authenticator(_credential, _randomStringGenerator, _serverApi);
156156
}
157-
// If saslSupportedMechs is not present in the isMaster results for mechanism negotiation, then SCRAM-SHA-1
157+
// If saslSupportedMechs is not present in the hello or legacy hello results for mechanism negotiation, then SCRAM-SHA-1
158158
// MUST be used when talking to servers >= 3.0. Prior to server 3.0, MONGODB-CR MUST be used.
159159
#pragma warning disable 618
160160
return Feature.ScramSha1Authentication.IsSupported(description.ServerVersion)
@@ -165,7 +165,7 @@ private IAuthenticator CreateAuthenticator(IConnection connection, ConnectionDes
165165

166166
private IAuthenticator GetOrCreateAuthenticator(IConnection connection, ConnectionDescription description)
167167
{
168-
/* It is possible to have for IsMaster["SpeculativeAuthenticate"] != null and for
168+
/* It is possible to have Hello["SpeculativeAuthenticate"] != null and for
169169
* _speculativeScramSha256Authenticator to be null in the case of multiple authenticators */
170170
var speculativeAuthenticateResult = description.IsMasterResult.SpeculativeAuthenticate;
171171
var canUseSpeculativeAuthenticator = _speculativeAuthenticator != null && speculativeAuthenticateResult != null;

src/MongoDB.Driver.Core/Core/Authentication/MongoDBCRAuthenticator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private CommandWireProtocol<BsonDocument> CreateAuthenticateProtocol(BsonDocumen
137137
var protocol = new CommandWireProtocol<BsonDocument>(
138138
databaseNamespace: new DatabaseNamespace(_credential.Source),
139139
command: command,
140-
slaveOk: true,
140+
secondaryOk: true,
141141
resultSerializer: BsonDocumentSerializer.Instance,
142142
messageEncoderSettings: null,
143143
serverApi: _serverApi);
@@ -156,7 +156,7 @@ private CommandWireProtocol<BsonDocument> CreateGetNonceProtocol()
156156
var protocol = new CommandWireProtocol<BsonDocument>(
157157
databaseNamespace: new DatabaseNamespace(_credential.Source),
158158
command: command,
159-
slaveOk: true,
159+
secondaryOk: true,
160160
resultSerializer: BsonDocumentSerializer.Instance,
161161
messageEncoderSettings: null,
162162
serverApi: _serverApi);

src/MongoDB.Driver.Core/Core/Authentication/MongoDBX509Authenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private CommandWireProtocol<BsonDocument> CreateAuthenticateProtocol()
147147
var protocol = new CommandWireProtocol<BsonDocument>(
148148
databaseNamespace: new DatabaseNamespace("$external"),
149149
command: command,
150-
slaveOk: true,
150+
secondaryOk: true,
151151
resultSerializer: BsonDocumentSerializer.Instance,
152152
messageEncoderSettings: null,
153153
serverApi: _serverApi);

src/MongoDB.Driver.Core/Core/Authentication/SaslAuthenticator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private CommandWireProtocol<BsonDocument> CreateCommandProtocol(BsonDocument com
175175
return new CommandWireProtocol<BsonDocument>(
176176
databaseNamespace: new DatabaseNamespace(DatabaseName),
177177
command: command,
178-
slaveOk: true,
178+
secondaryOk: true,
179179
resultSerializer: BsonDocumentSerializer.Instance,
180180
messageEncoderSettings: null,
181181
serverApi: _serverApi);

src/MongoDB.Driver.Core/Core/Bindings/IChannel.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface IChannel : IDisposable
4949
/// <param name="command">The command.</param>
5050
/// <param name="commandValidator">The command validator.</param>
5151
/// <param name="responseHandling">The response handling.</param>
52-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the command message sent to the server.</param>
52+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the command message sent to the server.</param>
5353
/// <param name="resultSerializer">The result serializer.</param>
5454
/// <param name="messageEncoderSettings">The message encoder settings.</param>
5555
/// <param name="cancellationToken">The cancellation token.</param>
@@ -60,7 +60,7 @@ TResult Command<TResult>(
6060
BsonDocument command,
6161
IElementNameValidator commandValidator,
6262
Func<CommandResponseHandling> responseHandling,
63-
bool slaveOk,
63+
bool secondaryOk,
6464
IBsonSerializer<TResult> resultSerializer,
6565
MessageEncoderSettings messageEncoderSettings,
6666
CancellationToken cancellationToken);
@@ -76,7 +76,7 @@ TResult Command<TResult>(
7676
/// <param name="commandValidator">The command validator.</param>
7777
/// <param name="additionalOptions">The additional options.</param>
7878
/// <param name="responseHandling">The response handling.</param>
79-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the command message sent to the server.</param>
79+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the command message sent to the server.</param>
8080
/// <param name="resultSerializer">The result serializer.</param>
8181
/// <param name="messageEncoderSettings">The message encoder settings.</param>
8282
/// <param name="cancellationToken">The cancellation token.</param>
@@ -92,7 +92,7 @@ TResult Command<TResult>(
9292
IElementNameValidator commandValidator,
9393
BsonDocument additionalOptions,
9494
Func<CommandResponseHandling> responseHandling,
95-
bool slaveOk,
95+
bool secondaryOk,
9696
IBsonSerializer<TResult> resultSerializer,
9797
MessageEncoderSettings messageEncoderSettings,
9898
CancellationToken cancellationToken);
@@ -138,7 +138,7 @@ TResult Command<TResult>(
138138
/// <param name="command">The command.</param>
139139
/// <param name="commandValidator">The command validator.</param>
140140
/// <param name="responseHandling">The response handling.</param>
141-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the command message sent to the server.</param>
141+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the command message sent to the server.</param>
142142
/// <param name="resultSerializer">The result serializer.</param>
143143
/// <param name="messageEncoderSettings">The message encoder settings.</param>
144144
/// <param name="cancellationToken">The cancellation token.</param>
@@ -149,7 +149,7 @@ Task<TResult> CommandAsync<TResult>(
149149
BsonDocument command,
150150
IElementNameValidator commandValidator,
151151
Func<CommandResponseHandling> responseHandling,
152-
bool slaveOk,
152+
bool secondaryOk,
153153
IBsonSerializer<TResult> resultSerializer,
154154
MessageEncoderSettings messageEncoderSettings,
155155
CancellationToken cancellationToken);
@@ -165,7 +165,7 @@ Task<TResult> CommandAsync<TResult>(
165165
/// <param name="commandValidator">The command validator.</param>
166166
/// <param name="additionalOptions">The additional options.</param>
167167
/// <param name="responseHandling">The response handling.</param>
168-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the command message sent to the server.</param>
168+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the command message sent to the server.</param>
169169
/// <param name="resultSerializer">The result serializer.</param>
170170
/// <param name="messageEncoderSettings">The message encoder settings.</param>
171171
/// <param name="cancellationToken">The cancellation token.</param>
@@ -181,7 +181,7 @@ Task<TResult> CommandAsync<TResult>(
181181
IElementNameValidator commandValidator,
182182
BsonDocument additionalOptions,
183183
Func<CommandResponseHandling> responseHandling,
184-
bool slaveOk,
184+
bool secondaryOk,
185185
IBsonSerializer<TResult> resultSerializer,
186186
MessageEncoderSettings messageEncoderSettings,
187187
CancellationToken cancellationToken);
@@ -384,7 +384,7 @@ Task KillCursorsAsync(
384384
/// <param name="queryValidator">The query validator.</param>
385385
/// <param name="skip">The number of documents to skip.</param>
386386
/// <param name="batchSize">The size of a batch.</param>
387-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the query message sent to the server.</param>
387+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
388388
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
389389
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
390390
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
@@ -400,7 +400,7 @@ CursorBatch<TDocument> Query<TDocument>(
400400
IElementNameValidator queryValidator,
401401
int skip,
402402
int batchSize,
403-
bool slaveOk,
403+
bool secondaryOk,
404404
bool partialOk,
405405
bool noCursorTimeout,
406406
bool tailableCursor,
@@ -419,7 +419,7 @@ CursorBatch<TDocument> Query<TDocument>(
419419
/// <param name="queryValidator">The query validator.</param>
420420
/// <param name="skip">The number of documents to skip.</param>
421421
/// <param name="batchSize">The size of a batch.</param>
422-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the query message sent to the server.</param>
422+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
423423
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
424424
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
425425
/// <param name="oplogReplay">if set to <c>true</c> the OplogReplay bit will be set.</param>
@@ -437,7 +437,7 @@ CursorBatch<TDocument> Query<TDocument>(
437437
IElementNameValidator queryValidator,
438438
int skip,
439439
int batchSize,
440-
bool slaveOk,
440+
bool secondaryOk,
441441
bool partialOk,
442442
bool noCursorTimeout,
443443
bool oplogReplay, // obsolete: OplogReplay is ignored by server versions 4.4.0 and newer
@@ -457,7 +457,7 @@ CursorBatch<TDocument> Query<TDocument>(
457457
/// <param name="queryValidator">The query validator.</param>
458458
/// <param name="skip">The number of documents to skip.</param>
459459
/// <param name="batchSize">The size of a batch.</param>
460-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the query message sent to the server.</param>
460+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
461461
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
462462
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
463463
/// <param name="tailableCursor">if set to <c>true</c> the query should return a tailable cursor.</param>
@@ -473,7 +473,7 @@ Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
473473
IElementNameValidator queryValidator,
474474
int skip,
475475
int batchSize,
476-
bool slaveOk,
476+
bool secondaryOk,
477477
bool partialOk,
478478
bool noCursorTimeout,
479479
bool tailableCursor,
@@ -492,7 +492,7 @@ Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
492492
/// <param name="queryValidator">The query validator.</param>
493493
/// <param name="skip">The number of documents to skip.</param>
494494
/// <param name="batchSize">The size of a batch.</param>
495-
/// <param name="slaveOk">if set to <c>true</c> sets the SlaveOk bit to true in the query message sent to the server.</param>
495+
/// <param name="secondaryOk">if set to <c>true</c> sets the SecondaryOk bit to true in the query message sent to the server.</param>
496496
/// <param name="partialOk">if set to <c>true</c> the server is allowed to return partial results if any shards are unavailable.</param>
497497
/// <param name="noCursorTimeout">if set to <c>true</c> the server will not timeout the cursor.</param>
498498
/// <param name="oplogReplay">if set to <c>true</c> the OplogReplay bit will be set.</param>
@@ -510,7 +510,7 @@ Task<CursorBatch<TDocument>> QueryAsync<TDocument>(
510510
IElementNameValidator queryValidator,
511511
int skip,
512512
int batchSize,
513-
bool slaveOk,
513+
bool secondaryOk,
514514
bool partialOk,
515515
bool noCursorTimeout,
516516
bool oplogReplay, // obsolete: OplogReplay is ignored by server versions 4.4.0 and newer

0 commit comments

Comments
 (0)