Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Jan 16, 2023
1 parent 20574c0 commit 6f1cc15
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions big_tests/tests/pep_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ all() ->
].

groups() ->
G = [
[
{pep_tests, [parallel],
[
disco_test,
Expand All @@ -80,8 +80,7 @@ groups() ->
unsubscribe_after_presence_unsubscription
]
}
],
ct_helper:repeat_all_until_all_ok(G).
].

suite() ->
require_rpc_nodes([mim]) ++ escalus:suite().
Expand Down Expand Up @@ -156,7 +155,7 @@ disco_sm_test(Config) ->
disco_sm_items_test(Config) ->
NodeNS = random_node_ns(),
escalus:fresh_story(
set_caps_node(NodeNS, Config),
Config, %%set_caps_node(NodeNS, Config),
[{alice, 1}],
fun(Alice) ->
AliceJid = escalus_client:short_jid(Alice),
Expand Down Expand Up @@ -193,29 +192,46 @@ pep_caps_test(Config) ->
send_presence_with_caps(Bob, Caps),
DiscoRequest = escalus:wait_for_stanza(Bob),

%% Client responds with a list of supported features (chap. 1 ex. 5)
send_caps_disco_result(Bob, DiscoRequest, NodeNS),
receive_presence_with_caps(Bob, Bob, Caps),

receive_presence_with_caps(Bob, Bob, Caps)
%% Client responds with a list of supported features (chap. 1 ex. 5)
send_caps_disco_result(Bob, DiscoRequest, NodeNS)
end).

publish_and_notify_test(Config) ->
NodeNS = random_node_ns(),
escalus:fresh_story(
set_caps_node(NodeNS, Config),
[{alice, 1}, {bob, 1}],
fun(Alice, Bob) ->
escalus_story:make_all_clients_friends([Alice, Bob]),
fresh_story_with_caps(Config, [{alice, 1}, {bob, 1}], fun publish_and_notify_story/3).

pubsub_tools:publish(Alice, <<"item1">>, {pep, NodeNS}, []),
pubsub_tools:receive_item_notification(
Bob, <<"item1">>, {escalus_utils:get_short_jid(Alice), NodeNS}, [])
end).
publish_and_notify_story(Config, Alice, Bob) ->
NodeNS = ?config(node_ns, Config),
escalus_story:make_all_clients_friends([Alice, Bob]),
pubsub_tools:publish(Alice, <<"item1">>, {pep, NodeNS}, []),
pubsub_tools:receive_item_notification(
Bob, <<"item1">>, {escalus_utils:get_short_jid(Alice), NodeNS}, []).

set_caps_node(NodeNS, Config) ->
[{escalus_overrides,
[{initial_activity, {?MODULE, send_initial_presence_with_caps, [NodeNS]}}]}
| Config].
fresh_story_with_caps(Config, Users, StoryF) ->
NodeNS = random_node_ns(),
Option = received_stanza_handlers,
%Pid = self(),
Value = fun(Client, Stanza) ->
case escalus_pred:is_iq_get(Stanza) of
true -> send_caps_disco_result(Client, Stanza, NodeNS),
%Pid ! caps_requested,
true;
false -> false
end
end,
Config1 = lists:foldl(fun({UserName, _Count}, CfgIn) ->
escalus_users:update_userspec(CfgIn, UserName, Option, Value)
end, Config, Users),
Config2 = [{escalus_overrides,
[{initial_activity, {?MODULE, send_initial_presence_with_caps, [NodeNS]}}]},
{node_ns, NodeNS} | Config1],
escalus:fresh_story_with_config(Config2, Users, StoryF).

assert_caps_requested() ->
receive caps_requested -> ok
after 5000 -> ct:fail("Caps not requested by the server")
end.

publish_options_test(Config) ->
% Given pubsub is configured with pep plugin
Expand Down Expand Up @@ -410,8 +426,8 @@ required_modules(cache_tests) ->
send_initial_presence_with_caps(NodeNS, User) ->
case string:to_lower(binary_to_list(escalus_client:username(User))) of
"alice" ++ _ -> escalus_story:send_initial_presence(User);
"bob" ++ _ -> send_presence_with_caps_and_handle_disco(User, caps(NodeNS), NodeNS);
"kate" ++ _ -> send_presence_with_caps_and_handle_disco(User, caps(NodeNS), NodeNS)
"bob" ++ _ -> send_presence_with_caps(User, caps(NodeNS));
"kate" ++ _ -> send_presence_with_caps(User, caps(NodeNS))
end.

send_presence_with_caps_and_handle_disco(User, Caps, NodeNS) ->
Expand Down

0 comments on commit 6f1cc15

Please sign in to comment.