File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ def __init__(
84
84
except Exception :
85
85
raise ConfigurationError (_INVALID_HOST_MSG % (fqdn ,)) from None
86
86
self .__slen = len (self .__plist )
87
+ if self .__slen < 2 :
88
+ raise ConfigurationError (_INVALID_HOST_MSG % (fqdn ,))
87
89
88
90
def get_options (self ) -> Optional [str ]:
89
91
from dns import resolver
Original file line number Diff line number Diff line change @@ -183,6 +183,18 @@ def create_tests(cls):
183
183
184
184
class TestParsingErrors (PyMongoTestCase ):
185
185
def test_invalid_host (self ):
186
+ self .assertRaisesRegex (
187
+ ConfigurationError ,
188
+ "Invalid URI host: mongodb is not" ,
189
+ self .simple_client ,
190
+ "mongodb+srv://mongodb" ,
191
+ )
192
+ self .assertRaisesRegex (
193
+ ConfigurationError ,
194
+ "Invalid URI host: mongodb.com is not" ,
195
+ self .simple_client ,
196
+ "mongodb+srv://mongodb.com" ,
197
+ )
186
198
self .assertRaisesRegex (
187
199
ConfigurationError ,
188
200
"Invalid URI host: an IP address is not" ,
You can’t perform that action at this time.
0 commit comments