Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into updating-mod_offlin…
Browse files Browse the repository at this point in the history
…e_stub-module
  • Loading branch information
DenysGonchar committed Jun 1, 2021
2 parents 2d1f91f + df42d26 commit c492cf0
Show file tree
Hide file tree
Showing 52 changed files with 984 additions and 1,000 deletions.
22 changes: 8 additions & 14 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,34 @@
{include, "tests"}.

{suites, "tests", acc_e2e_SUITE}.
{suites, "tests", domain_isolation_SUITE}.
{suites, "tests", muc_SUITE}.
{suites, "tests", muc_light_SUITE}.
{suites, "tests", muc_light_legacy_SUITE}.
{suites, "tests", mam_SUITE}.

{suites, "tests", carboncopy_SUITE}.
{skip_cases, "tests", carboncopy_SUITE, [discovering_support],
"at the moment mod_disco doesn't support dynamic domains"}.

{suites, "tests", mod_ping_SUITE}.
{suites, "tests", offline_stub_SUITE}.

{suites, "tests", inbox_SUITE}.
{skip_cases, "tests", inbox_SUITE, [disco_service],
"at the moment mod_disco doesn't support dynamic domains"}.
{skip_cases, "tests", inbox_SUITE, [msg_sent_to_offline_user],
"at the moment mod_offline doesn't support dynamic domains"}.
{skip_groups, "tests", inbox_SUITE, [muclight, muc],
"at the moment muc/muclight doesn't support dynamic domains"}.

{suites, "tests", inbox_extensions_SUITE}.
{skip_groups, "tests", inbox_extensions_SUITE, [muclight],
"at the moment muclight doesn't support dynamic domains"}.

{suites, "tests", mam_SUITE}.
{skip_cases, "tests", mam_SUITE,
[muc_service_discovery, mam_service_discovery],
"at the moment mod_disco doesn't support dynamic domains"}.
{skip_cases, "tests", mam_SUITE,
[messages_filtered_when_prefs_default_policy_is_roster],
"at the moment mod_roster doesn't support dynamic domains"}.
{skip_cases, "tests", mam_SUITE,
[metric_incremented_when_store_message,
metric_incremented_on_archive_request],
"this test is broken in PR #3120"}.

{suites, "tests", mod_ping_SUITE}.
{skip_cases, "tests", mod_ping_SUITE, [disco],
"at the moment mod_disco doesn't support dynamic domains"}.

{suites, "tests", muc_SUITE}.
{skip_groups, "tests", muc_SUITE,
[disco, disco_non_parallel, disco_rsm, disco_rsm_with_offline],
"at the moment mod_disco doesn't support dynamic domains"}.
Expand All @@ -54,6 +46,7 @@
"at the moment S2S doesn't support dynamic domains "
"(requires mod_register creating CT users)"}.

{suites, "tests", muc_light_SUITE}.
{skip_cases, "tests", muc_light_SUITE,
[disco_service,
disco_features,
Expand All @@ -73,6 +66,7 @@
no_roomname_in_schema_doesnt_break_disco_and_roster],
"at the moment mod_roster doesn't support dynamic domains"}.

