Skip to content

Commit ca9ea7e

Browse files
committed
fixing unit tests.
1 parent 0b930fd commit ca9ea7e

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

MongoDB.Driver/Communication/Security/MongoCRAuthenticationProtocol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void Authenticate(MongoConnection connection, MongoCredential credential)
7777
/// </returns>
7878
public bool CanUse(MongoCredential credential)
7979
{
80-
return credential.Mechanism == MongoAuthenticationMechanism.MongoCR &&
80+
return credential.Mechanism == MongoAuthenticationMechanism.Mongo_CR &&
8181
credential.Evidence is PasswordEvidence;
8282
}
8383
}

MongoDB.Driver/MongoAuthenticationMechanism.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum MongoAuthenticationMechanism
2323
/// <summary>
2424
/// Authenticate to the server using the Mongo Challenge Response (MONGO-CR) protocol.
2525
/// </summary>
26-
MongoCR,
26+
Mongo_CR,
2727
/// <summary>
2828
/// Authenticate to the server using GSSAPI.
2929
/// </summary>

MongoDB.Driver/MongoConnectionStringBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public MongoAuthenticationMechanism AuthenticationMechanism
135135
_authenticationMechanism = value;
136136
base["authMechanism"] = value
137137
.ToString()
138+
.ToUpper()
138139
.Replace("_", "-");
139140
}
140141
}
@@ -965,7 +966,7 @@ private IEnumerable<MongoServerAddress> ParseServersString(string value)
965966
private void ResetValues()
966967
{
967968
// set fields and not properties so base class items aren't set
968-
_authenticationMechanism = MongoAuthenticationMechanism.MongoCR;
969+
_authenticationMechanism = MongoAuthenticationMechanism.Mongo_CR;
969970
_authenticationSource = null;
970971
_connectionMode = ConnectionMode.Automatic;
971972
_connectTimeout = MongoDefaults.ConnectTimeout;

MongoDB.Driver/MongoCredential.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static MongoCredential CreateGssapiCredential(string username, SecureStri
188188
/// <returns></returns>
189189
public static MongoCredential CreateMongoCRCredential(string databaseName, string username, string password)
190190
{
191-
return FromComponents(MongoAuthenticationMechanism.MongoCR,
191+
return FromComponents(MongoAuthenticationMechanism.Mongo_CR,
192192
databaseName,
193193
username,
194194
new PasswordEvidence(password));
@@ -203,7 +203,7 @@ public static MongoCredential CreateMongoCRCredential(string databaseName, strin
203203
/// <returns></returns>
204204
public static MongoCredential CreateMongoCRCredential(string databaseName, string username, SecureString password)
205205
{
206-
return FromComponents(MongoAuthenticationMechanism.MongoCR,
206+
return FromComponents(MongoAuthenticationMechanism.Mongo_CR,
207207
databaseName,
208208
username,
209209
new PasswordEvidence(password));
@@ -284,7 +284,7 @@ private static MongoCredential FromComponents(MongoAuthenticationMechanism mecha
284284

285285
switch (mechanism)
286286
{
287-
case MongoAuthenticationMechanism.MongoCR:
287+
case MongoAuthenticationMechanism.Mongo_CR:
288288
// it is allowed for a password to be an empty string, but not a username
289289
source = source ?? "admin";
290290
if (evidence == null || !(evidence is PasswordEvidence))

MongoDB.Driver/MongoUrlBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class MongoUrlBuilder
6666
/// </summary>
6767
public MongoUrlBuilder()
6868
{
69-
_authenticationMechanism = MongoAuthenticationMechanism.MongoCR;
69+
_authenticationMechanism = MongoAuthenticationMechanism.Mongo_CR;
7070
_authenticationSource = null;
7171
_connectionMode = ConnectionMode.Automatic;
7272
_connectTimeout = MongoDefaults.ConnectTimeout;
@@ -1014,10 +1014,11 @@ public override string ToString()
10141014
url.Append(_databaseName);
10151015
}
10161016
var query = new StringBuilder();
1017-
if (_authenticationMechanism != MongoAuthenticationMechanism.MongoCR)
1017+
if (_authenticationMechanism != MongoAuthenticationMechanism.Mongo_CR)
10181018
{
10191019
string mechanismName = _authenticationMechanism
10201020
.ToString()
1021+
.ToUpper()
10211022
.Replace("_", "-");
10221023

10231024
query.AppendFormat("authMechanism={0};", mechanismName);

MongoDB.DriverUnitTests/MongoConnectionStringBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void TestAll()
135135
}
136136

137137
[Test]
138-
[TestCase(MongoAuthenticationMechanism.MongoCR, "server=localhost;authMechanism=MONGO-CR")]
138+
[TestCase(MongoAuthenticationMechanism.Mongo_CR, "server=localhost;authMechanism=MONGO-CR")]
139139
[TestCase(MongoAuthenticationMechanism.Gssapi, "server=localhost;authMechanism=GSSAPI")]
140140
public void TestAuthMechanism(MongoAuthenticationMechanism mechanism, string connectionString)
141141
{

MongoDB.DriverUnitTests/MongoUrlBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void TestAll()
131131
}
132132

133133
[Test]
134-
[TestCase(MongoAuthenticationMechanism.MongoCR, "mongodb://localhost")]
134+
[TestCase(MongoAuthenticationMechanism.Mongo_CR, "mongodb://localhost")]
135135
[TestCase(MongoAuthenticationMechanism.Gssapi, "mongodb://localhost/?authMechanism=GSSAPI")]
136136
public void TestAuthMechanism(MongoAuthenticationMechanism mechanism, string connectionString)
137137
{
@@ -279,7 +279,7 @@ public void TestDefaults()
279279

280280
foreach (var builder in EnumerateBuiltAndParsedBuilders(built, connectionString))
281281
{
282-
Assert.AreEqual(MongoAuthenticationMechanism.MongoCR, builder.AuthenticationMechanism);
282+
Assert.AreEqual(MongoAuthenticationMechanism.Mongo_CR, builder.AuthenticationMechanism);
283283
Assert.AreEqual(null, builder.AuthenticationSource);
284284
Assert.AreEqual(MongoDefaults.ComputedWaitQueueSize, builder.ComputedWaitQueueSize);
285285
Assert.AreEqual(ConnectionMode.Automatic, builder.ConnectionMode);

0 commit comments

Comments
 (0)