Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cassandra auth parameters parsing #3872

Merged
merged 1 commit into from
Nov 30, 2022
Merged
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
6 changes: 5 additions & 1 deletion src/wpool/mongoose_wpool_cassandra.erl
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
-export([start/4]).
-export([stop/2]).

-ifdef(TEST).
-export([prepare_cqerl_opts/1]).
-endif.

%% --------------------------------------------------------------
%% mongoose_wpool callbacks
-spec init() -> ok.
@@ -50,7 +54,7 @@ prepare_cqerl_opts(ConnOpts) ->
cqerl_opts(keyspace, #{keyspace := Keyspace}) ->
[{keyspace, Keyspace}];
cqerl_opts(auth, #{auth := #{plain := #{username := UserName, password := Password}}}) ->
[{cqerl_auth_plain_handler, [{UserName, Password}]}];
[{auth, {cqerl_auth_plain_handler, [{UserName, Password}]}}];
cqerl_opts(tcp, #{}) ->
[{tcp_opts, [{keepalive, true}]}]; % always set
cqerl_opts(tls, #{tls := TLSOpts}) ->
10 changes: 9 additions & 1 deletion test/mongoose_wpool_SUITE.erl
Original file line number Diff line number Diff line change
@@ -39,7 +39,8 @@ all() ->
dead_pool_is_restarted,
dead_pool_is_stopped_before_restarted,
riak_pool_cant_be_started_with_available_worker_strategy,
redis_pool_cant_be_started_with_available_worker_strategy
redis_pool_cant_be_started_with_available_worker_strategy,
cassandra_prepare_opts
].

%%--------------------------------------------------------------------
@@ -269,6 +270,13 @@ pool_cant_be_started_with_available_worker_strategy(Type) ->
?assertError({strategy_not_supported, Type, Host, Tag, available_worker},
mongoose_wpool:start_configured_pools(PoolDef)).

cassandra_prepare_opts(_Config) ->
%% Check that we pass auth options in the correct format to the Cassandra driver
AuthCfg = #{auth => #{plain => #{username => <<"user">>, password => <<"password">>}}},
?assertEqual([{auth, {cqerl_auth_plain_handler, [{<<"user">>, <<"password">>}]}},
{tcp_opts, [{keepalive, true}]}],
mongoose_wpool_cassandra:prepare_cqerl_opts(AuthCfg)).

%%--------------------------------------------------------------------
%% Helpers
%%--------------------------------------------------------------------