Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/mockupdb/test_handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,39 @@ def test_client_handshake_saslSupportedMechs(self):
future()
return

def test_client_handshake_saslSupportedMechs_unknown(self):
server = MockupDB()
server.run()
self.addCleanup(server.stop)

primary_response = OpReply(
"ismaster",
True,
minWireVersion=2,
maxWireVersion=MIN_SUPPORTED_WIRE_VERSION,
saslSupportedMechs=["SCRAM-SHA-256", "does_not_exist"],
)
client = MongoClient(
server.uri, authmechanism="PLAIN", username="username", password="password"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test may be flawed. A client only negotiates the auth mechanism if authmechanism is not supplied but this test sets authmechanism="PLAIN". Instead it should create the client without authmechanism or set authmechanism="DEFAULT".

)

self.addCleanup(client.close)

# New monitoring connections send data during handshake.
heartbeat = server.receives("ismaster")
heartbeat.ok(primary_response)

future = go(client.db.command, "whatever")
for request in server:
if request.matches("ismaster"):
request.ok(primary_response)
elif request.matches("saslStart"):
request.ok("saslStart", True, conversationId=1, payload=b"", done=True, ok=1)
else:
request.ok()
future()
return

def test_handshake_load_balanced(self):
self.hello_with_option_helper(OpMsg, loadBalanced=True)
with self.assertRaisesRegex(AssertionError, "does not match"):
Expand Down
Loading