{suites, "tests", muc_light_legacy_SUITE}.
{skip_cases, "tests", muc_light_legacy_SUITE,
[disco_service,
disco_features,
Expand Down
93 changes: 75 additions & 18 deletions big_tests/tests/adhoc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@

-include_lib("escalus/include/escalus.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(NS_COMMANDS, <<"http://jabber.org/protocol/commands">>).

%%--------------------------------------------------------------------
%% Suite configuration
%%--------------------------------------------------------------------
all() ->
[{group, adhoc}].
[{group, disco_visible},
{group, adhoc}].

groups() ->
G = [{adhoc, [sequence], [ping]}],
G = [{adhoc, [parallel], [disco_hidden, disco_commands, ping]},
{disco_visible, [parallel], [disco_visible, disco_commands]}],
ct_helper:repeat_all_until_all_ok(G).

suite() ->
Expand All @@ -36,12 +41,15 @@ init_per_suite(Config) ->
escalus:init_per_suite(Config).

end_per_suite(Config) ->
escalus_fresh:clean(),
escalus:end_per_suite(Config).

init_per_group(_GroupName, Config) ->
escalus:create_users(Config, escalus:get_users([alice, bob])).
init_per_group(GroupName, Config) ->
Config1 = init_modules(GroupName, Config),
escalus:create_users(Config1, escalus:get_users([alice, bob])).

end_per_group(_GroupName, Config) ->
end_per_group(GroupName, Config) ->
restore_modules(GroupName, Config),
escalus:delete_users(Config, escalus:get_users([alice, bob])).

init_per_testcase(CaseName, Config) ->
Expand All @@ -50,20 +58,69 @@ init_per_testcase(CaseName, Config) ->
end_per_testcase(CaseName, Config) ->
escalus:end_per_testcase(CaseName, Config).

init_modules(disco_visible, Config) ->
Config1 = escalus:init_per_suite(dynamic_modules:save_modules(domain(), Config)),
dynamic_modules:ensure_modules(domain(), [{mod_adhoc, [{report_commands_node, true}]}]),
Config1;
init_modules(_, Config) ->
Config.

restore_modules(disco_visible, Config) ->
dynamic_modules:restore_modules(domain(), Config);
restore_modules(_, Config) ->
ok.

%%--------------------------------------------------------------------
%% Adhoc tests
%%--------------------------------------------------------------------
disco_hidden(Config) ->
escalus:fresh_story(Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:service_discovery(Server)),
Stanza = escalus:wait_for_stanza(Alice),
Query = exml_query:subelement(Stanza, <<"query">>),
?assertEqual(undefined,
exml_query:subelement_with_attr(Query, <<"node">>, ?NS_COMMANDS)),
escalus:assert(is_stanza_from, [domain()], Stanza)
end).

disco_visible(Config) ->
escalus:fresh_story(Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:service_discovery(Server)),
Stanza = escalus:wait_for_stanza(Alice),
Query = exml_query:subelement(Stanza, <<"query">>),
Item = exml_query:subelement_with_attr(Query, <<"node">>, ?NS_COMMANDS),
?assertEqual(Server, exml_query:attr(Item, <<"jid">>)),
escalus:assert(is_stanza_from, [domain()], Stanza)
end).

disco_commands(Config) ->
escalus:fresh_story(Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:disco_items(Server, ?NS_COMMANDS)),
Stanza = escalus:wait_for_stanza(Alice),
Query = exml_query:subelement(Stanza, <<"query">>),
Item = exml_query:subelement_with_attr(Query, <<"node">>, <<"ping">>),
?assertEqual(Server, exml_query:attr(Item, <<"jid">>)),
escalus:assert(is_stanza_from, [domain()], Stanza)
end).

ping(Config) ->
escalus:story(Config, [{alice, 1}],
fun(Alice) ->
Host = ct:get_config({hosts, mim, domain}),
%% Alice pings the server using adhoc command
escalus_client:send(Alice, escalus_stanza:to(
escalus_stanza:adhoc_request(<<"ping">>),
Host)),

%% Server replies to Alice with pong
AdHocResp = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_adhoc_response, [<<"ping">>, <<"completed">>],
AdHocResp)
end).
escalus:fresh_story(Config, [{alice, 1}],
fun(Alice) ->
%% Alice pings the server using adhoc command
escalus_client:send(Alice, escalus_stanza:to(
escalus_stanza:adhoc_request(<<"ping">>),
domain())),
%% Server replies to Alice with pong
AdHocResp = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_adhoc_response, [<<"ping">>, <<"completed">>],
AdHocResp)
end).

domain() ->
ct:get_config({hosts, mim, domain}).
18 changes: 16 additions & 2 deletions big_tests/tests/disco_and_caps_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ groups() ->

all_test_cases() ->
[caps_feature_is_advertised,
user_can_query_server_caps_via_disco].
user_can_query_server_caps_via_disco,
extra_domains_are_advertised].

domain() ->
ct:get_config({hosts, mim, domain}).

init_per_suite(C) ->
C2 = escalus:init_per_suite(dynamic_modules:save_modules(domain(), C)),
dynamic_modules:ensure_modules(domain(), [{mod_caps, []}]),
dynamic_modules:ensure_modules(domain(), [{mod_caps, []},
{mod_disco, [{extra_domains, [extra_domain()]}]}]),
C2.

end_per_suite(C) ->
Expand Down Expand Up @@ -54,3 +56,15 @@ user_can_query_server_caps_via_disco(Config) ->
{attr, <<"name">>}]),
<<"MongooseIM">> = Identity,
escalus_connection:stop(Alice).

