Skip to content

Commit

Permalink
Add test for filename-based sasl config
Browse files Browse the repository at this point in the history
  • Loading branch information
rewritten committed Jan 3, 2024
1 parent e82455c commit 5106470
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions test/brod_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ defmodule BroadwayKafka.BrodClientTest do

assert BrodClient.init(opts) ==
{:error,
"expected :sasl to be a tuple of SASL mechanism, username and password, got: :an_atom"}
"expected :sasl to be a tuple of SASL mechanism, username and password, or mechanism and path, got: :an_atom"}

opts = put_in(@opts, [:client_config, :sasl], {:an_atom, "username", "password"})

assert BrodClient.init(opts) ==
{:error,
"expected :sasl to be a tuple of SASL mechanism, username and password, got: {:an_atom, \"username\", \"password\"}"}
"expected :sasl to be a tuple of SASL mechanism, username and password, or mechanism and path, got: {:an_atom, \"username\", \"password\"}"}

opts = put_in(@opts, [:client_config, :sasl], {:plain, "username", "password"})

Expand All @@ -273,6 +273,15 @@ defmodule BroadwayKafka.BrodClientTest do
sasl: {:plain, "username", "password"}
]
}} = BrodClient.init(opts)

opts = put_in(@opts, [:client_config, :sasl], {:plain, "filepath"})

assert {:ok, [],
%{
client_config: [
sasl: {:plain, "filepath"}
]
}} = BrodClient.init(opts)
end

test ":sasl is an optional tuple of :callback, SASL Authentication Plugin module and opts" do
Expand Down Expand Up @@ -390,8 +399,7 @@ defmodule BroadwayKafka.BrodClientTest do
%{
shared_client: true,
shared_client_id: :"my_prefix.Elixir.my_broadway_name.SharedClient"
}} =
BrodClient.init(opts)
}} = BrodClient.init(opts)

assert [
%{
Expand All @@ -414,8 +422,7 @@ defmodule BroadwayKafka.BrodClientTest do
%{
shared_client: false,
shared_client_id: nil
}} =
BrodClient.init(opts)
}} = BrodClient.init(opts)
end
end

Expand Down

0 comments on commit 5106470

Please sign in to comment.