Skip to content

Commit

Permalink
Merge pull request #3422 from esl/mu-fix-domain-removal-last-testcase
Browse files Browse the repository at this point in the history
Fix domain_removal_SUITE:last_removal
Fix expecting IQ, but received presence unavailable instead.
That presence is from make_everyone_friends story.
Proposed changes include:
* Rewrite code to use one story only
* Fix indention, common, how could it pass code review?
  • Loading branch information
NelsonVides authored Nov 30, 2021
2 parents 3be636e + 1ce1e95 commit 9690e60
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -353,35 +353,36 @@ vcard_removal(Config) ->
end).

last_removal(Config0) ->
Config1 = escalus_fresh:create_users(Config0, [{alice, 1}, {bob, 1}]),
Config2 = escalus:make_everyone_friends(Config1),
escalus:story(Config2, [{alice, 1}],
fun(Alice) ->
%% Bob logs in
{ok, Bob} = escalus_client:start_for(Config2, bob, <<"bob">>),

%% Bob logs out with a status
Status = escalus_stanza:tags([{<<"status">>, <<"I am a banana!">>}]),
Presence = escalus_stanza:presence(<<"unavailable">>, Status),
escalus_client:send(Bob, Presence),
escalus_client:stop(Config2, Bob),
timer:sleep(1024), % more than a second

%% Alice asks for Bob's last availability
BobShortJID = escalus_client:short_jid(Bob),
escalus_client:send(Alice, escalus_stanza:last_activity(BobShortJID)),

%% Alice receives Bob's status and last online time > 0
Stanza = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_last_result, Stanza),
true = (1 =< get_last_activity(Stanza)),
<<"I am a banana!">> = get_last_status(Stanza),

run_remove_domain(),
escalus_client:send(Alice, escalus_stanza:last_activity(BobShortJID)),
Error = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_error, [<<"auth">>, <<"forbidden">>], Error)
end).
F = fun(Config2, Alice, Bob) ->
escalus_story:make_all_clients_friends([Alice, Bob]),

%% Bob logs out with a status
Status = escalus_stanza:tags([{<<"status">>, <<"I am a banana!">>}]),
Presence = escalus_stanza:presence(<<"unavailable">>, Status),
escalus_client:send(Bob, Presence),

escalus_client:stop(Config2, Bob),
timer:sleep(1024), % more than a second

PresUn = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_presence_with_type, [<<"unavailable">>], PresUn),

%% Alice asks for Bob's last availability
BobShortJID = escalus_client:short_jid(Bob),
GetLast = escalus_stanza:last_activity(BobShortJID),
Stanza = escalus_client:send_iq_and_wait_for_result(Alice, GetLast),

%% Alice receives Bob's status and last online time > 0
escalus:assert(is_last_result, Stanza),
true = (1 =< get_last_activity(Stanza)),
<<"I am a banana!">> = get_last_status(Stanza),

run_remove_domain(),
escalus_client:send(Alice, GetLast),
Error = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_error, [<<"auth">>, <<"forbidden">>], Error)
end,
escalus:fresh_story_with_config(Config0, [{alice, 1}, {bob, 1}], F).

%% Helpers

Expand Down

0 comments on commit 9690e60

Please sign in to comment.