Skip to content

Commit

Permalink
Merge b694056 into 3c8c2e2
Browse files Browse the repository at this point in the history
  • Loading branch information
aleklisi authored May 13, 2019
2 parents 3c8c2e2 + b694056 commit c86c5df
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ branches:
- /^rel\-\d+\.\d+$/
- /^\d+\.\d+\.\d+([a-z0-9\-\+])*/
- gdpr-retrieve-clean
- gdpr-remove-vcard

otp_release:
- 19.3
Expand Down
40 changes: 35 additions & 5 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
retrieve_vcard/1,
remove_vcard/1,
retrieve_roster/1,
remove_roster/1,
retrieve_mam/1,
retrieve_offline/1,
retrieve_pubsub_payloads/1,
Expand Down Expand Up @@ -83,11 +84,13 @@ groups() ->
]},
{remove_personal_data, [], [
% per type
remove_vcard
remove_vcard,
remove_roster
]},
{remove_personal_data_with_mods_disabled, [], [
% per type
remove_vcard
remove_vcard,
remove_roster
]}
].

Expand Down Expand Up @@ -147,6 +150,10 @@ init_per_testcase(retrieve_mam = CN, Config) ->
dynamic_modules:ensure_modules(domain(), mam_required_modules(Backend)),
escalus:init_per_testcase(CN, Config)
end;
init_per_testcase(remove_roster = CN, Config) ->
dynamic_modules:ensure_modules(domain(), [{mod_roster, []}]),
escalus_fresh:clean(),
escalus:init_per_testcase(CN, Config);
init_per_testcase(CN, Config) ->
escalus:init_per_testcase(CN, Config).

Expand Down Expand Up @@ -238,14 +245,35 @@ retrieve_roster(Config) ->
escalus_story:make_all_clients_friends([Alice, Bob]),
BobU = escalus_utils:jid_to_lower(escalus_client:username(Bob)),
BobS = escalus_utils:jid_to_lower(escalus_client:server(Bob)),
ExpectedHeader = ["jid", "name", "subscription",
"ask", "groups", "askmessage", "xs"],
ExpectedItems = [
#{ "jid" => [{contains, BobU}, {contains, BobS}] }
],
maybe_stop_and_unload_module(mod_roster, mod_roster_backend, Config),
retrieve_and_validate_personal_data(
Alice, Config, "roster", ExpectedHeader, ExpectedItems)
Alice, Config, "roster", expected_header(mod_roster), ExpectedItems)
end).

remove_roster(Config) ->
escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) ->
escalus_story:make_all_clients_friends([Alice, Bob]),
AliceU = escalus_utils:jid_to_lower(escalus_client:username(Alice)),
AliceS = escalus_utils:jid_to_lower(escalus_client:server(Alice)),
ExpectedItems = [
#{ "jid" => [{contains, AliceU}, {contains, AliceS}] }
],

maybe_stop_and_unload_module(mod_roster, mod_roster_backend, Config),
{0, _} = unregister(Alice, Config),

mongoose_helper:wait_until(
fun() ->
mongoose_helper:successful_rpc(mod_roster, get_personal_data,
[AliceU, AliceS])
end,
[{roster, expected_header(mod_roster), []}]),
retrieve_and_validate_personal_data(
Bob, Config, "roster", expected_header(mod_roster), ExpectedItems)

end).

retrieve_mam(_Config) ->
Expand Down Expand Up @@ -608,3 +636,5 @@ item_content_xml(Data) ->
attrs = [{<<"xmlns">>, <<"http://www.w3.org/2005/Atom">>}],
children = [#xmlcdata{content = Data}]}.

expected_header(mod_roster) -> ["jid", "name", "subscription",
"ask", "groups", "askmessage", "xs"].
13 changes: 11 additions & 2 deletions src/mod_roster.erl
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,17 @@ remove_user(Acc, User, Server) ->
LUser = jid:nodeprep(User),
LServer = jid:nameprep(Server),
Acc1 = send_unsubscription_to_rosteritems(Acc, LUser, LServer),
R = mod_roster_backend:remove_user(LUser, LServer),
mongoose_lib:log_if_backend_error(R, ?MODULE, ?LINE, {User, Server}),
lists:foreach(fun(Backend) ->
try
Backend:remove_user(LUser, LServer)
catch
Class:Reason ->
StackTrace = erlang:get_stacktrace(),
?WARNING_MSG("event=cannot_delete_personal_data,"
"backend=~p,class=~p,reason=~p,stacktrace=~p",
[Backend, Class, Reason, StackTrace])
end
end, mongoose_lib:find_behaviour_implementations(mod_roster)),
Acc1.

%% For each contact with Subscription:
Expand Down

0 comments on commit c86c5df

Please sign in to comment.