Skip to content

Commit

Permalink
Remove obsolete vcard_update
Browse files Browse the repository at this point in the history
This module was handling the old versions of ejabberd
  • Loading branch information
chrzaszcz committed Oct 22, 2021
1 parent 35f0655 commit a362d86
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 144 deletions.
4 changes: 2 additions & 2 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ init_per_testcase(CN, Config) when CN =:= retrieve_inbox_muc;
Config0;

init_per_testcase(retrieve_vcard = CN, Config) ->
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
{skip, skipped_for_simplicity_for_now}; % TODO: Fix the case for LDAP as well
_ ->
escalus:init_per_testcase(CN, Config)
end;
init_per_testcase(remove_vcard = CN, Config) ->
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
{skip, skipped_for_simplicity_for_now}; % TODO: Fix the case for LDAP as well
_ ->
Expand Down
35 changes: 9 additions & 26 deletions big_tests/tests/sm_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
require_rpc_nodes/1,
rpc/4]).

-import(vcard_update, [discard_vcard_update/1,
server_string/1]).

-import(escalus_stanza, [setattr/3]).

-import(domain_helper, [host_type/0]).
Expand Down Expand Up @@ -364,7 +361,6 @@ h_ok_after_a_chat(ConfigIn) ->
Config = escalus_users:update_userspec(ConfigIn, alice,
stream_management, true),
escalus:fresh_story(Config, [{alice,1}, {bob,1}], fun(Alice, Bob) ->
NDiscarded = discard_vcard_update(Alice),
escalus:send(Alice, escalus_stanza:chat_to(Bob, <<"Hi, Bob!">>)),
escalus:assert(is_chat_message, [<<"Hi, Bob!">>],
escalus:wait_for_stanza(Bob)),
Expand All @@ -380,7 +376,7 @@ h_ok_after_a_chat(ConfigIn) ->
escalus:send(Alice, escalus_stanza:sm_request()),
escalus:assert(is_sm_ack, [3], escalus:wait_for_stanza(Alice)),
%% Ack, so that unacked messages don't go into offline store.
escalus:send(Alice, escalus_stanza:sm_ack(3 + NDiscarded))
escalus:send(Alice, escalus_stanza:sm_ack(3))
end).

h_non_given_closes_stream_gracefully(ConfigIn) ->
Expand Down Expand Up @@ -438,7 +434,7 @@ server_requests_ack(Config, N) ->
{Alice, _} = given_fresh_user(Config, alice),
%% ack request after initial presence
maybe_assert_ack_request(1, N, Alice),
StanzasRec = maybe_discard_vcard_update(1, N, Alice),
StanzasRec = 1,
ct:print("discarded"),
escalus:send(Bob, escalus_stanza:chat_to(Alice, <<"Hi, Alice!">>)),
escalus:assert(is_chat_message, [<<"Hi, Alice!">>],
Expand All @@ -455,14 +451,6 @@ maybe_assert_ack_request(StanzasRec, AckRequests, Alice) ->
end,
StanzasRec.

maybe_discard_vcard_update(StanzasRec, AckFreq, Alice) ->
case discard_vcard_update(Alice) of
0 ->
StanzasRec;
1 ->
maybe_assert_ack_request(StanzasRec + 1, AckFreq, Alice)
end.

server_requests_ack_freq_2(Config) ->
Config1 = escalus_users:update_userspec(Config, alice, manual_ack, true),
server_requests_ack(Config1, 2).
Expand Down Expand Up @@ -514,7 +502,6 @@ resend_unacked_on_reconnection(Config) ->
Messages = [<<"msg-1">>, <<"msg-2">>, <<"msg-3">>],
{Bob, _} = given_fresh_user(Config, bob),
{Alice, AliceSpec0} = given_fresh_user(Config, alice),
discard_vcard_update(Alice),
%% Bob sends some messages to Alice.
[escalus:send(Bob, escalus_stanza:chat_to(Alice, Msg))
|| Msg <- Messages],
Expand Down Expand Up @@ -796,7 +783,7 @@ session_established(Config) ->
AliceSpec = [{manual_ack, true}
| escalus_fresh:create_fresh_user(Config, alice)],
{Alice, _} = given_fresh_user_with_spec(AliceSpec),
{ok, C2SPid} = get_session_pid(AliceSpec, server_string("escalus-default-resource")),
{ok, C2SPid} = get_session_pid(AliceSpec, <<"escalus-default-resource">>),
assert_no_offline_msgs(AliceSpec),
assert_c2s_state(C2SPid, session_established),
escalus_connection:stop(Alice).
Expand Down Expand Up @@ -924,15 +911,14 @@ resume_session(Config) ->
%% Resume the session.
Steps = connection_steps_to_stream_resumption(SMID, 2),
{ok, Alice, _} = escalus_connection:start(AliceSpec, Steps),
NDiscarded = discard_vcard_update(Alice),
%% Alice receives the unacked messages from the previous
%% interrupted session.
Stanzas = [escalus_connection:get_stanza(Alice, {msg, I})
|| I <- lists:seq(1, 3)],
[escalus:assert(is_chat_message, [Msg], Stanza)
|| {Msg, Stanza} <- lists:zip(Messages, Stanzas)],
%% Alice acks the received messages.
escalus_connection:send(Alice, escalus_stanza:sm_ack(5 + NDiscarded)),
escalus_connection:send(Alice, escalus_stanza:sm_ack(5)),
escalus_connection:stop(Alice)
end).

