Skip to content

Commit dfb6a9a

Browse files
authored
PYTHON-4209 Ensure that no error is raised for unknown auth mechanism (mongodb#1981)
1 parent 00c2960 commit dfb6a9a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/mockupdb/test_handshake.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,39 @@ def test_client_handshake_saslSupportedMechs(self):
229229
future()
230230
return
231231

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+
232265
def test_handshake_load_balanced(self):
233266
self.hello_with_option_helper(OpMsg, loadBalanced=True)
234267
with self.assertRaisesRegex(AssertionError, "does not match"):

0 commit comments

Comments
 (0)