Skip to content

Commit

Permalink
Merge pull request #3926 from esl/disco-tests-push-notifications
Browse files Browse the repository at this point in the history
Disco test for push notifications
  • Loading branch information
chrzaszcz authored Jan 12, 2023
2 parents 73c2409 + af62463 commit ef6be9a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 58 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
2 changes: 1 addition & 1 deletion doc/tutorials/push-notifications/MongoosePush-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ And second, you need to add `mod_push_service_mongoosepush` to the `modules` sec

```toml
[modules.mod_push_service_mongoosepush]
pool_name = mongoose_push_http
pool_name = "mongoose_push_http"
api_version = "v3"
```

Expand Down

0 comments on commit ef6be9a

Please sign in to comment.