Skip to content

Commit

Permalink
Use the new mod_last API with host types in mongoose_cleanup_SUITE
Browse files Browse the repository at this point in the history
Also: use host types when testing modules that support them
  • Loading branch information
chrzaszcz committed Jul 26, 2021
1 parent 5272218 commit 9676977
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions test/mongoose_cleanup_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,35 @@ cleaner_runs_hook_on_nodedown(_Config) ->
['_', {node_cleanup, global}, '_'])).

auth_anonymous(_Config) ->
HostType = host_type(),
{U, S, R, JID, SID} = get_fake_session(),
ejabberd_auth_anonymous:start(S),
ejabberd_auth_anonymous:start(HostType),
Info = [{auth_module, ejabberd_auth_anonymous}],
ejabberd_auth_anonymous:register_connection(#{}, S, SID, JID, Info),
true = ejabberd_auth_anonymous:does_user_exist(host_type(), U, S),
ejabberd_auth_anonymous:register_connection(#{}, HostType, SID, JID, Info),
true = ejabberd_auth_anonymous:does_user_exist(HostType, U, S),
mongoose_hooks:session_cleanup(S, new_acc(S), U, R, SID),
false = ejabberd_auth_anonymous:does_user_exist(host_type(), U, S).
false = ejabberd_auth_anonymous:does_user_exist(HostType, U, S).

last(_Config) ->
HostType = host_type(),
{U, S, R, _JID, SID} = get_fake_session(),
mod_last:start(S, [{backend, mnesia}, {iqdisc, no_queue}]),
not_found = mod_last:get_last_info(U, S),
mod_last:start(HostType, [{backend, mnesia}, {iqdisc, no_queue}]),
not_found = mod_last:get_last_info(HostType, U, S),
Status1 = <<"status1">>,
#{} = mod_last:on_presence_update(#{}, U, S, R, Status1),
{ok, TS1, Status1} = mod_last:get_last_info(U, S),
#{} = mod_last:on_presence_update(new_acc(S), U, S, R, Status1),
{ok, TS1, Status1} = mod_last:get_last_info(HostType, U, S),
async_helper:wait_until(
fun() ->
mongoose_hooks:session_cleanup(S, new_acc(S), U, R, SID),
{ok, TS2, <<>>} = mod_last:get_last_info(U, S),
{ok, TS2, <<>>} = mod_last:get_last_info(HostType, U, S),
TS2 - TS1 > 0
end,
true).

stream_management(_Config) ->
HostType = host_type(),
{U, S, R, _JID, SID} = get_fake_session(),
mod_stream_management:start(S, []),
mod_stream_management:start(HostType, []),
SMID = <<"123">>,
mod_stream_management:register_smid(SMID, SID),
{sid, SID} = mod_stream_management:get_sid(SMID),
Expand Down Expand Up @@ -217,7 +220,7 @@ get_fake_session() ->
new_acc(Server) ->
mongoose_acc:new(#{location => ?LOCATION,
lserver => Server,
host_type => Server,
host_type => host_type(),
element => undefined}).

host_type() ->
Expand Down

0 comments on commit 9676977

Please sign in to comment.