From 23d6a4c80aa466fe3cf25115150d6c42fc5d9f87 Mon Sep 17 00:00:00 2001 From: Gustaw Lippa Date: Mon, 14 Feb 2022 15:50:02 +0100 Subject: [PATCH] Add defaults for LDAP connection opts in config --- src/config/mongoose_config_spec.erl | 8 +++++++- test/config_parser_helper.erl | 22 +++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/config/mongoose_config_spec.erl b/src/config/mongoose_config_spec.erl index f52c769345..ef2da75277 100644 --- a/src/config/mongoose_config_spec.erl +++ b/src/config/mongoose_config_spec.erl @@ -613,7 +613,13 @@ outgoing_pool_connection(<<"ldap">>) -> wrap = {kv, tls_options}, process = fun ?MODULE:process_tls_sni/1} }, - format_items = map + format_items = map, + include = always, + defaults = #{<<"rootdn">> => "", + <<"password">> => "", + <<"encrypt">> => none, + <<"servers">> => ["localhost"], + <<"connect_interval">> => 10000} }; outgoing_pool_connection(<<"rabbit">>) -> #section{ diff --git a/test/config_parser_helper.erl b/test/config_parser_helper.erl index ea7efc662e..9a6707a048 100644 --- a/test/config_parser_helper.erl +++ b/test/config_parser_helper.erl @@ -753,20 +753,32 @@ pgsql_access() -> register => [#{acl => all, value => allow}], s2s_shaper => [#{acl => all, value => fast}]}. -merge_with_default_pool_config(PoolIn) -> - DefaultConfig = #{opts := DefaultOpts} = default_pool_config(), +merge_with_default_pool_config(PoolIn = #{type := Type}) -> + DefaultConfig = #{opts := DefaultOpts, conn_opts := DefaultConnOpts} = default_pool_config(Type), WpoolOptsWithDefaults = maps:merge(DefaultOpts, maps:get(opts, PoolIn, #{})), - maps:merge(DefaultConfig, PoolIn#{opts => WpoolOptsWithDefaults}). + ConnOptsWithDefaults = maps:merge(DefaultConnOpts, maps:get(conn_opts, PoolIn, #{})), + maps:merge(DefaultConfig, PoolIn#{opts => WpoolOptsWithDefaults, + conn_opts => ConnOptsWithDefaults}). -default_pool_config() -> +default_pool_config(Type) -> #{scope => global, - opts => default_pool_wpool_opts()}. + opts => default_pool_wpool_opts(), + conn_opts => default_pool_conn_opts(Type)}. default_pool_wpool_opts() -> #{workers => 10, strategy => best_worker, call_timeout => 5000}. +default_pool_conn_opts(ldap) -> + #{rootdn => "", + password => "", + encrypt => none, + servers => ["localhost"], + connect_interval => 10000}; +default_pool_conn_opts(Type) -> + #{}. + default_mod_config(mod_adhoc) -> #{iqdisc => one_queue, report_commands_node => false};