extra_domains_are_advertised(Config) ->
escalus:fresh_story(Config, [{alice, 1}], fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:service_discovery(Server)),
Stanza = escalus:wait_for_stanza(Alice),
escalus:assert(has_service, [extra_domain()], Stanza),
escalus:assert(is_stanza_from, [domain()], Stanza)
end).

extra_domain() ->
<<"eXtra.example.com">>.
2 changes: 1 addition & 1 deletion big_tests/tests/extdisco_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ init_per_group(extdisco_configured, Config) ->
init_per_group(multiple_extdisco_configured, Config) ->
ExternalServices = [stun_service(), stun_service(), turn_service()],
set_external_services(ExternalServices, Config);
init_per_group(external_service_required_elements_configured, Config) ->
init_per_group(extdisco_required_elements_configured, Config) ->
ExternalServices = [[{type, ftp},{host, "3.3.3.3"}]],
set_external_services(ExternalServices, Config);
init_per_group(_GroupName, Config) ->
Expand Down
5 changes: 1 addition & 4 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1553,10 +1553,7 @@ data_is_not_retrieved_for_missing_user(Config) ->
%% -------------------------------------------------------------

domain() ->
<<"localhost">>. % TODO: Make dynamic?

muc_domain() ->
muc_helper:muc_host().
ct:get_config({hosts, mim, domain}).

assert_personal_data_via_rpc(Client, ExpectedPersonalDataEntries) ->
ExpectedKeys = [ Key || {Key, _, _} <- ExpectedPersonalDataEntries ],
Expand Down
18 changes: 9 additions & 9 deletions big_tests/tests/inbox_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@

