diff --git a/src/wpool/mongoose_wpool_cassandra.erl b/src/wpool/mongoose_wpool_cassandra.erl index 1832f6de6b6..68b8ff4a449 100644 --- a/src/wpool/mongoose_wpool_cassandra.erl +++ b/src/wpool/mongoose_wpool_cassandra.erl @@ -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}) -> diff --git a/test/mongoose_wpool_SUITE.erl b/test/mongoose_wpool_SUITE.erl index f85a4ceae82..559945c3631 100644 --- a/test/mongoose_wpool_SUITE.erl +++ b/test/mongoose_wpool_SUITE.erl @@ -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 %%--------------------------------------------------------------------