Skip to content

Commit

Permalink
ensure that deleted devices are replicated over federation
Browse files Browse the repository at this point in the history
regression test for element-hq/element-web#4527
  • Loading branch information
ara4n committed Jul 12, 2018
1 parent 9515cd8 commit 42c1f0f
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/41end-to-end-keys/06-device-lists.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use Future::Utils qw( try_repeat_until_success );
use Devel::StackTrace;

sub is_user_in_changed_list
{
Expand All @@ -21,6 +22,9 @@ sub sync_until_user_in_device_list

my $wait_for_id = $user_to_wait_for->user_id;

my $trace = Devel::StackTrace->new(no_args => 1);
log_if_fail $trace->frame(1)->as_string();

$msg = "$msg: waiting for $wait_for_id in $device_list";

return repeat_until_true {
Expand All @@ -39,6 +43,7 @@ sub sync_until_user_in_device_list
};
}


test "Local device key changes appear in v2 /sync",
requires => [ local_user_fixtures( 2 ),
qw( can_sync ) ],
Expand Down Expand Up @@ -234,6 +239,71 @@ sub sync_until_user_in_device_list
};


# regression test for https://github.com/vector-im/riot-web/issues/4527
test "Device deletion propagates over federation",
requires => [ local_user_fixture(), remote_user_fixture(),
qw( can_upload_e2e_keys )],


check => sub {
my ( $user1, $user2 ) = @_;

my $room_id;

matrix_create_room( $user1 )->then( sub {
( $room_id ) = @_;

matrix_invite_user_to_room( $user1, $user2, $room_id )
})->then( sub {
matrix_join_room( $user2, $room_id );
})->then( sub {
matrix_sync( $user1 );
})->then( sub {
matrix_put_e2e_keys( $user2 )
})->then( sub {
sync_until_user_in_device_list( $user1, $user2 );
})->then( sub {
matrix_set_device_display_name( $user2, $user2->device_id, "test display name" ),
})->then( sub {
sync_until_user_in_device_list( $user1, $user2 );
})->then( sub {
matrix_delete_device( $user2, $user2->device_id, {
auth => {
type => "m.login.password",
user => $user2->user_id,
password => $user2->password,
}
});
})->then( sub {
sync_until_user_in_device_list( $user1, $user2 );
})->then( sub {
do_request_json_for( $user1,
method => "POST",
uri => "/unstable/keys/query",
content => {
device_keys => {
$user2->user_id => {}
}
}
)
})->then( sub {
my ( $content ) = @_;

log_if_fail "key query content", $content;

assert_json_keys( $content, "device_keys" );

my $device_keys = $content->{device_keys};
assert_json_keys( $device_keys, $user2->user_id );

assert_deeply_eq( $device_keys->{$user2->user_id}, {},
"user2's device has been deleted" );

Future->done(1);
});
};


# Check that when a remote user leaves and rejoins between calls to sync their
# key still comes down in the changes list
test "If remote user leaves room, changes device and rejoins we see update in sync",
Expand Down

0 comments on commit 42c1f0f

Please sign in to comment.