Skip to content

Commit 1f2f648

Browse files
author
Sridhar Nanjundeswaran
committed
CSHARP-760 - default ExternalEvidence credential when credential created with username only
1 parent 0ae5c7f commit 1f2f648

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

MongoDB.Driver/MongoCredential.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static MongoCredential CreateGssapiCredential(string username)
163163
return FromComponents("GSSAPI",
164164
"$external",
165165
username,
166-
(PasswordEvidence)null);
166+
new ExternalEvidence());
167167
}
168168

169169
/// <summary>

MongoDB.DriverUnitTests/MongoCredentialTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,17 @@ public void TestPassword()
6969
Assert.AreEqual("password", credentials.Password);
7070
#pragma warning restore
7171
}
72+
73+
[Test]
74+
public void TestCreateGssapiCredentialWithOnlyUsername()
75+
{
76+
var username = "testuser";
77+
var credential = MongoCredential.CreateGssapiCredential(username);
78+
Assert.AreEqual(username, credential.Username);
79+
Assert.IsInstanceOf<ExternalEvidence>(credential.Evidence);
80+
Assert.AreEqual("GSSAPI", credential.Mechanism);
81+
Assert.AreEqual("$external", credential.Source);
82+
Assert.AreEqual(new ExternalEvidence(), credential.Evidence);
83+
}
7284
}
7385
}

0 commit comments

Comments
 (0)