@@ -50,7 +50,7 @@ def respond(r):
50
50
appname = 'my app' , # For _check_handshake_data()
51
51
** dict ([k_map .get ((k , v ), (k , v )) for k , v
52
52
in kwargs .items ()]))
53
-
53
+
54
54
self .addCleanup (client .close )
55
55
56
56
# We have an autoresponder luckily, so no need for `go()`.
@@ -217,5 +217,42 @@ def test_handshake_not_either(self):
217
217
with self .assertRaisesRegex (AssertionError , "does not match" ):
218
218
test_hello_with_option (self , OpMsg )
219
219
220
+ def test_handshake_max_wire (self ):
221
+ server = MockupDB ()
222
+ primary_response = {"hello" : 1 , "ok" : 1 ,
223
+ "minWireVersion" : 0 , "maxWireVersion" : 6 }
224
+ self .found_auth_msg = False
225
+
226
+ def responder (request ):
227
+ if request .matches (OpMsg , saslStart = 1 ):
228
+ self .found_auth_msg = True
229
+ # Immediately closes the connection with
230
+ # OperationFailure: Server returned an invalid nonce.
231
+ request .reply (OpMsgReply (** primary_response ,
232
+ ** {'payload' :
233
+ b'r=wPleNM8S5p8gMaffMDF7Py4ru9bnmmoqb0'
234
+ b'1WNPsil6o=pAvr6B1garhlwc6MKNQ93ZfFky'
235
+ b'tXdF9r,'
236
+ b's=4dcxugMJq2P4hQaDbGXZR8uR3ei'
237
+ b'PHrSmh4uhkg==,i=15000' ,
238
+ "saslSupportedMechs" : [
239
+ "SCRAM-SHA-1" ]}))
240
+ else :
241
+ return request .reply (** primary_response )
242
+
243
+ server .autoresponds (responder )
244
+ self .addCleanup (server .stop )
245
+ server .run ()
246
+ client = MongoClient (server .uri ,
247
+ username = 'username' ,
248
+ password = 'password' ,
249
+ )
250
+ self .addCleanup (client .close )
251
+ self .assertRaises (OperationFailure , client .db .collection .find_one ,
252
+ {"a" : 1 })
253
+ self .assertTrue (self .found_auth_msg , "Could not find authentication "
254
+ "command with correct protocol" )
255
+
256
+
220
257
if __name__ == '__main__' :
221
258
unittest .main ()
0 commit comments