Skip to content

Commit

Permalink
Merge pull request #3247 from esl/add-dynamic-domains-support-in-mod_…
Browse files Browse the repository at this point in the history
…register

Add support for dynamic domains in mod_register
  • Loading branch information
vkatsuba committed Sep 8, 2021
2 parents cdfd7b9 + 8cbc2c2 commit 649590d
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 118 deletions.
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
59 changes: 30 additions & 29 deletions big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,26 @@ all() ->
].

groups() ->
G = [{register, [parallel], [register,
already_registered,
registration_conflict,
check_unregistered]},
{registration_watchers, [sequence], [admin_notify]},
{bad_registration, [sequence], [null_password]},
{bad_cancelation, [sequence], [bad_request_registration_cancelation,
not_allowed_registration_cancelation]},
{registration_timeout, [sequence], [registration_timeout,
registration_failure_timeout]},
{change_account_details, [parallel], change_password_tests()},
{change_account_details_store_plain, [parallel], change_password_tests()},
{utilities, [{group, user_info},
{group, users_number_estimate}]},
{user_info, [parallel], [list_users,
list_selected_users,
count_users,
count_selected_users]},
{users_number_estimate, [], [count_users_estimate]}
],
ct_helper:repeat_all_until_all_ok(G).
[{register, [parallel], [register,
already_registered,
registration_conflict,
check_unregistered]},
{registration_watchers, [sequence], [admin_notify]},
{bad_registration, [sequence], [null_password]},
{bad_cancelation, [sequence], [bad_request_registration_cancelation,
not_allowed_registration_cancelation]},
{registration_timeout, [sequence], [registration_timeout,
registration_failure_timeout]},
{change_account_details, [parallel], change_password_tests()},
{change_account_details_store_plain, [parallel], change_password_tests()},
{utilities, [{group, user_info},
{group, users_number_estimate}]},
{user_info, [parallel], [list_users,
list_selected_users,
count_users,
count_selected_users]},
{users_number_estimate, [], [count_users_estimate]}
].

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 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}).
8 changes: 3 additions & 5 deletions big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,11 @@ restore_sasl_mechanisms_config(Config) ->
set_sasl_mechanisms(GlobalOrHostSASLMechanisms, Mechanisms) ->
rpc(mim(), ejabberd_config, add_local_option, [GlobalOrHostSASLMechanisms, Mechanisms]).


set_store_password(Type) ->
XMPPDomain = escalus_ejabberd:unify_str_arg(
ct:get_config({hosts, mim, domain})),
AuthOpts = rpc(mim(), ejabberd_config, get_local_option, [{auth_opts, XMPPDomain}]),
HostType = domain_helper:host_type(mim),
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, XMPPDomain}, NewAuthOpts]).
rpc(mim(), ejabberd_config, add_local_option, [{auth_opts, HostType}, NewAuthOpts]).

build_new_auth_opts(scram, AuthOpts) ->
NewAuthOpts0 = lists:keystore(password_format, 1, AuthOpts, {password_format, scram}),
Expand Down
2 changes: 2 additions & 0 deletions rel/mim1.vars-toml.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

[host_config.modules.mod_disco]

[host_config.modules.mod_register]

{{#mod_last}}
[host_config.modules.mod_last]
{{{mod_last}}}
Expand Down
Loading

0 comments on commit 649590d

Please sign in to comment.