Skip to content

Commit e2b6693

Browse files
SeppMeSMeinhardt
andauthored
Set the current host in the SASL configs (#2633)
Co-authored-by: Sebastian.Meinhardt <Sebastian.Meinhardt@vodafone.com>
1 parent 7b7f3af commit e2b6693

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

kafka/conn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def __init__(self, host, port, afi, **configs):
256256
for key in self.config:
257257
if key in configs:
258258
self.config[key] = configs[key]
259+
self.config['host'] = host
259260

260261
self.node_id = self.config.pop('node_id')
261262

test/test_conn.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,13 @@ def test_maybe_throttle(conn):
386386

387387
time.return_value = 3000
388388
assert not conn.throttled()
389+
390+
391+
def test_host_in_sasl_config():
392+
hostname = 'example.org'
393+
port = 9092
394+
for security_protocol in ('SASL_PLAINTEXT', 'SASL_SSL'):
395+
with mock.patch("kafka.conn.get_sasl_mechanism") as get_sasl_mechanism:
396+
BrokerConnection(hostname, port, socket.AF_UNSPEC, security_protocol=security_protocol)
397+
call_config = get_sasl_mechanism.mock_calls[1].kwargs
398+
assert call_config['host'] == hostname

0 commit comments

Comments
 (0)