Expand Down Expand Up @@ -997,7 +983,6 @@ resume_session_kills_old_C2S_gracefully(Config) ->
escalus_connection:send(Alice, InitialPresence),
Presence = escalus_connection:get_stanza(Alice, presence1),
escalus:assert(is_presence, Presence),
discard_vcard_update(Alice),

%% Monitor the C2S process and disconnect Alice.
MonitorRef = erlang:monitor(process, C2SPid),
Expand Down Expand Up @@ -1066,11 +1051,10 @@ buffer_unacked_messages_and_die(Config, AliceSpec, Bob, Messages) ->
escalus_connection:send(Alice, InitialPresence),
Presence = escalus_connection:get_stanza(Alice, presence1),
escalus:assert(is_presence, Presence),
Res = server_string("escalus-default-resource"),
Res = <<"escalus-default-resource">>,
{ok, C2SPid} = get_session_pid(AliceSpec, Res),
escalus_connection:send(Alice, escalus_stanza:presence(<<"available">>)),
_Presence = escalus_connection:get_stanza(Alice, presence2),
discard_vcard_update(Alice),
%% Bobs sends some messages to Alice.
[escalus:send(Bob, escalus_stanza:chat_to(JID, Msg))
|| Msg <- Messages],
Expand Down Expand Up @@ -1220,7 +1204,7 @@ messages_are_properly_flushed_during_resumption(Config) ->
escalus:assert(is_presence, Presence),
SMH = escalus_connection:get_sm_h(Alice),
escalus_client:kill_connection(Config, Alice),
{ok, C2SPid} = get_session_pid(AliceSpec, server_string("escalus-default-resource")),
{ok, C2SPid} = get_session_pid(AliceSpec, <<"escalus-default-resource">>),
ok = rpc(mim(), sys, suspend, [C2SPid]),

% WHEN new session requests resumption
Expand Down Expand Up @@ -1266,7 +1250,7 @@ messages_are_properly_flushed_during_resumption_p1_fsm_old(Config) ->
escalus:assert(is_presence, Presence),
SMH = escalus_connection:get_sm_h(Alice),
escalus_client:kill_connection(Config, Alice),
{ok, C2SPid} = get_session_pid(AliceSpec, server_string("escalus-default-resource")),
{ok, C2SPid} = get_session_pid(AliceSpec, <<"escalus-default-resource">>),
ok = rpc(mim(), sys, suspend, [C2SPid]),

%% send some dummy event. ignored by c2s but ensures that
Expand Down Expand Up @@ -1495,9 +1479,8 @@ get_sid_by_stream_id(SMID) ->
rpc(mim(), ?MOD_SM, get_sid, [SMID]).

get_us_from_spec(UserSpec) ->
ConfigUS = [proplists:get_value(username, UserSpec),
proplists:get_value(server, UserSpec)],
[U, S] = [server_string(V) || V <- ConfigUS],
U = proplists:get_value(username, UserSpec),
S = proplists:get_value(server, UserSpec),
{U, S}.

clear_session_table() ->
Expand Down
34 changes: 17 additions & 17 deletions big_tests/tests/vcard_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ end_per_suite(Config) ->

init_per_group(Group, Config) when Group == rw; Group == params_limited_infinity ->
restart_vcard_mod(Config, Group),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
{skip, ldap_vcard_is_readonly};
_ ->
Expand Down Expand Up @@ -462,7 +462,7 @@ search_wildcard(Config) ->
ExpectedItemTups = get_search_results(Config,
[<<"bobb@", Domain/binary>>,
<<"aliceb@", Domain/binary>>]),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
3 = length(ItemTups);
_ ->
Expand Down Expand Up @@ -498,7 +498,7 @@ search_rsm_pages(Config) ->
escalus:assert(is_iq_result, Res1),

