Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions kafka/net/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ def sasl_enabled(self):

async def _sasl_authenticate(self):
# Step 1: SaslHandshake to negotiate mechanism
version = self.broker_version_data.api_version(SaslHandshakeRequest, max_version=1)
request = SaslHandshakeRequest[version](self.config['sasl_mechanism'])
request = SaslHandshakeRequest(
mechanism=self.config['sasl_mechanism'],
max_version=1)
try:
response = await self._send_request(request)
except Exception as exc:
Expand All @@ -415,6 +416,7 @@ async def _sasl_authenticate(self):
return

# Step 2: SASL authentication exchange
version = response.API_VERSION
try:
mechanism = get_sasl_mechanism(self.config['sasl_mechanism'])(
host=self.transport.getPeer()[0], **self.config)
Expand All @@ -425,7 +427,7 @@ async def _sasl_authenticate(self):
while not mechanism.is_done():
token = mechanism.auth_bytes()
if version == 1:
auth_request = SaslAuthenticateRequest[0](token)
auth_request = SaslAuthenticateRequest(token, version=0)
else:
auth_request = SaslBytesRequest(token)

Expand Down
6 changes: 2 additions & 4 deletions test/test_mock_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ def test_send_and_receive(self):
client.await_ready(node_id, timeout_ms=5000)

# Send a MetadataRequest directly via client.send
version = client.api_version(MetadataRequest, max_version=8)
request = MetadataRequest[version]()
request = MetadataRequest(max_version=9)
future = client.send(node_id, request)
_poll_for_future(client, future)

Expand All @@ -251,8 +250,7 @@ def test_fail_next_aborts_request(self):
error = Errors.KafkaConnectionError('simulated')
broker.fail_next(MetadataRequest, error=error)

version = client.api_version(MetadataRequest, max_version=8)
future = client.send(node_id, MetadataRequest[version]())
future = client.send(node_id, MetadataRequest(max_version=9))
_poll_for_future(client, future)

assert future.failed()
Expand Down
Loading