Skip to content

Commit 785f030

Browse files
committed
fixing explicit auth tests against external system.
1 parent a93fa6e commit 785f030

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/MongoDB.Driver.TestHelpers/DriverTestConfiguration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ namespace MongoDB.Driver.Tests
2727
public static class DriverTestConfiguration
2828
{
2929
// private static fields
30-
private static MongoClient __client;
30+
private static Lazy<MongoClient> __client;
3131
private static CollectionNamespace __collectionNamespace;
3232
private static DatabaseNamespace __databaseNamespace;
3333

3434
// static constructor
3535
static DriverTestConfiguration()
3636
{
37-
__client = new MongoClient(CoreTestConfiguration.Cluster);
37+
__client = new Lazy<MongoClient>(() => new MongoClient(CoreTestConfiguration.Cluster), true);
3838
__databaseNamespace = CoreTestConfiguration.DatabaseNamespace;
3939
__collectionNamespace = new CollectionNamespace(__databaseNamespace, "testcollection");
4040
}
@@ -45,7 +45,7 @@ static DriverTestConfiguration()
4545
/// </summary>
4646
public static MongoClient Client
4747
{
48-
get { return __client; }
48+
get { return __client.Value; }
4949
}
5050

5151
/// <summary>

src/MongoDB.Driver.Tests/Communication/Security/GssapiAuthenticationTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
using System;
1717
using System.Linq;
1818
using MongoDB.Bson;
19+
using MongoDB.Driver.Core.Authentication;
20+
using MongoDB.Driver.Core.Configuration;
1921
using NUnit.Framework;
2022

2123
namespace MongoDB.Driver.Tests.Communication.Security
@@ -33,7 +35,7 @@ public class GssapiAuthenticationTests
3335
[SetUp]
3436
public void Setup()
3537
{
36-
_settings = DriverTestConfiguration.Client.Settings.Clone();
38+
_settings = MongoClientSettings.FromUrl(new MongoUrl(CoreTestConfiguration.ConnectionString.ToString()));
3739
}
3840

3941
[Test]
@@ -54,6 +56,7 @@ public void TestNoCredentials()
5456
});
5557
}
5658

59+
5760
[Test]
5861
public void TestSuccessfulAuthentication()
5962
{
@@ -74,7 +77,7 @@ public void TestSuccessfulAuthentication()
7477
public void TestBadPassword()
7578
{
7679
var currentCredentialUsername = _settings.Credentials.Single().Username;
77-
_settings.Credentials = new[]
80+
_settings.Credentials = new[]
7881
{
7982
MongoCredential.CreateGssapiCredential(currentCredentialUsername, "wrongPassword")
8083
};

src/MongoDB.Driver.Tests/Communication/Security/PlainAuthenticationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class PlainAuthenticationTests
3434
[SetUp]
3535
public void Setup()
3636
{
37-
_settings = DriverTestConfiguration.Client.Settings.Clone();
37+
_settings = MongoClientSettings.FromUrl(new MongoUrl(CoreTestConfiguration.ConnectionString.ToString()));
3838
}
3939

4040
[Test]
@@ -75,7 +75,7 @@ public void TestSuccessfulAuthentication()
7575
public void TestBadPassword()
7676
{
7777
var currentCredential = _settings.Credentials.Single();
78-
_settings.Credentials = new[]
78+
_settings.Credentials = new[]
7979
{
8080
MongoCredential.CreatePlainCredential(currentCredential.Source, currentCredential.Username, "wrongPassword")
8181
};

0 commit comments

Comments
 (0)