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

Add support for dynamic domains in mod_register #3247

Merged
merged 5 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
%% http://www.erlang.org/doc/apps/common_test/run_test_chapter.html#test_specifications
{include, "tests"}.

{suites, "tests", accounts_SUITE}.

{suites, "tests", acc_e2e_SUITE}.

{suites, "tests", carboncopy_SUITE}.
Expand Down
25 changes: 13 additions & 12 deletions big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ all() ->
].

groups() ->
G = [{register, [parallel], [register,
[{register, [parallel], [register,
already_registered,
registration_conflict,
check_unregistered]},
Expand All @@ -52,8 +52,7 @@ groups() ->
count_users,
count_selected_users]},
{users_number_estimate, [], [count_users_estimate]}
],
Premwoik marked this conversation as resolved.
Show resolved Hide resolved
ct_helper:repeat_all_until_all_ok(G).
].

suite() ->
require_rpc_nodes([mim]) ++ escalus:suite().
Expand All @@ -66,8 +65,7 @@ change_password_tests() ->
%%--------------------------------------------------------------------

init_per_suite(Config1) ->
Host = ct:get_config({hosts, mim, domain}),
ok = dynamic_modules:ensure_modules(Host, required_modules()),
ok = dynamic_modules:ensure_modules(host_type(), required_modules()),
Config2 = [{mod_register_options, mod_register_options()} | Config1],
escalus:init_per_suite([{escalus_user_db, xmpp} | Config2]).

Expand All @@ -91,7 +89,7 @@ init_per_group(change_account_details, Config) ->
[{escalus_user_db, {module, escalus_ejabberd}} |Config];
init_per_group(change_account_details_store_plain, Config) ->
Config1 = mongoose_helper:backup_auth_config(Config),
mongoose_helper:set_store_password(plain),
mongoose_helper:set_store_password(host_type(), plain),
[{escalus_user_db, {module, escalus_ejabberd}} |Config1];
init_per_group(registration_timeout, Config) ->
set_registration_timeout(Config);
Expand Down Expand Up @@ -126,12 +124,12 @@ end_per_group(_GroupName, Config) ->
Config.

get_auth_opts() ->
rpc(mim(), ejabberd_config, get_local_option, [{auth_opts, domain()}]).
rpc(mim(), ejabberd_config, get_local_option, [{auth_opts, host_type()}]).

set_auth_opts(AuthOpts) ->
rpc(mim(), ejabberd_auth, stop, [domain()]),
rpc(mim(), ejabberd_config, add_local_option, [{auth_opts, domain()}, AuthOpts]),
rpc(mim(), ejabberd_auth, start, [domain()]).
rpc(mim(), ejabberd_auth, stop, [host_type()]),
rpc(mim(), ejabberd_config, add_local_option, [{auth_opts, host_type()}, AuthOpts]),
rpc(mim(), ejabberd_auth, start, [host_type()]).

init_per_testcase(admin_notify, Config) ->
[{_, AdminSpec}] = escalus_users:get_users([admin]),
Expand Down Expand Up @@ -445,13 +443,13 @@ user_exists(Name, Config) ->
rpc(mim(), ejabberd_auth, does_user_exist, [mongoose_helper:make_jid(Username, Server)]).

reload_mod_register_option(Config, Key, Value) ->
Host = domain(),
Host = host_type(),
Args = proplists:get_value(mod_register_options, Config),
Args1 = lists:keyreplace(Key, 1, Args, {Key, Value}),
dynamic_modules:restart(Host, mod_register, Args1).

restore_mod_register_options(Config) ->
Host = domain(),
Host = host_type(),
Args = proplists:get_value(mod_register_options, Config),
dynamic_modules:restart(Host, mod_register, Args).

Expand All @@ -461,5 +459,8 @@ enable_watcher(Config, Watcher) ->
disable_watcher(Config) ->
restore_mod_register_options(Config).

host_type() ->
domain_helper:host_type(mim).

domain() ->
ct:get_config({hosts, mim, domain}).
5 changes: 5 additions & 0 deletions big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
-export([backup_sasl_mechanisms_config/1, restore_sasl_mechanisms_config/1]).
-export([set_sasl_mechanisms/2]).
-export([set_store_password/1]).
-export([set_store_password/2]).
-export([get_listener_opts/2]).
-export([restart_listener_with_opts/3]).
-export([should_minio_be_running/1]).
Expand Down Expand Up @@ -478,6 +479,10 @@ restore_sasl_mechanisms_config(Config) ->
set_sasl_mechanisms(GlobalOrHostSASLMechanisms, Mechanisms) ->
rpc(mim(), ejabberd_config, add_local_option, [GlobalOrHostSASLMechanisms, Mechanisms]).

set_store_password(HostType, Type) ->
Premwoik marked this conversation as resolved.
Show resolved Hide resolved
AuthOpts = rpc(mim(), ejabberd_config, get_local_option, [{auth_opts, HostType}]),
NewAuthOpts = build_new_auth_opts(Type, AuthOpts),
rpc(mim(), ejabberd_config, add_local_option, [{auth_opts, HostType}, NewAuthOpts]).

set_store_password(Type) ->
XMPPDomain = escalus_ejabberd:unify_str_arg(
Expand Down
4 changes: 4 additions & 0 deletions rel/mim1.vars-toml.config
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

[host_config.modules.mod_disco]

{{#mod_register}}
[host_config.modules.mod_register]
{{{mod_register}}}
{{/mod_register}}
Premwoik marked this conversation as resolved.
Show resolved Hide resolved
{{#mod_last}}
[host_config.modules.mod_last]
{{{mod_last}}}
Expand Down
Loading