Skip to content
Merged
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
505 changes: 376 additions & 129 deletions downstreamadapter/sink/kafka/sink_test.go

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions downstreamadapter/sink/topicmanager/topic_manager_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
20 changes: 4 additions & 16 deletions pkg/sink/kafka/scram_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ package kafka
import (
"testing"

"github.com/IBM/sarama"
"github.com/stretchr/testify/require"
"github.com/xdg/scram"
)

func TestSCRAMClientGeneratorHandshake(t *testing.T) {
func TestSCRAMClientHandshake(t *testing.T) {
t.Parallel()

tests := []struct {
name string
mechanism saslMechanism
hashGenerator scram.HashGeneratorFcn
}{
{name: "SHA-256", mechanism: scram256Mechanism, hashGenerator: sha256HashGenerator},
{name: "SHA-512", mechanism: scram512Mechanism, hashGenerator: sha512HashGenerator},
{name: "SHA-256", hashGenerator: sha256HashGenerator},
{name: "SHA-512", hashGenerator: sha512HashGenerator},
}

for _, test := range tests {
Expand All @@ -41,17 +39,7 @@ func TestSCRAMClientGeneratorHandshake(t *testing.T) {
username = "user"
password = "password"
)
options := NewOptions()
options.sasl = &saslConfig{
user: username,
password: password,
mechanism: test.mechanism,
}
config := sarama.NewConfig()
require.NoError(t, completeSaramaSASLConfig(t.Context(), config, options))
require.NotNil(t, config.Net.SASL.SCRAMClientGeneratorFunc)

client := config.Net.SASL.SCRAMClientGeneratorFunc()
client := &xdgSCRAMClient{HashGeneratorFcn: test.hashGenerator}
require.NoError(t, client.Begin(username, password, ""))

credentialClient, err := test.hashGenerator.NewClient(username, password, "")
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-mock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ fi
"$MOCKGEN" -source pkg/sink/codec/simple/marshaller.go -destination pkg/sink/codec/simple/mock/marshaller.go
"$MOCKGEN" -source pkg/sink/kafka/admin_client.go -destination pkg/sink/kafka/admin_client_mock.go -package kafka
"$MOCKGEN" -source pkg/sink/kafka/factory.go -destination pkg/sink/kafka/factory_mock.go -package kafka
"$MOCKGEN" -source pkg/sink/kafka/admin.go -destination pkg/sink/kafka/admin_mock.go -package kafka
"$MOCKGEN" -source pkg/sink/kafka/admin.go -destination pkg/sink/kafka/sarama_admin_mock.go -package kafka
"$MOCKGEN" -source pkg/sink/kafka/sarama_sync_producer.go -destination pkg/sink/kafka/sarama_sync_producer_mock.go -package kafka
"$MOCKGEN" -source downstreamadapter/sink/topicmanager/topic_manager.go -destination downstreamadapter/sink/topicmanager/topic_manager_mock.go -package topicmanager
"$MOCKGEN" -source pkg/keyspace/keyspace_manager.go -destination pkg/keyspace/keyspace_manager_mock.go -package keyspace
"$MOCKGEN" -source pkg/txnutil/gc/gc_manager.go -destination pkg/txnutil/gc/gc_manager_mock.go -package gc
"$MOCKGEN" -source pkg/txnutil/gc/gc_client.go -destination pkg/txnutil/gc/gc_client_mock.go -package gc
Expand Down
Loading