-import(muc_light_helper, [room_bin_jid/1]).
-import(inbox_helper, [
muclight_domain/0,
inbox_modules/0,
muclight_modules/0,
inbox_opts/0,
Expand Down Expand Up @@ -208,7 +207,7 @@ init_per_group(one_to_one, Config) ->
init_per_group(muclight, Config) ->
ok = dynamic_modules:ensure_modules(domain_helper:host_type(mim), muclight_modules()),
inbox_helper:reload_inbox_option(Config, groupchat, [muclight]),
muc_light_helper:create_room(?ROOM, muclight_domain(), alice,
muc_light_helper:create_room(?ROOM, muc_light_helper:muc_host(), alice,
[bob, kate], Config, muc_light_helper:ver(1));
init_per_group(muc, Config) ->
muc_helper:load_muc(),
Expand All @@ -231,22 +230,22 @@ init_per_testcase(create_groupchat_no_affiliation_stored, Config) ->
escalus:init_per_testcase(create_groupchat_no_affiliation_stored, Config);
init_per_testcase(groupchat_markers_one_reset, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM_MARKERS, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM_MARKERS, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
escalus:init_per_testcase(groupchat_markers_one_reset, Config);
init_per_testcase(non_reset_marker_should_not_affect_muclight_inbox, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM_MARKERS2, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM_MARKERS2, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
escalus:init_per_testcase(non_reset_marker_should_not_affect_muclight_inbox, Config);
init_per_testcase(groupchat_reset_stanza_resets_inbox, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM_MARKERS_RESET, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM_MARKERS_RESET, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
escalus:init_per_testcase(groupchat_reset_stanza_resets_inbox, Config);
init_per_testcase(leave_and_remove_conversation, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM2, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM2, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
escalus:init_per_testcase(leave_and_remove_conversation, Config);
init_per_testcase(leave_and_store_conversation, Config) ->
Expand All @@ -255,13 +254,13 @@ init_per_testcase(leave_and_store_conversation, Config) ->
escalus:init_per_testcase(leave_and_store_conversation, Config);
init_per_testcase(no_aff_stored_and_remove_on_kicked, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM3, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM3, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
inbox_helper:reload_inbox_option(Config, [{remove_on_kicked, true}, {aff_changes, false}]),
escalus:init_per_testcase(no_aff_stored_and_remove_on_kicked, Config);
init_per_testcase(no_stored_and_remain_after_kicked, Config) ->
clear_inbox_all(),
muc_light_helper:create_room(?ROOM4, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM4, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
inbox_helper:reload_inbox_option(Config, [{remove_on_kicked, false}, {aff_changes, true}]),
escalus:init_per_testcase(no_stored_and_remain_after_kicked, Config);
Expand Down Expand Up @@ -306,7 +305,8 @@ end_per_testcase(no_stored_and_remain_after_kicked, Config) ->
inbox_helper:restore_inbox_option(Config),
escalus:end_per_testcase(no_stored_and_remain_after_kicked, Config);
end_per_testcase(msg_sent_to_not_existing_user, Config) ->
escalus_ejabberd:rpc(mod_inbox_utils, clear_inbox, [<<"not_existing_user">>,<<"localhost">>]),
HostType = domain_helper:host_type(mim),
escalus_ejabberd:rpc(mod_inbox_utils, clear_inbox, [HostType, <<"not_existing_user">>,<<"localhost">>]),
escalus:end_per_testcase(msg_sent_to_not_existing_user, Config);
end_per_testcase(CaseName, Config) ->
escalus:end_per_testcase(CaseName, Config).
Expand Down
3 changes: 1 addition & 2 deletions big_tests/tests/inbox_extensions_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@


-import(inbox_helper, [
muclight_domain/0,
inbox_modules/0,
muclight_modules/0,
inbox_opts/0
Expand Down Expand Up @@ -175,7 +174,7 @@ end_per_group(_GroupName, Config) ->

init_per_testcase(groupchat_setunread_stanza_sets_inbox, Config) ->
inbox_helper:clear_inbox_all(),
muc_light_helper:create_room(?ROOM_MARKERS_RESET, muclight_domain(), alice, [bob, kate],
muc_light_helper:create_room(?ROOM_MARKERS_RESET, muc_light_helper:muc_host(), alice, [bob, kate],
Config, muc_light_helper:ver(1)),
escalus:init_per_testcase(groupchat_setunread_stanza_sets_inbox, Config);
init_per_testcase(TestCase, Config) ->
Expand Down
5 changes: 3 additions & 2 deletions big_tests/tests/inbox_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ inbox_modules() ->

muclight_modules() ->
[
{mod_muc_light, [{host, subhost_pattern(muclight_config_domain())},
{mod_muc_light, [{host, subhost_pattern(muc_light_helper:muc_host_pattern())},
{backend, rdbms}]}
].

Expand Down Expand Up @@ -249,10 +249,11 @@ clear_inbox_all() ->
clear_inboxes([alice, bob, kate, mike]).

clear_inboxes(UserList) ->
HostType = domain_helper:host_type(mim),
Usernames = [{escalus_users:get_username(escalus_users:get_users(UserList),U),
escalus_users:get_server(escalus_users:get_users(UserList),U)}
|| U <- UserList],
[escalus_ejabberd:rpc(mod_inbox_utils, clear_inbox, [User, Server]) || {User, Server} <- Usernames].
[escalus_ejabberd:rpc(mod_inbox_utils, clear_inbox, [HostType, User, Server]) || {User, Server} <- Usernames].

reload_inbox_option(Config, KeyValueList) ->
HostType = domain_helper:host_type(mim),
Expand Down
4 changes: 3 additions & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,9 @@ metric_incremented_on_archive_request(ConfigIn) ->
assert_respond_query_id(P, <<"metric_q1">>, parse_result_iq(Res)),
ok
end,
MongooseMetrics = [{[host_type(), backends, mod_mam, lookup], changed}],
HostType = domain_helper:host_type(mim),
HostTypePrefix = domain_helper:make_metrics_prefix(HostType),
MongooseMetrics = [{[HostTypePrefix, backends, mod_mam, lookup], changed}],
Config = [{mongoose_metrics, MongooseMetrics} | ConfigIn],
escalus_fresh:story(Config, [{alice, 1}], F).

Expand Down
4 changes: 3 additions & 1 deletion big_tests/tests/mod_http_upload_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ http_upload_item_discovery(Config) ->
ServJID = escalus_client:server(Bob),
Result = escalus:send_and_wait(Bob, escalus_stanza:disco_items(ServJID)),
escalus:assert(is_iq_result, Result),
escalus:assert(has_item, [upload_service(Bob)], Result)
Query = exml_query:subelement(Result, <<"query">>),
Item = exml_query:subelement_with_attr(Query, <<"jid">>, upload_service(Bob)),
?assertEqual(<<"HTTP File Upload">>, exml_query:attr(Item, <<"name">>))
end).

http_upload_feature_discovery(Config) ->
Expand Down
Loading

0 comments on commit c492cf0

Please sign in to comment.