-
Notifications
You must be signed in to change notification settings - Fork 59
Tests for e2e key backup interface #503
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
Conversation
Make sure keys from old backups don't appear in newly created ones element-hq/element-web#7448
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.
Wooo, tests! Sorry that I'm not a fan of interdependent tests :(
tests/41end-to-end-keys/07-backup.pl
Outdated
|
||
assert_json_keys( $content, "is_verified" ); | ||
|
||
assert_json_keys( $content, "session_data" ); |
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.
You can do:
assert_json_keys( $content, qw( first_message_index forwarded_count is_verified session_data ) )
tests/41end-to-end-keys/07-backup.pl
Outdated
is_verified => JSON::false, | ||
session_data => "anopaquestring", | ||
} | ||
); |
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.
weird indentation
tests/41end-to-end-keys/07-backup.pl
Outdated
content => { | ||
algorithm => "m.megolm_backup.v1", | ||
auth_data => "anopaquestring", | ||
} |
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 its going to be beneficial if we create matrix_create_backup_version
etc functions. There's already a fair bit of duplication and it'll make it easier to write more backup tests.
@@ -0,0 +1,387 @@ | |||
my $fixture = local_user_fixture(); | |||
|
|||
my $current_version; # FIXME: is there a better way of passing the backup version between tests? |
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 would prefer if each test was a standalone test, rather than there being implicit dependencies (it makes it harder to reason about each test and change later on).
I think once the APIs are split out into separate functions that will reduce boiler plate enough to make it feasible to just start from scratch for each test. There are also multi_test
if you want to do multiple tests in one run through.
tests/41end-to-end-keys/07-backup.pl
Outdated
assert_json_keys( $content, "session_data" ); | ||
|
||
$content->{first_message_index} == 1 or | ||
die "Expected first message index to match submitted data"; |
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 you want to use assert_eq( $content->{first_message_index}, 1, ".." )
as it will have better logging on failures (in terms of logging what the actual values were?)
Factor the common HTTP hits out into matrix_* subs and make the tests independent from one another.
This should be better! ptal :) |
No description provided.