From 692b0aeafda745243771a44223175d0c77f44c47 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Thu, 12 Sep 2024 17:41:17 -0700 Subject: [PATCH] Kafka connection --- lib/kafkalib/connection.go | 8 ++++---- lib/kafkalib/connection_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/kafkalib/connection.go b/lib/kafkalib/connection.go index 158b67a50..a33685584 100644 --- a/lib/kafkalib/connection.go +++ b/lib/kafkalib/connection.go @@ -37,14 +37,14 @@ func NewConnection(enableAWSMSKIAM bool, disableTLS bool, username, password str } func (c Connection) Mechanism() Mechanism { - if c.username != "" && c.password != "" { - return ScramSha512 - } - if c.enableAWSMSKIAM { return AwsMskIam } + if c.username != "" && c.password != "" { + return ScramSha512 + } + return Plain } diff --git a/lib/kafkalib/connection_test.go b/lib/kafkalib/connection_test.go index f64dabe3f..a2881b860 100644 --- a/lib/kafkalib/connection_test.go +++ b/lib/kafkalib/connection_test.go @@ -16,9 +16,9 @@ func TestConnection_Mechanism(t *testing.T) { c := NewConnection(false, false, "username", "password") assert.Equal(t, ScramSha512, c.Mechanism()) - // AWS MSK IAM is enabled, but SCRAM is preferred + // Username and password are set but AWS IAM is enabled c = NewConnection(true, false, "username", "password") - assert.Equal(t, ScramSha512, c.Mechanism()) + assert.Equal(t, AwsMskIam, c.Mechanism()) } { c := NewConnection(true, false, "", "")