From a3e0576ac0a7c73cf43ae92918c04f920e1ffe2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 14 Oct 2021 14:52:22 +0200 Subject: [PATCH] Replace global config with local config in big tests Use the new helper in muc_SUITE --- big_tests/tests/accounts_SUITE.erl | 2 +- big_tests/tests/login_SUITE.erl | 5 ++--- big_tests/tests/mam_SUITE.erl | 16 ++++++++-------- big_tests/tests/mongoose_helper.erl | 2 +- big_tests/tests/muc_SUITE.erl | 18 ++++++++++-------- big_tests/tests/users_api_SUITE.erl | 9 +-------- big_tests/tests/vcard_update.erl | 2 +- 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/big_tests/tests/accounts_SUITE.erl b/big_tests/tests/accounts_SUITE.erl index 95ed81f1500..f13695f2fab 100644 --- a/big_tests/tests/accounts_SUITE.erl +++ b/big_tests/tests/accounts_SUITE.erl @@ -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. diff --git a/big_tests/tests/login_SUITE.erl b/big_tests/tests/login_SUITE.erl index abe4958750f..699141fe2dc 100644 --- a/big_tests/tests/login_SUITE.erl +++ b/big_tests/tests/login_SUITE.erl @@ -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]}), diff --git a/big_tests/tests/mam_SUITE.erl b/big_tests/tests/mam_SUITE.erl index 51d8f8e10cc..5bf5d78c9c1 100644 --- a/big_tests/tests/mam_SUITE.erl +++ b/big_tests/tests/mam_SUITE.erl @@ -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) -> @@ -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) -> diff --git a/big_tests/tests/mongoose_helper.erl b/big_tests/tests/mongoose_helper.erl index 2cc1ba9f673..8c2046a204d 100644 --- a/big_tests/tests/mongoose_helper.erl +++ b/big_tests/tests/mongoose_helper.erl @@ -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]) diff --git a/big_tests/tests/muc_SUITE.erl b/big_tests/tests/muc_SUITE.erl index dcd25494109..63bcd95f5e8 100644 --- a/big_tests/tests/muc_SUITE.erl +++ b/big_tests/tests/muc_SUITE.erl @@ -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). @@ -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])). @@ -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])). @@ -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. diff --git a/big_tests/tests/users_api_SUITE.erl b/big_tests/tests/users_api_SUITE.erl index 7adde08a8ac..9c3599217ec 100644 --- a/big_tests/tests/users_api_SUITE.erl +++ b/big_tests/tests/users_api_SUITE.erl @@ -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}))). @@ -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(_) -> diff --git a/big_tests/tests/vcard_update.erl b/big_tests/tests/vcard_update.erl index ee70ee44111..f37b95ef9ba 100644 --- a/big_tests/tests/vcard_update.erl +++ b/big_tests/tests/vcard_update.erl @@ -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);