Path: blob/main/component/loki/source/kafka/kafka_test.go
4096 views
package kafka12import (3"testing"45"github.com/grafana/agent/pkg/river"6"github.com/stretchr/testify/require"7)89func TestRiverConfig(t *testing.T) {10var exampleRiverConfig = `11brokers = ["localhost:9092","localhost:23456"]12topics = ["quickstart-events"]13labels = {component = "loki.source.kafka"}14forward_to = []15use_incoming_timestamp = true16`1718var args Arguments19err := river.Unmarshal([]byte(exampleRiverConfig), &args)20require.NoError(t, err)21}2223func TestTLSRiverConfig(t *testing.T) {24var exampleRiverConfig = `25brokers = ["localhost:9092","localhost:23456"]26topics = ["quickstart-events"]27authentication {28type = "ssl"29tls_config {30cert_file = "/fake/file.cert"31key_file = "/fake/file.key"32}33}34labels = {component = "loki.source.kafka"}35forward_to = []36`3738var args Arguments39err := river.Unmarshal([]byte(exampleRiverConfig), &args)40require.NoError(t, err)41}4243func TestSASLRiverConfig(t *testing.T) {44var exampleRiverConfig = `45brokers = ["localhost:9092","localhost:23456"]46topics = ["quickstart-events"]47authentication {48type = "sasl"49sasl_config {50user = "user"51password = "password"52}53}54labels = {component = "loki.source.kafka"}55forward_to = []56`5758var args Arguments59err := river.Unmarshal([]byte(exampleRiverConfig), &args)60require.NoError(t, err)61}6263func TestSASLOAuthRiverConfig(t *testing.T) {64var exampleRiverConfig = `65brokers = ["localhost:9092", "localhost:23456"]66topics = ["quickstart-events"]6768authentication {69type = "sasl"70sasl_config {71mechanism = "OAUTHBEARER"72oauth_config {73token_provider = "azure"74scopes = ["my-scope"]75}76}77}78labels = {component = "loki.source.kafka"}79forward_to = []80`8182var args Arguments83err := river.Unmarshal([]byte(exampleRiverConfig), &args)84require.NoError(t, err)85}868788