@@ -1847,14 +1847,24 @@ test_mongoc_uri_dns_options (void)
1847
1847
mongoc_uri_destroy (uri );
1848
1848
uri = mongoc_uri_new (
"mongodb+srv://[email protected] /?authSource=db1&replicaSet=rs1" );
1849
1849
1850
- capture_logs (true);
1851
- /* parse_options returns true, but logs warnings */
1852
- BSON_ASSERT (mongoc_uri_parse_options (uri , "authSource=db2&replicaSet=db2" , true, NULL ));
1853
- ASSERT_CAPTURED_LOG ("parsing TXT record" , MONGOC_LOG_LEVEL_WARNING , "Cannot override URI option \"authSource\"" );
1854
- ASSERT_CAPTURED_LOG ("parsing TXT record" , MONGOC_LOG_LEVEL_WARNING , "Cannot override URI option \"replicaSet\"" );
1855
- capture_logs (false);
1856
- ASSERT_MATCH (mongoc_uri_get_credentials (uri ), "{'authsource': 'db1'}" );
1857
- ASSERT_MATCH (mongoc_uri_get_options (uri ), "{'replicaset': 'rs1'}" );
1850
+ // test that parsing warns if replicaSet is ignored from TXT records.
1851
+ {
1852
+ capture_logs (true);
1853
+ ASSERT (mongoc_uri_parse_options (uri , "replicaSet=db2" , true, NULL ));
1854
+ ASSERT_CAPTURED_LOG (
1855
+ "parsing replicaSet from TXT" , MONGOC_LOG_LEVEL_WARNING , "Ignoring URI option \"replicaSet\"" );
1856
+ capture_logs (false);
1857
+ ASSERT_MATCH (mongoc_uri_get_options (uri ), "{'replicaset': 'rs1'}" );
1858
+ }
1859
+
1860
+ // test that parsing does not warn if authSource is ignored from TXT records.
1861
+ {
1862
+ capture_logs (true);
1863
+ ASSERT (mongoc_uri_parse_options (uri , "authSource=db2" , true, NULL ));
1864
+ ASSERT_NO_CAPTURED_LOGS ("parsing authSource from TXT" );
1865
+ capture_logs (false);
1866
+ ASSERT_MATCH (mongoc_uri_get_credentials (uri ), "{'authsource': 'db1'}" );
1867
+ }
1858
1868
1859
1869
mongoc_uri_destroy (uri );
1860
1870
}
0 commit comments