diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index d5e3631961a..7fe4cc1b1db 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -50,6 +50,8 @@ {suites, "tests", offline_stub_SUITE}. +{suites, "tests", domain_isolation_SUITE}. + {suites, "tests", sm_SUITE}. {skip_cases, "tests", sm_SUITE, [basic_ack, diff --git a/doc/modules/mod_domain_isolation.md b/doc/modules/mod_domain_isolation.md index ce6f4135133..4535188d579 100644 --- a/doc/modules/mod_domain_isolation.md +++ b/doc/modules/mod_domain_isolation.md @@ -1,14 +1,3 @@ ## Module Description This module limits message passing between domains. - -## Options - -### `modules.mod_domain_isolation.extra_domains` - -Allows to specify more domains, the rules are applied to. -No filtering is done to subdomains, unless they are specified in the `extra_domains` list. - - * **Syntax:** a list of domain templates (as lists) - * **Default:** `[]` - * **Example:** `extra_domains = ["muclight.@HOST@"]` diff --git a/include/mongoose.hrl b/include/mongoose.hrl index 954df5b2cdc..519929350fd 100644 --- a/include/mongoose.hrl +++ b/include/mongoose.hrl @@ -22,7 +22,7 @@ %% If the ejabberd application description isn't loaded, returns atom: undefined -define(MONGOOSE_VERSION, element(2, application:get_key(mongooseim,vsn))). --define(MYHOSTS, ejabberd_config:get_global_option(hosts)). +-define(MYHOSTS, ejabberd_config:get_global_option_or_default(hosts, [])). -define(ALL_HOST_TYPES, ejabberd_config:get_global_option_or_default(hosts, []) ++ ejabberd_config:get_global_option_or_default(host_types, [])). -define(MYNAME, ejabberd_config:get_global_option(default_server_domain)). diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 7299c553737..0e705df5591 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -140,6 +140,7 @@ start_module_for_host_type(HostType, Module, Opts0) -> try lists:map(fun mongoose_service:assert_loaded/1, get_required_services(HostType, Module, Opts)), + check_dynamic_domains_support(HostType, Module), Res = Module:start(HostType, Opts), {links, LinksAfter} = erlang:process_info(self(), links), case lists:sort(LinksBefore) =:= lists:sort(LinksAfter) of @@ -186,6 +187,17 @@ start_module_for_host_type(HostType, Module, Opts0) -> end end. +check_dynamic_domains_support(HostType, Module) -> + case lists:member(HostType, ?MYHOSTS) of + true -> ok; + false -> + case gen_mod:does_module_support(Module, dynamic_domains) of + true -> ok; + false -> + error({Module, HostType, dynamic_domains_feature_is_not_supported}) + end + end. + is_mim_or_ct_running() -> ?MODULE:is_app_running(mongooseim) %% Common tests would be very confused if we kill the whole node diff --git a/src/mam/mod_mam.erl b/src/mam/mod_mam.erl index 1a8310cd679..a7d4c7783e8 100644 --- a/src/mam/mod_mam.erl +++ b/src/mam/mod_mam.erl @@ -42,7 +42,7 @@ archive_id/2]). %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% ejabberd handlers -export([disco_local_features/1, @@ -211,6 +211,10 @@ stop(HostType) -> remove_iq_handlers(HostType), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + %% ---------------------------------------------------------------------- %% hooks and handlers diff --git a/src/mam/mod_mam_cache_user.erl b/src/mam/mod_mam_cache_user.erl index a6613449c69..8c01bb3b138 100644 --- a/src/mam/mod_mam_cache_user.erl +++ b/src/mam/mod_mam_cache_user.erl @@ -17,7 +17,7 @@ -behaviour(mongoose_module_metrics). %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% ejabberd handlers -export([cached_archive_id/3, @@ -55,7 +55,6 @@ su_key(#jid{lserver = LServer, luser = LUser}) -> %% ---------------------------------------------------------------------- %% gen_mod callbacks %% Starting and stopping functions for users' archives - -spec start(HostType :: mongooseim:host_type(), Opts :: gen_mod:module_opts()) -> ok. start(HostType, _Opts) -> start_server(), @@ -67,6 +66,10 @@ stop(HostType) -> ejabberd_hooks:delete(hooks(HostType)), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + writer_child_spec() -> MFA = {?MODULE, start_link, []}, {?MODULE, MFA, permanent, 5000, worker, [?MODULE]}. diff --git a/src/mam/mod_mam_meta.erl b/src/mam/mod_mam_meta.erl index f0b97614cb7..a73b60aad60 100644 --- a/src/mam/mod_mam_meta.erl +++ b/src/mam/mod_mam_meta.erl @@ -20,7 +20,7 @@ -type deps() :: #{module() => proplists:proplist()}. --export([start/2, stop/1, config_spec/0, +-export([start/2, stop/1, config_spec/0, supported_features/0, deps/2, get_mam_module_configuration/3, get_mam_module_opt/4]). -export([config_metrics/1]). @@ -31,6 +31,10 @@ %% API %%-------------------------------------------------------------------- +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + -spec start(Host :: jid:server(), Opts :: list()) -> any(). start(_Host, _Opts) -> ok. diff --git a/src/mam/mod_mam_mnesia_prefs.erl b/src/mam/mod_mam_mnesia_prefs.erl index 85d6093642f..bd4e55f3f80 100644 --- a/src/mam/mod_mam_mnesia_prefs.erl +++ b/src/mam/mod_mam_mnesia_prefs.erl @@ -13,7 +13,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_prefs). @@ -73,6 +73,9 @@ stop(Host) -> ok end. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. %% ---------------------------------------------------------------------- %% Add hooks for mod_mam diff --git a/src/mam/mod_mam_muc.erl b/src/mam/mod_mam_muc.erl index 27c85b15ef6..0a876c6b265 100644 --- a/src/mam/mod_mam_muc.erl +++ b/src/mam/mod_mam_muc.erl @@ -40,7 +40,7 @@ archive_id/2]). %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% ejabberd room handlers -export([disco_muc_features/1, @@ -158,6 +158,10 @@ stop(HostType) -> remove_iq_handlers(HostType), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + %% ---------------------------------------------------------------------- %% hooks and handlers for MUC diff --git a/src/mam/mod_mam_muc_cache_user.erl b/src/mam/mod_mam_muc_cache_user.erl index a3d9bb313ff..6928e58d9da 100644 --- a/src/mam/mod_mam_muc_cache_user.erl +++ b/src/mam/mod_mam_muc_cache_user.erl @@ -1,7 +1,7 @@ -module(mod_mam_muc_cache_user). %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% ejabberd handlers -export([cached_archive_id/3, @@ -49,6 +49,10 @@ stop(HostType) -> clean_mnesia(HostType), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + %% ---------------------------------------------------------------------- %% Init diff --git a/src/mam/mod_mam_muc_rdbms_arch.erl b/src/mam/mod_mam_muc_rdbms_arch.erl index 3cedc1986d7..ae39066760e 100644 --- a/src/mam/mod_mam_muc_rdbms_arch.erl +++ b/src/mam/mod_mam_muc_rdbms_arch.erl @@ -10,7 +10,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_archive). @@ -61,6 +61,10 @@ start(HostType, _Opts) -> stop(HostType) -> stop_hooks(HostType). +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + -spec get_mam_muc_gdpr_data(ejabberd_gen_mam_archive:mam_pm_gdpr_data(), host_type(), jid:jid()) -> ejabberd_gen_mam_archive:mam_muc_gdpr_data(). diff --git a/src/mam/mod_mam_muc_rdbms_async_pool_writer.erl b/src/mam/mod_mam_muc_rdbms_async_pool_writer.erl index 30d5f30d4e3..d3f040e3e10 100644 --- a/src/mam/mod_mam_muc_rdbms_async_pool_writer.erl +++ b/src/mam/mod_mam_muc_rdbms_async_pool_writer.erl @@ -10,7 +10,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_archive). @@ -95,6 +95,10 @@ stop(HostType) -> stop_muc(HostType), stop_workers(HostType). +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + %% ---------------------------------------------------------------------- %% Add hooks for mod_mam_muc diff --git a/src/mam/mod_mam_rdbms_arch.erl b/src/mam/mod_mam_rdbms_arch.erl index 552b8c10ccc..dce7cc3129e 100644 --- a/src/mam/mod_mam_rdbms_arch.erl +++ b/src/mam/mod_mam_rdbms_arch.erl @@ -10,7 +10,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_archive). @@ -76,6 +76,10 @@ start(HostType, Opts) -> stop(HostType) -> stop_hooks(HostType). +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + -spec get_mam_pm_gdpr_data(ejabberd_gen_mam_archive:mam_pm_gdpr_data(), host_type(), jid:jid()) -> ejabberd_gen_mam_archive:mam_pm_gdpr_data(). diff --git a/src/mam/mod_mam_rdbms_async_pool_writer.erl b/src/mam/mod_mam_rdbms_async_pool_writer.erl index 28edaacb457..d9172def561 100644 --- a/src/mam/mod_mam_rdbms_async_pool_writer.erl +++ b/src/mam/mod_mam_rdbms_async_pool_writer.erl @@ -21,7 +21,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_archive). @@ -119,6 +119,10 @@ stop(HostType) -> end, stop_workers(HostType). +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + %% ---------------------------------------------------------------------- %% Add hooks for mod_mam diff --git a/src/mam/mod_mam_rdbms_prefs.erl b/src/mam/mod_mam_rdbms_prefs.erl index 420a990ff21..37b09c528ce 100644 --- a/src/mam/mod_mam_rdbms_prefs.erl +++ b/src/mam/mod_mam_rdbms_prefs.erl @@ -10,7 +10,7 @@ %% Exports %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% MAM hook handlers -behaviour(ejabberd_gen_mam_prefs). @@ -34,7 +34,6 @@ %% ---------------------------------------------------------------------- %% gen_mod callbacks %% Starting and stopping functions for users' archives - -spec start(mongooseim:host_type(), _) -> ok. start(HostType, _Opts) -> prepare_queries(HostType), @@ -46,6 +45,10 @@ stop(HostType) -> ejabberd_hooks:delete(hooks(HostType)), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + hooks(HostType) -> PM = gen_mod:get_module_opt(HostType, ?MODULE, pm, false), MUC = gen_mod:get_module_opt(HostType, ?MODULE, muc, false), diff --git a/src/mam/mod_mam_rdbms_user.erl b/src/mam/mod_mam_rdbms_user.erl index 7733b2f9ab5..1e6ee3019b4 100644 --- a/src/mam/mod_mam_rdbms_user.erl +++ b/src/mam/mod_mam_rdbms_user.erl @@ -11,7 +11,7 @@ -module(mod_mam_rdbms_user). %% gen_mod handlers --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). %% ejabberd handlers -export([archive_id/3, @@ -25,7 +25,6 @@ %% ---------------------------------------------------------------------- %% gen_mod callbacks - -spec start(mongooseim:host_type(), gen_mod:module_opts()) -> ok. start(HostType, _Opts) -> prepare_queries(), @@ -37,6 +36,10 @@ stop(HostType) -> ejabberd_hooks:delete(hooks(HostType)), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + hooks(HostType) -> [{Hook, HostType, ?MODULE, Fun, N} || {true, Hook, Fun, N} <- hooks2(HostType)]. diff --git a/src/mod_commands.erl b/src/mod_commands.erl index 8588d2c61df..7553e44f246 100644 --- a/src/mod_commands.erl +++ b/src/mod_commands.erl @@ -4,7 +4,7 @@ -behaviour(gen_mod). -behaviour(mongoose_module_metrics). --export([start/0, stop/0, +-export([start/0, stop/0, supported_features/0, start/2, stop/1, register/3, unregister/2, @@ -43,6 +43,13 @@ stop() -> start(_, _) -> start(). stop(_) -> stop(). +-spec supported_features() -> [atom()]. +supported_features() -> + %% TODO: this module should be reworked into service + %% from the quick look it seems that the conversion for dynamic domains is done, + %% but there's no testing for this module enabled at dynamic_domains.spec yet. + [dynamic_domains]. + %%% %%% mongoose commands %%% @@ -504,8 +511,8 @@ run_subscription(Type, CallerJid, OtherJid) -> lserver => LServer, element => El }), % set subscription to - Acc2 = mongoose_hooks:roster_out_subscription( - LServer, Acc1, CallerJid, OtherJid, Type), + Acc2 = mongoose_hooks:roster_out_subscription(HostType, Acc1, CallerJid, + OtherJid, Type), ejabberd_router:route(CallerJid, OtherJid, Acc2), ok. diff --git a/src/mod_domain_isolation.erl b/src/mod_domain_isolation.erl index 07e42024d4f..927e23a2635 100644 --- a/src/mod_domain_isolation.erl +++ b/src/mod_domain_isolation.erl @@ -8,6 +8,7 @@ %% gen_mod handlers -export([start/2, stop/1]). -export([config_spec/0]). +-export([supported_features/0]). %% hooks -export([filter_local_packet/1]). @@ -19,32 +20,16 @@ -spec config_spec() -> mongoose_config_spec:config_section(). config_spec() -> - #section{ - items = #{<<"extra_domains">> => extra_domains()} - }. + #section{items = #{}}. -extra_domains() -> - #list{items = #option{type = string, - validate = subdomain_template, - process = fun mongoose_subdomain_utils:make_subdomain_pattern/1}}. +start(HostType, _Opts) -> + ejabberd_hooks:add(filter_local_packet, HostType, ?MODULE, filter_local_packet, 10). -start(Host, Opts) -> - ExtraDomains = proplists:get_value(extra_domains, Opts, []), - SubHosts = [mongoose_subdomain_utils:get_fqdn(SubdomainPattern, Host) - || SubdomainPattern <- ExtraDomains], - AllHosts = [Host|SubHosts], - [ejabberd_hooks:add(filter_local_packet, H, ?MODULE, filter_local_packet, 10) - || H <- AllHosts], - ok. +stop(HostType) -> + ejabberd_hooks:delete(filter_local_packet, HostType, ?MODULE, filter_local_packet, 10). -stop(Host) -> - ExtraDomains = gen_mod:get_module_opt(Host, ?MODULE, extra_domains, []), - SubHosts = [mongoose_subdomain_utils:get_fqdn(SubdomainPattern, Host) - || SubdomainPattern <- ExtraDomains], - AllHosts = [Host|SubHosts], - [ejabberd_hooks:delete(filter_local_packet, H, ?MODULE, filter_local_packet, 10) - || H <- AllHosts], - ok. +-spec supported_features() -> [atom()]. +supported_features() -> [dynamic_domains]. -spec filter_local_packet(Value :: fpacket() | drop) -> fpacket() | drop. filter_local_packet(drop) -> @@ -53,7 +38,7 @@ filter_local_packet({#jid{lserver = Server}, #jid{lserver = Server}, _Acc, _Packet} = Arg) -> Arg; filter_local_packet({#jid{lserver = FromServer} = From, - #jid{lserver = ToServer} = To, Acc, Packet} = Arg) -> + #jid{lserver = ToServer} = To, Acc, _Packet} = Arg) -> FromHost = domain_to_host(FromServer), ToHost = domain_to_host(ToServer), case FromHost =:= ToHost of diff --git a/src/mod_muc.erl b/src/mod_muc.erl index b573dfca4fd..eb215701f38 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -35,6 +35,7 @@ -export([start_link/2, start/2, stop/1, + supported_features/0, config_spec/0, process_room_affiliation/1, room_destroyed/4, @@ -171,6 +172,10 @@ stop(HostType) -> stop_gen_server(HostType), ok. +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + start_server(HostType, Opts) -> Proc = gen_mod:get_module_proc(HostType, ?PROCNAME), ChildSpec = diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index 00b56e41008..2062b133050 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -34,6 +34,7 @@ -export([start_link/2, start/2, stop/1, + supported_features/0, check_access_log/3, add_to_log/5, set_room_occupants/4]). @@ -98,7 +99,6 @@ start_link(Host, Opts) -> Proc = gen_mod:get_module_proc(Host, ?PROCNAME), gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []). - -spec start(jid:server(), _) -> {'error', _} | {'ok', 'undefined' | pid()} | {'ok', 'undefined' | pid(), _}. @@ -113,7 +113,6 @@ start(Host, Opts) -> [?MODULE]}, ejabberd_sup:start_child(ChildSpec). - -spec stop(jid:server()) -> 'ok' | {'error', 'not_found' | 'restarting' | 'running' | 'simple_one_for_one'}. stop(Host) -> @@ -121,6 +120,10 @@ stop(Host) -> gen_server:call(Proc, stop), ejabberd_sup:stop_child(Proc). +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + -spec config_spec() -> mongoose_config_spec:config_section(). config_spec() -> #section{ diff --git a/src/muc_light/mod_muc_light.erl b/src/muc_light/mod_muc_light.erl index 85430ddc67d..e41d9d56f07 100644 --- a/src/muc_light/mod_muc_light.erl +++ b/src/muc_light/mod_muc_light.erl @@ -34,7 +34,7 @@ delete_room/1]). %% gen_mod callbacks --export([start/2, stop/1, config_spec/0]). +-export([start/2, stop/1, config_spec/0, supported_features/0]). %% config processing callback -export([process_config_schema/1]). @@ -72,6 +72,10 @@ %% API %%==================================================================== +-spec supported_features() -> [atom()]. +supported_features() -> + [dynamic_domains]. + -spec default_schema_definition() -> mod_muc_light_room_config:user_defined_schema(). default_schema_definition() -> [{"roomname", "Untitled"}, diff --git a/src/muc_light/mod_muc_light_commands.erl b/src/muc_light/mod_muc_light_commands.erl index a563b20b023..8b444840899 100644 --- a/src/muc_light/mod_muc_light_commands.erl +++ b/src/muc_light/mod_muc_light_commands.erl @@ -22,7 +22,7 @@ -behaviour(gen_mod). -behaviour(mongoose_module_metrics). --export([start/2, stop/1]). +-export([start/2, stop/1, supported_features/0]). -export([create_unique_room/4]). -export([create_identifiable_room/5]). @@ -48,6 +48,12 @@ start(_, _) -> stop(_) -> mongoose_commands:unregister(commands()). +-spec supported_features() -> [atom()]. +supported_features() -> + %% TODO: this module should be reworked into service + %% from the quick look it seems that the conversion for dynamic domains is done, + %% but there's no testing for this module enabled at dynamic_domains.spec yet. + [dynamic_domains]. %%-------------------------------------------------------------------- %% Interface descriptions diff --git a/test/gen_mod_SUITE.erl b/test/gen_mod_SUITE.erl index 1b622e33cb6..d7022c5e602 100644 --- a/test/gen_mod_SUITE.erl +++ b/test/gen_mod_SUITE.erl @@ -30,6 +30,8 @@ all() -> init_per_testcase(_, Config) -> meck:new(ejabberd_config, [passthrough]), + meck:expect(ejabberd_config, get_global_option_or_default, + fun(hosts, _) -> [<<"localhost">>, <<"localhost.bis">>] end), meck:expect(ejabberd_config, get_local_option, fun(_) -> undefined end), meck:expect(ejabberd_config, add_local_option, fun(_, _) -> {atomic, ok} end), meck:expect(ejabberd_config, del_local_option, fun(_) -> {atomic, ok} end), diff --git a/test/mod_global_distrib_SUITE.erl b/test/mod_global_distrib_SUITE.erl index 4eb5d4adfc0..42d06f888c5 100644 --- a/test/mod_global_distrib_SUITE.erl +++ b/test/mod_global_distrib_SUITE.erl @@ -130,8 +130,8 @@ fake_acc_to_component(From) -> set_meck() -> meck:new(ejabberd_config, []), - meck:expect(ejabberd_config, get_global_option, - fun(hosts) -> [global_host(), local_host()] end), + meck:expect(ejabberd_config, get_global_option_or_default, + fun(hosts, _) -> [global_host(), local_host()] end), meck:expect(ejabberd_config, get_local_option, fun(_) -> undefined end), meck:new(mongoose_metrics, []), diff --git a/test/mongoose_service_SUITE.erl b/test/mongoose_service_SUITE.erl index bb4deda7e7f..6dc4307aa0a 100644 --- a/test/mongoose_service_SUITE.erl +++ b/test/mongoose_service_SUITE.erl @@ -55,7 +55,7 @@ init_per_testcase(misconfigured, C) -> mongoose_service:start(), meck:new(ejabberd_config, [passthrough]), meck:expect(ejabberd_config, get_local_option_or_default, - fun(services, _) -> [{service_a, []}] end), + fun(services, _) -> [{service_a, []}] end), meck:new(service_a, [non_strict]), meck:expect(service_a, deps, fun() -> [service_b] end), C; @@ -64,6 +64,8 @@ init_per_testcase(module_deps, C) -> init_per_testcase(generic, C), meck:expect(ejabberd_config, get_local_option, fun(_) -> undefined end), meck:expect(ejabberd_config, add_local_option, fun(_, _) -> ok end), + meck:expect(ejabberd_config, get_global_option_or_default, + fun(hosts, _) -> [<<"localhost">>] end), gen_mod:start(), meck:new(module_a, [non_strict]), meck:expect(module_a, deps, fun(_, _) -> [{service, service_d}, {service, service_h}] end), diff --git a/test/mongoose_wpool_SUITE.erl b/test/mongoose_wpool_SUITE.erl index 584b2beb686..a9596ebab45 100644 --- a/test/mongoose_wpool_SUITE.erl +++ b/test/mongoose_wpool_SUITE.erl @@ -49,8 +49,8 @@ init_per_suite(Config) -> ok = meck:new(wpool, [no_link, passthrough]), ok = meck:new(mongoose_wpool, [no_link, passthrough]), ok = meck:new(ejabberd_config, [no_link]), - meck:expect(ejabberd_config, get_global_option, - fun(hosts) -> [<<"a.com">>, <<"b.com">>, <<"c.eu">>] end), + meck:expect(ejabberd_config, get_global_option_or_default, + fun(hosts, _) -> [<<"a.com">>, <<"b.com">>, <<"c.eu">>] end), Self = self(), spawn(fun() -> register(test_helper, self()), diff --git a/test/roster_SUITE.erl b/test/roster_SUITE.erl index f60c03d1002..8414edca7bf 100644 --- a/test/roster_SUITE.erl +++ b/test/roster_SUITE.erl @@ -37,9 +37,18 @@ init_per_suite(C) -> ok = mnesia:start(), {ok, _} = application:ensure_all_started(jid), {ok, _} = application:ensure_all_started(exometer_core), + meck:new(gen_iq_handler, [no_link]), + meck:expect(gen_iq_handler, add_iq_handler, fun(_, _, _, _, _, _) -> ok end), + meck:expect(gen_iq_handler, remove_iq_handler, fun(_, _, _) -> ok end), + meck:new(mongoose_domain_api, [no_link]), + meck:expect(mongoose_domain_api, get_domain_host_type, fun(H) -> {ok, H} end), + meck:new(ejabberd_config, [no_link, passthrough]), + meck:expect(ejabberd_config, get_global_option_or_default, + fun(hosts, _) -> [host()] end), C. end_per_suite(C) -> + meck:unload(), mnesia:stop(), mnesia:delete_schema([node()]), C. @@ -47,11 +56,6 @@ end_per_suite(C) -> init_per_testcase(_TC, C) -> init_ets(), ejabberd_hooks:start_link(), - meck:new(gen_iq_handler), - meck:expect(gen_iq_handler, add_iq_handler, fun(_, _, _, _, _, _) -> ok end), - meck:expect(gen_iq_handler, remove_iq_handler, fun(_, _, _) -> ok end), - meck:new(mongoose_domain_api), - meck:expect(mongoose_domain_api, get_domain_host_type, fun(H) -> {ok, H} end), gen_mod:start(), gen_mod:start_module(host(), mod_roster, []), C. @@ -60,8 +64,6 @@ end_per_testcase(_TC, C) -> mod_roster:remove_user(a(), host()), gen_mod:stop_module(host(), mod_roster), delete_ets(), - meck:unload(gen_iq_handler), - meck:unload(mongoose_domain_api), C. diff --git a/tools/travis-setup-db.sh b/tools/travis-setup-db.sh index fcdb5d941d6..4ad013c650c 100755 --- a/tools/travis-setup-db.sh +++ b/tools/travis-setup-db.sh @@ -140,7 +140,7 @@ elif [ "$db" = 'pgsql' ]; then # make clean && make # Than rerun the script to create a new docker container. echo "Configuring postgres with SSL" - sudo -n service postgresql stop || echo "Failed to stop psql" + sudo -n service postgresql stop || echo "Failed to stop pgsql" docker rm -v -f $NAME || echo "Skip removing previous container" cp ${SSLDIR}/mongooseim/cert.pem ${SQL_TEMP_DIR}/fake_cert.pem cp ${SSLDIR}/mongooseim/key.pem ${SQL_TEMP_DIR}/fake_key.pem