Skip to content

Commit

Permalink
Merge pull request #465 from matrix-org/rav/fix_erasure_over_federation
Browse files Browse the repository at this point in the history
Ensure that events from erased users are redacted over federation
  • Loading branch information
richvdh authored Jul 24, 2018
2 parents 0040ad8 + 1a81419 commit 263ca2c
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/50federation/32room-getevent.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,75 @@
});
};


test "Inbound federation redacts events from erased users",
requires => [ $main::OUTBOUND_CLIENT, $main::HOMESERVER_INFO[0],
local_user_and_room_fixtures(),
federation_user_id_fixture() ],

do => sub {
my ( $outbound_client, $info, $creator, $room_id, $user_id ) = @_;
my $first_home_server = $info->server_name;

my $message_id;

$outbound_client->join_room(
server_name => $first_home_server,
room_id => $room_id,
user_id => $user_id,
)->then( sub {
my ( $room ) = @_;

# have the creator send a message into the room, which we will try to
# fetch.
matrix_send_room_text_message( $creator, $room_id, body => "body1" );
})->then( sub {
( $message_id ) = @_;

$outbound_client->do_request_json(
method => "GET",
hostname => $first_home_server,
uri => "/event/$message_id/",
);
})->then( sub {
my ( $body ) = @_;
log_if_fail "Fetched event before erasure", $body;

assert_json_keys( $body, qw( origin origin_server_ts pdus ));
assert_json_list( my $events = $body->{pdus} );

@$events == 1 or
die "Expected 1 event, found " . scalar(@$events);
my ( $event ) = @$events;

# Check that the content is right
assert_eq( $event->{content}->{body}, "body1" );

# now do the erasure
matrix_deactivate_account( $creator, erase => JSON::true );
})->then( sub {
# re-fetch the event
$outbound_client->do_request_json(
method => "GET",
hostname => $first_home_server,
uri => "/event/$message_id/",
);
})->then( sub {
my ( $body ) = @_;
log_if_fail "Fetched event after erasure", $body;

assert_json_keys( $body, qw( origin origin_server_ts pdus ));
assert_json_list( my $events = $body->{pdus} );

@$events == 1 or
die "Expected 1 event, found " . scalar(@$events);
my ( $event ) = @$events;

# Check that the content has been redacted
exists $event->{content}->{body} and
die "Event was not redacted";

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

0 comments on commit 263ca2c

Please sign in to comment.