@@ -218,50 +218,19 @@ def test_client_handshake_saslSupportedMechs(self):
218218 request .ok (
219219 "ismaster" ,
220220 True ,
221- saslSupportedMechs = ["SCRAM-SHA-256" ],
221+ # Unsupported auth mech should be ignored.
222+ saslSupportedMechs = ["SCRAM-SHA-256" , "does_not_exist" ],
222223 speculativeAuthenticate = auth ,
223224 minWireVersion = 2 ,
224225 maxWireVersion = MIN_SUPPORTED_WIRE_VERSION ,
225226 )
226227 # Authentication should immediately fail with:
227228 # OperationFailure: Server returned an invalid nonce.
228- with self .assertRaises (OperationFailure ):
229+ with self .assertRaises (OperationFailure ) as cm :
229230 future ()
231+ self .assertEqual (str (cm .exception ), "Server returned an invalid nonce." )
230232 return
231233
232- def test_client_handshake_saslSupportedMechs_unknown (self ):
233- server = MockupDB ()
234- server .run ()
235- self .addCleanup (server .stop )
236-
237- primary_response = OpReply (
238- "ismaster" ,
239- True ,
240- minWireVersion = 2 ,
241- maxWireVersion = MIN_SUPPORTED_WIRE_VERSION ,
242- saslSupportedMechs = ["SCRAM-SHA-256" , "does_not_exist" ],
243- )
244- client = MongoClient (
245- server .uri , authmechanism = "PLAIN" , username = "username" , password = "password"
246- )
247-
248- self .addCleanup (client .close )
249-
250- # New monitoring connections send data during handshake.
251- heartbeat = server .receives ("ismaster" )
252- heartbeat .ok (primary_response )
253-
254- future = go (client .db .command , "whatever" )
255- for request in server :
256- if request .matches ("ismaster" ):
257- request .ok (primary_response )
258- elif request .matches ("saslStart" ):
259- request .ok ("saslStart" , True , conversationId = 1 , payload = b"" , done = True , ok = 1 )
260- else :
261- request .ok ()
262- future ()
263- return
264-
265234 def test_handshake_load_balanced (self ):
266235 self .hello_with_option_helper (OpMsg , loadBalanced = True )
267236 with self .assertRaisesRegex (AssertionError , "does not match" ):
0 commit comments