RSMCount1 = get_rsm_count(Res1),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount1;
false ->
Expand Down Expand Up @@ -526,7 +526,7 @@ search_rsm_pages(Config) ->
escalus:assert(is_iq_result, Res2),

RSMCount2 = get_rsm_count(Res2),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount2;
false ->
Expand All @@ -538,7 +538,7 @@ search_rsm_pages(Config) ->
Config,
[<<"bobb@", SecDomain/binary>>,
<<"aliceb@", SecDomain/binary>>]),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
ignore;
_ ->
Expand Down Expand Up @@ -575,7 +575,7 @@ search_rsm_forward(Config) ->
escalus:assert(is_iq_result, Res1),

RSMCount1 = get_rsm_count(Res1),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount1;
false ->
Expand Down Expand Up @@ -604,7 +604,7 @@ search_rsm_forward(Config) ->
escalus:assert(is_iq_result, Res2),

RSMCount2 = get_rsm_count(Res2),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount2;
false ->
Expand All @@ -617,7 +617,7 @@ search_rsm_forward(Config) ->
Config,
[<<"bobb@", SecDomain/binary>>,
<<"aliceb@", SecDomain/binary>>]),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
ignore;
_ ->
Expand Down Expand Up @@ -645,7 +645,7 @@ search_rsm_forward(Config) ->
escalus:assert(is_iq_result, Res3),

RSMCount2 = get_rsm_count(Res3),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount2,
[_] = search_result_item_tuples(Res3);
Expand Down Expand Up @@ -684,7 +684,7 @@ search_rsm_backward(Config) ->
escalus:assert(is_iq_result, Res1),

RSMCount1 = get_rsm_count(Res1),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount1;
false ->
Expand Down Expand Up @@ -713,7 +713,7 @@ search_rsm_backward(Config) ->
escalus:assert(is_iq_result, Res2),

RSMCount2 = get_rsm_count(Res2),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount2;
false ->
Expand All @@ -726,7 +726,7 @@ search_rsm_backward(Config) ->
Config,
[<<"bobb@", SecDomain/binary>>,
<<"aliceb@", SecDomain/binary>>]),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
ignore;
_ ->
Expand Down Expand Up @@ -754,7 +754,7 @@ search_rsm_backward(Config) ->
escalus:assert(is_iq_result, Res3),

RSMCount2 = get_rsm_count(Res3),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount2,
[_] = search_result_item_tuples(Res3);
Expand Down Expand Up @@ -795,7 +795,7 @@ search_rsm_count(Config) ->
0 = length(ItemTups),

RSMCount = get_rsm_count(Res),
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
<<"3">> = RSMCount;
false ->
Expand Down Expand Up @@ -1417,7 +1417,7 @@ maybe_add_jabberd_id(JabberId) ->
maybe_add([{<<"JABBERID">>, JabberId}]).

maybe_add(Elems) ->
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
[];
_ ->
Expand Down Expand Up @@ -1471,7 +1471,7 @@ get_first_name_search_field() ->
get_search_field(<<"first">>, <<"givenName">>).

get_search_field(Default, LDAP) ->
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
LDAP;
_ ->
Expand Down Expand Up @@ -1520,7 +1520,7 @@ reported_fields() ->
] ++ maybe_add_jabberd_field().

maybe_add_jabberd_field() ->
case vcard_update:is_vcard_ldap() of
case vcard_helper:is_vcard_ldap() of
true ->
[];
_ ->
Expand Down
8 changes: 8 additions & 0 deletions big_tests/tests/vcard_helper.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-module(vcard_helper).
-compile([export_all, nowarn_export_all]).

-import(distributed_helper, [rpc/4, mim/0]).

is_vcard_ldap() ->
ldap == rpc(mim(), gen_mod, get_module_opt,
[ct:get_config({hosts, mim, domain}), mod_vcard, backend, mnesia]).
2 changes: 1 addition & 1 deletion big_tests/tests/vcard_simple_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
-define(EL(Element, Name), exml_query:path(Element, [{element, Name}])).
-define(EL_CD(Element, Name), exml_query:path(Element, [{element, Name}, cdata])).

-import(vcard_update, [is_vcard_ldap/0]).
-import(vcard_helper, [is_vcard_ldap/0]).

-import(distributed_helper, [mim/0,
require_rpc_nodes/1,
Expand Down
Loading

0 comments on commit a362d86

Please sign in to comment.