@@ -2452,6 +2452,42 @@ test_mongoc_uri_duplicates (void)
2452
2452
mongoc_uri_destroy (uri );
2453
2453
}
2454
2454
2455
+ static void
2456
+ test_one_tls_option_enables_tls ()
2457
+ {
2458
+ const char * opts [] = {MONGOC_URI_TLS "=true" ,
2459
+ MONGOC_URI_TLSCERTIFICATEKEYFILE "=file.pem" ,
2460
+ MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "=file.pem" ,
2461
+ MONGOC_URI_TLSCAFILE "=file.pem" ,
2462
+ MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "=true" ,
2463
+ MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "=true" ,
2464
+ MONGOC_URI_TLSINSECURE "=true" ,
2465
+ MONGOC_URI_SSL "=true" ,
2466
+ MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE "=file.pem" ,
2467
+ MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD "=file.pem" ,
2468
+ MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE "=file.pem" ,
2469
+ MONGOC_URI_SSLALLOWINVALIDCERTIFICATES "=true" ,
2470
+ MONGOC_URI_SSLALLOWINVALIDHOSTNAMES "=true" };
2471
+ int i ;
2472
+
2473
+ for (i = 0 ; i < sizeof (opts ) / sizeof (opts [0 ]); i ++ ) {
2474
+ mongoc_uri_t * uri ;
2475
+ bson_error_t error ;
2476
+ char * uri_string ;
2477
+
2478
+ uri_string =
2479
+ bson_strdup_printf ("mongodb://localhost:27017/?%s" , opts [i ]);
2480
+ uri = mongoc_uri_new_with_error (uri_string , & error );
2481
+ bson_free (uri_string );
2482
+ ASSERT_OR_PRINT (uri , error );
2483
+ if (!mongoc_uri_get_tls (uri )) {
2484
+ test_error (
2485
+ "unexpected tls not enabled when following option set: %s\n" ,
2486
+ opts [i ]);
2487
+ }
2488
+ mongoc_uri_destroy (uri );
2489
+ }
2490
+ }
2455
2491
2456
2492
void
2457
2493
test_uri_install (TestSuite * suite )
@@ -2482,4 +2518,7 @@ test_uri_install (TestSuite *suite)
2482
2518
TestSuite_Add (suite , "/Uri/dns_options" , test_mongoc_uri_dns_options );
2483
2519
TestSuite_Add (suite , "/Uri/utf8" , test_mongoc_uri_utf8 );
2484
2520
TestSuite_Add (suite , "/Uri/duplicates" , test_mongoc_uri_duplicates );
2521
+ TestSuite_Add (suite ,
2522
+ "/Uri/one_tls_option_enables_tls" ,
2523
+ test_one_tls_option_enables_tls );
2485
2524
}
0 commit comments