Skip to content

Commit

Permalink
Disco test for push notifications
Browse files Browse the repository at this point in the history
Previously, disco was tested only for one type of host; now it's tested for real and virtual hosts.
  • Loading branch information
jacekwegr committed Jan 12, 2023
1 parent 944ba98 commit af62463
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 57 deletions.
54 changes: 1 addition & 53 deletions big_tests/tests/push_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@

all() ->
[
{group, disco},
{group, toggling},
{group, pubsub_ful},
{group, pubsub_less}
].

groups() ->
G = [
{disco, [], [
push_notifications_listed_disco_when_available,
push_notifications_not_listed_disco_when_not_available
]},
{toggling, [parallel], [
enable_should_fail_with_missing_attributes,
enable_should_fail_with_invalid_attributes,
Expand Down Expand Up @@ -99,8 +94,6 @@ end_per_suite(Config) ->
escalus_fresh:clean(),
escalus:end_per_suite(Config).

init_per_group(disco, Config) ->
escalus:create_users(Config, escalus:get_users([alice]));
init_per_group(pubsub_ful, Config) ->
[{pubsub_host, real} | Config];
init_per_group(pubsub_less, Config) ->
Expand All @@ -117,23 +110,12 @@ init_per_group(GroupName, Config0) ->
dynamic_modules:ensure_modules(HostType, required_modules(GroupName)),
Config.

end_per_group(disco, Config) ->
escalus:delete_users(Config),
Config;
end_per_group(ComplexGroup, Config) when ComplexGroup == pubsub_ful;
ComplexGroup == pubsub_less ->
Config;
end_per_group(_, Config) ->
dynamic_modules:restore_modules(Config),
Config.
dynamic_modules:restore_modules(Config).

init_per_testcase(CaseName = push_notifications_listed_disco_when_available, Config1) ->
HostType = host_type(),
Config2 = dynamic_modules:save_modules(HostType, Config1),
dynamic_modules:ensure_modules(HostType, required_modules(CaseName)),
escalus:init_per_testcase(CaseName, Config2);
init_per_testcase(CaseName = push_notifications_not_listed_disco_when_not_available, Config) ->
escalus:init_per_testcase(CaseName, Config);
init_per_testcase(CaseName, Config0) ->
Config1 = escalus_fresh:create_users(Config0, [{bob, 1}, {alice, 1}, {kate, 1}]),
Config2 = add_pubsub_jid([{case_name, CaseName} | Config1]),
Expand All @@ -147,11 +129,6 @@ init_per_testcase(CaseName, Config0) ->

escalus:init_per_testcase(CaseName, Config).

end_per_testcase(CaseName = push_notifications_listed_disco_when_available, Config) ->
dynamic_modules:restore_modules(Config),
escalus:end_per_testcase(CaseName, Config);
end_per_testcase(CaseName = push_notifications_not_listed_disco_when_not_available, Config) ->
escalus:end_per_testcase(CaseName, Config);
end_per_testcase(CaseName, Config) ->
case ?config(pubsub_host, Config) of
virtual ->
Expand All @@ -178,35 +155,6 @@ muc_light_module() ->
mod_config(mod_muc_light, #{backend => mongoose_helper:mnesia_or_rdbms_backend(),
rooms_in_rosters => true})}.

%%--------------------------------------------------------------------
%% GROUP disco
%%--------------------------------------------------------------------

push_notifications_listed_disco_when_available(Config) ->
escalus:story(
Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:disco_info(Server)),
Stanza = escalus:wait_for_stanza(Alice),
escalus:assert(is_iq_result, Stanza),
escalus:assert(has_feature, [push_helper:ns_push()], Stanza),
ok
end).

push_notifications_not_listed_disco_when_not_available(Config) ->
escalus:story(
Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:disco_info(Server)),
Stanza = escalus:wait_for_stanza(Alice),
escalus:assert(is_iq_result, Stanza),
Pred = fun(Feature, Stanza0) -> not escalus_pred:has_feature(Feature, Stanza0) end,
escalus:assert(Pred, [push_helper:ns_push()], Stanza),
ok
end).

%%--------------------------------------------------------------------
%% GROUP toggling
%%--------------------------------------------------------------------
Expand Down
51 changes: 47 additions & 4 deletions big_tests/tests/push_integration_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ basic_groups() ->
{group, failure_cases_v3},
{group, failure_cases_v2},
{group, integration_with_sm_and_offline_storage},
{group, enhanced_integration_with_sm}
{group, enhanced_integration_with_sm},
{group, disco}
].

groups() ->
Expand Down Expand Up @@ -105,7 +106,12 @@ groups() ->
inbox_msg_reset_unread_count_fcm
]},
{failure_cases_v3, [parallel], failure_cases()},
{failure_cases_v2, [parallel], failure_cases()}
{failure_cases_v2, [parallel], failure_cases()},
{disco, [],
[
push_notifications_listed_disco_when_available,
push_notifications_not_listed_disco_when_not_available
]}
],
G.

Expand Down Expand Up @@ -143,6 +149,8 @@ init_per_group(pubsub_less, Config) ->
[{pubsub_host, virtual} | Config];
init_per_group(pubsub_ful, Config) ->
[{pubsub_host, real} | Config];
init_per_group(disco, Config) ->
escalus:create_users(Config, escalus:get_users([alice]));
init_per_group(G, Config) when G =:= pm_notifications_with_inbox;
G =:= groupchat_notifications_with_inbox;
G =:= integration_with_sm_and_offline_storage ->
Expand All @@ -164,13 +172,20 @@ init_per_group(G, Config) ->
end,
C.

end_per_group(disco, Config) ->
escalus:delete_users(Config);
end_per_group(_, Config) ->
dynamic_modules:restore_modules(Config),
Config.
dynamic_modules:restore_modules(Config).

init_per_testcase(CaseName = push_notifications_listed_disco_when_available, Config) ->
init_modules(disco, Config),
escalus:init_per_testcase(CaseName, Config);
init_per_testcase(CaseName, Config) ->
escalus:init_per_testcase(CaseName, Config).

end_per_testcase(CaseName = push_notifications_listed_disco_when_available, Config) ->
dynamic_modules:restore_modules(Config),
escalus:end_per_testcase(CaseName, Config);
end_per_testcase(CaseName, Config) ->
escalus:end_per_testcase(CaseName, Config).

Expand Down Expand Up @@ -827,6 +842,34 @@ no_push_notification_for_internal_mongoose_push_error(Config) ->

end).

%%--------------------------------------------------------------------
%% GROUP disco
%%--------------------------------------------------------------------

push_notifications_listed_disco_when_available(Config) ->
escalus:story(
Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:disco_info(Server)),
Stanza = escalus:wait_for_stanza(Alice),
escalus:assert(is_iq_result, Stanza),
escalus:assert(has_feature, [push_helper:ns_push()], Stanza),
ok
end).

push_notifications_not_listed_disco_when_not_available(Config) ->
escalus:story(
Config, [{alice, 1}],
fun(Alice) ->
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:disco_info(Server)),
Stanza = escalus:wait_for_stanza(Alice),
escalus:assert(is_iq_result, Stanza),
Pred = fun(Feature, Stanza0) -> not escalus_pred:has_feature(Feature, Stanza0) end,
escalus:assert(Pred, [push_helper:ns_push()], Stanza),
ok
end).

%%--------------------------------------------------------------------
%% Test helpers
Expand Down

0 comments on commit af62463

Please sign in to comment.