Skip to content

Commit

Permalink
Prevent infinite loop when domain isolation is on on both domains
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed May 5, 2021
1 parent 3d3ff8d commit 553f528
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 13 additions & 0 deletions big_tests/tests/domain_isolation_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ suite() ->
all() ->
[
isolation_works_for_one2one,
isolation_works_for_one2one_2domains,
isolation_works_for_subdomains
].

domain() -> ct:get_config({hosts, mim, domain}).
domain2() -> ct:get_config({hosts, mim, secondary_domain}).
domains() -> [domain(), domain2()].

%%--------------------------------------------------------------------
%% Init & teardown
Expand All @@ -30,13 +33,20 @@ end_per_suite(Config) ->
escalus_fresh:clean(),
escalus:end_per_suite(Config).


init_per_testcase(isolation_works_for_one2one_2domains = TestcaseName, Config) ->
[dynamic_modules:start(Host, mod_domain_isolation, []) || Host <- domains()],
escalus:init_per_testcase(TestcaseName, Config);
init_per_testcase(TestcaseName, Config) ->
Host = domain(),
MucHost = binary_to_list(<<"muclight.", Host/binary>>),
dynamic_modules:start(Host, mod_domain_isolation, [{extra_domains, [MucHost]}]),
dynamic_modules:start(Host, mod_muc_light, [{host, MucHost}]),
escalus:init_per_testcase(TestcaseName, Config).

end_per_testcase(isolation_works_for_one2one_2domains = TestcaseName, Config) ->
[dynamic_modules:stop(Host, mod_domain_isolation) || Host <- domains()],
escalus:end_per_testcase(TestcaseName, Config);
end_per_testcase(TestcaseName, Config) ->
Host = domain(),
dynamic_modules:stop(Host, mod_domain_isolation),
Expand All @@ -62,6 +72,9 @@ isolation_works_for_one2one(Config) ->
end,
escalus:fresh_story(Config, [{alice, 1}, {bob, 1}, {alice_bis, 1}], F).

isolation_works_for_one2one_2domains(Config) ->
isolation_works_for_one2one(Config).

isolation_works_for_subdomains(Config) ->
F = fun(Alice, Bis) ->
Domain = domain(),
Expand Down
14 changes: 10 additions & 4 deletions src/mod_domain_isolation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ filter_local_packet({#jid{lserver = FromServer} = From,
true ->
Arg;
false ->
send_back_error(mongoose_xmpp_errors:service_unavailable(
<<"en">>, <<"Filtered by the domain isolation">>),
From, To, Acc),
drop
%% Allow errors from this module
case mongoose_acc:get(flag, error, false, Acc) of
true ->
Arg;
false ->
Err = mongoose_xmpp_errors:service_unavailable(<<"en">>,
<<"Filtered by the domain isolation">>),
send_back_error(Err, From, To, Acc),
drop
end
end.

%% muc.localhost becomes localhost.
Expand Down

0 comments on commit 553f528

Please sign in to comment.