@@ -85,7 +85,7 @@ public void TestClone()
8585 "maxIdleTime=124;maxLifeTime=125;maxPoolSize=126;minPoolSize=127;readConcernLevel=majority;" +
8686 "readPreference=secondary;readPreferenceTags=a:1,b:2;readPreferenceTags=c:3,d:4;socketTimeout=129;" +
8787 "serverSelectionTimeout=20s;ssl=true;sslVerifyCertificate=false;waitqueuesize=130;waitQueueTimeout=131;" +
88- "w=1;fsync=true;journal=true;w=2;wtimeout=131;gssapiServiceName=other;tlsInsecure=true " ;
88+ "w=1;fsync=true;journal=true;w=2;wtimeout=131;gssapiServiceName=other" ;
8989#pragma warning disable 618
9090 if ( BsonDefaults . GuidRepresentationMode == GuidRepresentationMode . V2 )
9191 {
@@ -95,7 +95,6 @@ public void TestClone()
9595 var builder = new MongoUrlBuilder ( connectionString ) ;
9696 var url = builder . ToMongoUrl ( ) ;
9797 var settings = MongoClientSettings . FromUrl ( url ) ;
98-
9998 // a few settings can only be made in code
10099#pragma warning disable 618
101100 settings . Credential = MongoCredential . CreateMongoCRCredential ( "database" , "username" , "password" ) . WithMechanismProperty ( "SERVICE_NAME" , "other" ) ;
@@ -104,9 +103,36 @@ public void TestClone()
104103 settings . SdamLogFilename = "stdout" ;
105104
106105 var clone = settings . Clone ( ) ;
106+
107107 Assert . Equal ( settings , clone ) ;
108108 }
109109
110+ [ Fact ]
111+ public void TestCloneTlsDisableCertificateRevocationCheck ( )
112+ {
113+ var connectionString = "mongodb://somehost/?tlsDisableCertificateRevocationCheck=true" ;
114+ var builder = new MongoUrlBuilder ( connectionString ) ;
115+ var url = builder . ToMongoUrl ( ) ;
116+ var settings = MongoClientSettings . FromUrl ( url ) ;
117+
118+ var clone = settings . Clone ( ) ;
119+
120+ clone . Should ( ) . Be ( settings ) ;
121+ }
122+
123+ [ Fact ]
124+ public void TestCloneTlsInsecure ( )
125+ {
126+ var connectionString = "mongodb://somehost/?tlsInsecure=true" ;
127+ var builder = new MongoUrlBuilder ( connectionString ) ;
128+ var url = builder . ToMongoUrl ( ) ;
129+ var settings = MongoClientSettings . FromUrl ( url ) ;
130+
131+ var clone = settings . Clone ( ) ;
132+
133+ clone . Should ( ) . Be ( settings ) ;
134+ }
135+
110136 [ Fact ]
111137 public void TestCompressors ( )
112138 {
@@ -398,12 +424,14 @@ public void TestFreezeInvalid()
398424 public void TestFromUrl ( )
399425 {
400426 // set everything to non default values to test that all settings are converted
427+ // with the exception of tlsDisableCertificateRevocationCheck because setting that with tlsInsecure is
428+ // not allowed in a connection string
401429 var connectionString =
402430 "mongodb://user1:password1@somehost/?appname=app1;authSource=db;authMechanismProperties=CANONICALIZE_HOST_NAME:true;" +
403431 "compressors=zlib,snappy;zlibCompressionLevel=9;connect=direct;connectTimeout=123;ipv6=true;heartbeatInterval=1m;heartbeatTimeout=2m;localThreshold=128;" +
404432 "maxIdleTime=124;maxLifeTime=125;maxPoolSize=126;minPoolSize=127;readConcernLevel=majority;" +
405433 "readPreference=secondary;readPreferenceTags=a:1,b:2;readPreferenceTags=c:3,d:4;retryReads=false;retryWrites=true;socketTimeout=129;" +
406- "serverSelectionTimeout=20s;tls=true;tlsInsecure=true ;waitqueuesize=130;waitQueueTimeout=131;" +
434+ "serverSelectionTimeout=20s;tls=true;sslVerifyCertificate=false ;waitqueuesize=130;waitQueueTimeout=131;" +
407435 "w=1;fsync=true;journal=true;w=2;wtimeout=131;gssapiServiceName=other" ;
408436#pragma warning disable 618
409437 if ( BsonDefaults . GuidRepresentationMode == GuidRepresentationMode . V2 )
@@ -415,6 +443,7 @@ public void TestFromUrl()
415443 var url = builder . ToMongoUrl ( ) ;
416444
417445 var settings = MongoClientSettings . FromUrl ( url ) ;
446+
418447 Assert . Equal ( url . AllowInsecureTls , settings . AllowInsecureTls ) ;
419448 Assert . Equal ( url . ApplicationName , settings . ApplicationName ) ;
420449 Assert . Equal ( url . Compressors , settings . Compressors ) ;
@@ -453,21 +482,44 @@ public void TestFromUrl()
453482 Assert . Equal ( url . ServerSelectionTimeout , settings . ServerSelectionTimeout ) ;
454483 Assert . Equal ( url . SocketTimeout , settings . SocketTimeout ) ;
455484#pragma warning disable 618
456- settings . SslSettings . Should ( ) . BeNull ( ) ;
485+ Assert . Equal ( url . TlsDisableCertificateRevocationCheck , ! settings . SslSettings . CheckCertificateRevocation ) ;
457486 Assert . Equal ( url . UseSsl , settings . UseSsl ) ;
458487#pragma warning restore 618
459488 Assert . Equal ( url . UseTls , settings . UseTls ) ;
460489#pragma warning disable 618
461490 Assert . Equal ( url . VerifySslCertificate , settings . VerifySslCertificate ) ;
462491#pragma warning restore 618
463-
464492#pragma warning disable 618
465493 Assert . Equal ( url . ComputedWaitQueueSize , settings . WaitQueueSize ) ;
466494#pragma warning restore 618
467495 Assert . Equal ( url . WaitQueueTimeout , settings . WaitQueueTimeout ) ;
468496 Assert . Equal ( url . GetWriteConcern ( true ) , settings . WriteConcern ) ;
469497 }
470498
499+ [ Fact ]
500+ public void TestFromUrlTlsDisableCertificateRevocationCheck ( )
501+ {
502+ var connectionString = "mongodb://the-next-generation/?tlsDisableCertificateRevocationCheck=true" ;
503+ var builder = new MongoUrlBuilder ( connectionString ) ;
504+ var url = builder . ToMongoUrl ( ) ;
505+
506+ var settings = MongoClientSettings . FromUrl ( url ) ;
507+
508+ settings . SslSettings . Should ( ) . Be ( new SslSettings { CheckCertificateRevocation = ! url . TlsDisableCertificateRevocationCheck } ) ;
509+ }
510+
511+ [ Fact ]
512+ public void TestFromUrlTlsInsecure ( )
513+ {
514+ var connectionString = "mongodb://the-next-generation/?tlsInsecure=true" ;
515+ var builder = new MongoUrlBuilder ( connectionString ) ;
516+ var url = builder . ToMongoUrl ( ) ;
517+
518+ var settings = MongoClientSettings . FromUrl ( url ) ;
519+
520+ settings . AllowInsecureTls . Should ( ) . Be ( url . AllowInsecureTls ) ;
521+ }
522+
471523 [ Fact ]
472524 public void TestFromUrlWithMongoDBX509 ( )
473525 {
0 commit comments