From 5106470900feda91dca1ab81c9b9c218b64ec990 Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Wed, 3 Jan 2024 16:48:29 +0100 Subject: [PATCH] Add test for filename-based sasl config --- test/brod_client_test.exs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/brod_client_test.exs b/test/brod_client_test.exs index 121ad05..8419d5b 100644 --- a/test/brod_client_test.exs +++ b/test/brod_client_test.exs @@ -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"}) @@ -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 @@ -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 [ %{ @@ -414,8 +422,7 @@ defmodule BroadwayKafka.BrodClientTest do %{ shared_client: false, shared_client_id: nil - }} = - BrodClient.init(opts) + }} = BrodClient.init(opts) end end