Skip to content

Commit

Permalink
Replace global config with local config in big tests
Browse files Browse the repository at this point in the history
Use the new helper in muc_SUITE
  • Loading branch information
chrzaszcz committed Oct 15, 2021
1 parent 568788f commit a3e0576
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ allow_everyone_registration() ->

change_registration_settings_for_everyone(Rule)
when allow =:= Rule; deny =:= Rule ->
{atomic,ok} = rpc(mim(), ejabberd_config, add_global_option,
{atomic,ok} = rpc(mim(), ejabberd_config, add_local_option,
[{access, register, global}, [{Rule, all}]]),
ok.

Expand Down
5 changes: 2 additions & 3 deletions big_tests/tests/login_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,10 @@ do_verify_format(_, Password, SPassword) ->
set_acl_for_blocking(Spec) ->
User = proplists:get_value(username, Spec),
LUser = jid:nodeprep(User),
rpc(mim(), ejabberd_config, add_global_option, [{acl, blocked, host_type()}, [{user, LUser}]]).
rpc(mim(), ejabberd_config, add_local_option, [{acl, blocked, host_type()}, [{user, LUser}]]).

unset_acl_for_blocking() ->
%% There is no del_global_option
rpc(mim(), mnesia, dirty_delete, [config, {acl, blocked, host_type()}]).
rpc(mim(), ejabberd_config, del_local_option, [{acl, blocked, host_type()}]).

configure_and_log_scram(Config, Sha, Mech) ->
mongoose_helper:set_store_password({scram, [Sha]}),
Expand Down
16 changes: 8 additions & 8 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,15 @@ restore_shaping(Config) ->
Config.

get_shaper() ->
Mam = rpc_apply(ejabberd_config, get_global_option, [{shaper, mam_shaper, global}]),
Norm = rpc_apply(ejabberd_config, get_global_option, [{shaper, normal, global}]),
Fast = rpc_apply(ejabberd_config, get_global_option, [{shaper, fast, global}]),
Mam = rpc_apply(ejabberd_config, get_local_option, [{shaper, mam_shaper, global}]),
Norm = rpc_apply(ejabberd_config, get_local_option, [{shaper, normal, global}]),
Fast = rpc_apply(ejabberd_config, get_local_option, [{shaper, fast, global}]),
{Mam, Norm, Fast}.

set_shaper({Mam, Norm, Fast}) ->
rpc_apply(ejabberd_config, add_global_option, [{shaper, mam_shaper, global}, Mam]),
rpc_apply(ejabberd_config, add_global_option, [{shaper, normal, global}, Norm]),
rpc_apply(ejabberd_config, add_global_option, [{shaper, fast, global}, Fast]),
rpc_apply(ejabberd_config, add_local_option, [{shaper, mam_shaper, global}, Mam]),
rpc_apply(ejabberd_config, add_local_option, [{shaper, normal, global}, Norm]),
rpc_apply(ejabberd_config, add_local_option, [{shaper, fast, global}, Fast]),
rpc_apply(shaper_srv, reset_all_shapers, [host_type()]).

disable_sessions_limit(Config) ->
Expand All @@ -576,10 +576,10 @@ restore_sessions_limit(Config) ->
Config.

get_sessions_limit() ->
rpc_apply(ejabberd_config, get_global_option, [{access, max_user_sessions, global}]).
rpc_apply(ejabberd_config, get_local_option, [{access, max_user_sessions, global}]).

set_sessions_limit(NewLimit) ->
rpc_apply(ejabberd_config, add_global_option,
rpc_apply(ejabberd_config, add_local_option,
[{access, max_user_sessions, global}, NewLimit]).

init_per_group(mam04, Config) ->
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mnesia_or_rdbms_backend() ->

-spec auth_modules() -> [atom()].
auth_modules() ->
Hosts = rpc(mim(), ejabberd_config, get_global_option, [hosts]),
Hosts = rpc(mim(), ejabberd_config, get_local_option, [hosts]),
lists:flatmap(
fun(Host) ->
rpc(mim(), ejabberd_auth, auth_modules, [Host])
Expand Down
18 changes: 10 additions & 8 deletions big_tests/tests/muc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@

-import(domain_helper, [host_type/0, domain/0]).

-define(MUC_CLIENT_HOST, <<"localhost/res1">>).
-import(mongoose_helper, [backup_and_set_config_option/3, restore_config_option/2]).

-define(PASSWORD, <<"pa5sw0rd">>).
-define(SUBJECT, <<"subject">>).
-define(WAIT_TIME, 1500).
Expand Down Expand Up @@ -398,6 +399,9 @@ init_per_group(register_over_s2s, Config) ->
[{_,AliceSpec2}|Others] = escalus:get_users([alice2, bob, kate]),
Users = [{alice,AliceSpec2}|Others],
escalus:create_users(Config2, Users);
init_per_group(owner_no_parallel, Config) ->
Config1 = backup_and_set_config_option(Config, {access, muc_create, global}, [{deny, all}]),
escalus:create_users(Config1, escalus:get_users([alice, bob, kate]));
init_per_group(_GroupName, Config) ->
escalus:create_users(Config, escalus:get_users([alice, bob, kate])).

Expand Down Expand Up @@ -461,6 +465,8 @@ end_per_group(hibernation, Config) ->
end_per_group(register_over_s2s, Config) ->
s2s_helper:end_s2s(Config),
escalus:delete_users(Config, escalus:get_users([alice2, bob, kate]));
end_per_group(owner_no_parallel, Config) ->
restore_config_option(Config, {access, muc_create, global});
end_per_group(_GroupName, Config) ->
escalus:delete_users(Config, escalus:get_users([alice, bob, kate])).

Expand Down Expand Up @@ -2996,13 +3002,9 @@ create_and_destroy_room_multiple_x_elements(Config) ->
%% ejabberd returns 'forbidden' while it ought to return 'not-allowed'.
room_creation_not_allowed(Config) ->
escalus:story(Config, [{alice, 1}], fun(Alice) ->
escalus_ejabberd:with_global_option({access,muc_create,global},
[{deny,all}], fun() ->
escalus:send(Alice, stanza_enter_room(<<"room1">>, <<"nick1">>)),
escalus:assert(is_error, [<<"cancel">>, <<"not-allowed">>],
escalus:wait_for_stanza(Alice))

end)
escalus:send(Alice, stanza_enter_room(<<"room1">>, <<"nick1">>)),
escalus:assert(is_error, [<<"cancel">>, <<"not-allowed">>],
escalus:wait_for_stanza(Alice))
end).

%% Fails.
Expand Down
9 changes: 1 addition & 8 deletions big_tests/tests/users_api_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
require_rpc_nodes/1,
rpc/4]).
-import(rest_helper, [assert_status/2, simple_request/2, simple_request/3, simple_request/4]).

-import(domain_helper, [domain/0]).
-import(mongoose_helper, [auth_modules/0]).

-define(DOMAIN, (domain())).
-define(PORT, (ct:get_config({hosts, mim, metrics_rest_port}))).
Expand Down Expand Up @@ -140,13 +140,6 @@ is_external_auth() ->
is_riak_auth() ->
lists:member(ejabberd_auth_riak, auth_modules()).

auth_modules() ->
Hosts = rpc(mim(), ejabberd_config, get_global_option, [hosts]),
lists:flatmap(
fun(Host) ->
rpc(mim(), ejabberd_auth, auth_modules, [Host])
end, Hosts).

wait_for_user_removal(false) ->
ok;
wait_for_user_removal(_) ->
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/vcard_update.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ is_mongooseim() ->

-spec try_ejabberd_v2() -> no_return().
try_ejabberd_v2() ->
[{config, hosts, [XMPPDomain | _]}] = rpc(mim(), ets, lookup, [config, hosts]),
[{local_config, hosts, [XMPPDomain | _]}] = rpc(mim(), ets, lookup, [local_config, hosts]),
case XMPPDomain of
BString when is_binary(BString) ->
throw(binary);
Expand Down

0 comments on commit a3e0576

Please sign in to comment.