@@ -220,12 +220,15 @@ async def mock_resolve(query, record_type, *args, **kwargs):
220
220
mock_resolver .side_effect = mock_resolve
221
221
domain = case ["query" ].split ("._tcp." )[1 ]
222
222
connection_string = f"mongodb+srv://{ domain } "
223
- try :
223
+ if "expected_error" not in case :
224
224
await parse_uri (connection_string )
225
- except ConfigurationError as e :
226
- self .assertIn (case ["expected_error" ], str (e ))
227
225
else :
228
- self .fail (f"ConfigurationError was not raised for query: { case ['query' ]} " )
226
+ try :
227
+ await parse_uri (connection_string )
228
+ except ConfigurationError as e :
229
+ self .assertIn (case ["expected_error" ], str (e ))
230
+ else :
231
+ self .fail (f"ConfigurationError was not raised for query: { case ['query' ]} " )
229
232
230
233
async def test_1_allow_srv_hosts_with_fewer_than_three_dot_separated_parts (self ):
231
234
with patch ("dns.asyncresolver.resolve" ):
@@ -289,6 +292,17 @@ async def test_4_throw_when_return_address_does_not_contain_dot_separating_share
289
292
]
290
293
await self .run_initial_dns_seedlist_discovery_prose_tests (test_cases )
291
294
295
+ async def test_5_when_srv_hostname_has_two_dot_separated_parts_it_is_valid_for_the_returned_hostname_to_be_identical (
296
+ self
297
+ ):
298
+ test_cases = [
299
+ {
300
+ "query" : "_mongodb._tcp.blogs.mongodb.com" ,
301
+ "mock_target" : "blogs.mongodb.com" ,
302
+ },
303
+ ]
304
+ await self .run_initial_dns_seedlist_discovery_prose_tests (test_cases )
305
+
292
306
293
307
if __name__ == "__main__" :
294
308
unittest .main ()
0 commit comments