-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gdpr retrieve data from mod_offline #2289
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## gdpr-retrieve-clean #2289 +/- ##
=======================================================
+ Coverage 78.93% 78.94% +<.01%
=======================================================
Files 334 334
Lines 29110 29023 -87
=======================================================
- Hits 22977 22911 -66
+ Misses 6133 6112 -21
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -57,7 +57,10 @@ retrieve_all(Username, Domain, ResultFilePath) -> | |||
-spec modules_with_personal_data() -> [module()]. | |||
modules_with_personal_data() -> | |||
[ | |||
mod_vcard | |||
mod_vcard, | |||
mod_offline_mnesia, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should call mod_offline
, not the backends directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense
src/mod_offline_mnesia.erl
Outdated
NowUniversal = calendar:now_to_universal_time(Timestamp), | ||
{UTCTime, UTCDiff} = jlib:timestamp_to_iso(NowUniversal, utc), | ||
UTC = list_to_binary(UTCTime ++ UTCDiff), | ||
{UTC, jid:to_binary(jid:to_bare(From)), jid:to_binary(jid:to_bare(To)), exml:to_binary(Packet)}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we converting these to bare JIDs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I used bare jids because there was assertion in test for bare jid so I assumed that it is the requirement
Do we want to return Full jids ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, no need to convert them to bare. The test case was just a stub, written without examining what is exactly stored in the DB.
{ok, Obj} = mongoose_riak:get(bucket_type(LServer), Key), | ||
|
||
PacketRaw = riakc_obj:get_value(Obj), | ||
{ok, Packet} = exml:parse(PacketRaw), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we parse it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, doesnt make sense as im parsing it back again. will remove :)
src/mod_offline_riak.erl
Outdated
NowUniversal = calendar:now_to_universal_time(usec:to_now(Timestamp)), | ||
{UTCTime, UTCDiff} = jlib:timestamp_to_iso(NowUniversal, utc), | ||
UTC = list_to_binary(UTCTime ++ UTCDiff), | ||
{UTC, jid:to_binary(jid:binary_to_bare(From)), To, exml:to_binary(Packet)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Username is provided as To
, not JID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think everything is fine, just again the variable name is confusing
src/mod_offline_rdbms.erl
Outdated
NowUniversal = calendar:now_to_universal_time(Timestamp), | ||
{UTCTime, UTCDiff} = jlib:timestamp_to_iso(NowUniversal, utc), | ||
UTC = list_to_binary(UTCTime ++ UTCDiff), | ||
[UTC, jid:to_binary(jid:binary_to_bare(SFrom)), User, SPacket]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JID is expected as third element, not username.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it is JID (https://github.com/esl/MongooseIM/pull/2289/files#diff-4fe7d08b2813e3e1da98142afd6341b7R164). The variable name is confusing
4b04179
to
7911c0e
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the common part for all backends must be extracted to mod_offline
. :)
big_tests/tests/gdpr_SUITE.erl
Outdated
@@ -47,14 +47,15 @@ groups() -> | |||
[ | |||
{retrieve_personal_data, [parallel], [ | |||
% per type | |||
retrieve_vcard, | |||
%% retrieve_vcard, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be reverted (after rebase) now as the base is fixed.
src/mod_offline_mnesia.erl
Outdated
NowUniversal = calendar:now_to_universal_time(Timestamp), | ||
{UTCTime, UTCDiff} = jlib:timestamp_to_iso(NowUniversal, utc), | ||
UTC = list_to_binary(UTCTime ++ UTCDiff), | ||
{UTC, jid:to_binary(jid:to_bare(From)), jid:to_binary(jid:to_bare(To)), exml:to_binary(Packet)}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, no need to convert them to bare. The test case was just a stub, written without examining what is exactly stored in the DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good, I would consider extracting changes in common base for other tests to separate PR.
big_tests/tests/gdpr_SUITE.erl
Outdated
ExpectedHeader = ["timestamp", "from", "to", "packet"], | ||
ExpectedItems = [ | ||
#{ "packet" => [{contains, Body}], "from" => BobJid } | ||
#{ "packet" => [{contains, Body1}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way of generating those maps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more readable to have:
Expected = [
{Body1, BobJid, AliceJid},
...],
ExpectedItems = lists:map(
fun({Body, From ,To) ->
#{ "packet" => [{contains, Body}],
"from" => binary_to_list(From),
"to" => binary_to_list(To),
"timestamp" => [{validate, fun validate_datetime/1}]}
end, Expected)
??
big_tests/tests/gdpr_SUITE.erl
Outdated
@@ -304,19 +322,25 @@ csv_to_maps(ExpectedHeader, [ExpectedHeader | Rows]) -> | |||
csv_row_to_map(Header, Row) -> | |||
maps:from_list(lists:zip(Header, Row)). | |||
|
|||
validate_personal_maps(_, []) -> ok; | |||
validate_personal_maps([Map | RMaps], [Checks | RChecks]) -> | |||
validate_personal_maps(PersonalMaps, ExpectedItems) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change affects all other PRs, isn't it going to break all other testcases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually its fixing them, as the order of incoming stanzas can result in bad validations
0474e31
to
a297028
Compare
7e6a2bc
to
dc92f71
Compare
This comment has been minimized.
This comment has been minimized.
big_tests/tests/gdpr_SUITE.erl
Outdated
%retrieve_private_xml, | ||
%retrieve_inbox, | ||
retrieve_logs | ||
%% retrieve_logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be done when rebasing on the base with "dynamic" PR merged.
0a040f8
to
1bd8de2
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retrieve_offline
test case is not enabled!mod_offline
doesn't query all backendsretrieve_offline
test is not added to the "with disabled" group
Oh sorry, something went wrong after rabase, fixing |
7b9b4a8
to
a4cd8ba
Compare
This comment has been minimized.
This comment has been minimized.
6465.1 / Erlang 19.3 / small_tests / 70b598f 6465.2 / Erlang 19.3 / internal_mnesia / 70b598f sm_SUITE:parallel:subscription_requests_are_buffered_properly{error,{{badmatch,false},
[{escalus_session,stream_management,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_session.erl"},
{line,227}]},
{escalus_connection,connection_step,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,134}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
{escalus_connection,start,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,118}]},
{sm_SUITE,'-subscription_requests_are_buffered_properly/1-fun-3-',6,
[{file,"sm_SUITE.erl"},{line,848}]},
{escalus_story,story,4,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1529}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1045}]}]}} sm_SUITE:parallel:subscription_requests_are_buffered_properly{error,{{badmatch,false},
[{escalus_session,stream_management,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_session.erl"},
{line,227}]},
{escalus_connection,connection_step,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,134}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
{escalus_connection,start,2,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,118}]},
{sm_SUITE,'-subscription_requests_are_buffered_properly/1-fun-3-',6,
[{file,"sm_SUITE.erl"},{line,848}]},
{escalus_story,story,4,
[{file,"/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1529}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1045}]}]}} 6465.3 / Erlang 19.3 / mysql_redis / 70b598f 6465.4 / Erlang 19.3 / odbc_mssql_mnesia / 70b598f 6465.6 / Erlang 19.3 / elasticsearch_and_cassandra_mnesia / 70b598f 6465.5 / Erlang 19.3 / ldap_mnesia / 70b598f 6465.8 / Erlang 20.0 / pgsql_mnesia / 70b598f 6465.9 / Erlang 21.0 / riak_mnesia / 70b598f |
ea799de
to
6861f96
Compare
6479.1 / Erlang 19.3 / small_tests / 5ee9077 6479.3 / Erlang 19.3 / mysql_redis / 5ee9077 6479.5 / Erlang 19.3 / ldap_mnesia / 5ee9077 6479.6 / Erlang 19.3 / elasticsearch_and_cassandra_mnesia / 5ee9077 6479.2 / Erlang 19.3 / internal_mnesia / 5ee9077 6479.4 / Erlang 19.3 / odbc_mssql_mnesia / 5ee9077 6479.8 / Erlang 20.0 / pgsql_mnesia / 5ee9077 6479.9 / Erlang 21.0 / riak_mnesia / 5ee9077 |
* Improve mod offline retrival test * Retrieve offline data from mnesia * Add support for RDBMS * Change timestamp format in rdbms return * Fetch personal data for offline in riak backend * Riak support for mod offline * dont do useless parsing, fix var names in mod_offline_riak * Call generic mod_offline instead of backend implementations * Move GDPR logic to generic mod_offline * Retrieve full jid * Shorten assertions in tests * Remove unimplemented function * fix fetching offline for riak * fix upper/lower case of jid issue * Enable mod_offline retrieve tests * merge reults from disabled backends as well * test offline retrieve with unloading module
This PR addresses https://erlangsolutions.atlassian.net/browse/MIM-306
TODO:
Notes:
2019-04-29T11:03:21Z