MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_scram_skip_empty_exchange

Method test_scram_skip_empty_exchange

test/test_auth.py:448–471  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

446 super().tearDown()
447
448 def test_scram_skip_empty_exchange(self):
449 listener = AllowListEventListener("saslStart", "saslContinue")
450 client_context.create_user(
451 "testscram", "sha256", "pwd", roles=["dbOwner"], mechanisms=["SCRAM-SHA-256"]
452 )
453
454 client = self.rs_or_single_client_noauth(
455 username="sha256", password="pwd", authSource="testscram", event_listeners=[listener]
456 )
457 client.testscram.command("dbstats")
458
459 if client_context.version < (4, 4, -1):
460 # Assert we sent the skipEmptyExchange option.
461 first_event = listener.started_events[0]
462 self.assertEqual(first_event.command_name, "saslStart")
463 self.assertEqual(first_event.command["options"], {"skipEmptyExchange": True})
464
465 # Assert the third exchange was skipped on servers that support it.
466 # Note that the first exchange occurs on the connection handshake.
467 started = listener.started_command_names()
468 if client_context.version.at_least(4, 4, -1):
469 self.assertEqual(started, ["saslContinue"])
470 else:
471 self.assertEqual(started, ["saslStart", "saslContinue", "saslContinue"])
472
473 @client_context.require_no_fips
474 def test_scram(self):

Callers

nothing calls this directly

Calls 6

started_command_namesMethod · 0.80
at_leastMethod · 0.80
create_userMethod · 0.45
commandMethod · 0.45

Tested by

no test coverage detected