From 3094e2bafd28c030b7809cea7afca9eccfcd2f45 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 13 Sep 2018 15:57:39 +0100 Subject: [PATCH] Add test to check for receiving redacted events See https://github.com/matrix-org/synapse/pull/3859 --- tests/50federation/31room-send.pl | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/50federation/31room-send.pl b/tests/50federation/31room-send.pl index e4309072b..fc61bac8b 100644 --- a/tests/50federation/31room-send.pl +++ b/tests/50federation/31room-send.pl @@ -1,3 +1,5 @@ +use Protocol::Matrix qw( redact_event ); + test "Outbound federation can send events", requires => [ local_user_fixture(), $main::INBOUND_SERVER, federation_user_id_fixture() ], @@ -89,3 +91,52 @@ }); }); }; + +test "Inbound federation can receive redacted events", + requires => [ $main::OUTBOUND_CLIENT, $main::HOMESERVER_INFO[0], + local_user_and_room_fixtures( user_opts => { with_events => 1 }), + federation_user_id_fixture() ], + + do => sub { + my ( $outbound_client, $info, $creator, $room_id, $user_id ) = @_; + my $first_home_server = $info->server_name; + + my $local_server_name = $outbound_client->server_name; + + $outbound_client->join_room( + server_name => $first_home_server, + room_id => $room_id, + user_id => $user_id, + )->then( sub { + my ( $room ) = @_; + + my $event = $room->create_event( + type => "m.room.message", + + sender => $user_id, + content => { + body => "Hello", + }, + ); + + redact_event( $event ); + + $outbound_client->send_event( + event => $event, + destination => $first_home_server, + ); + })->then( sub { + await_event_for( $creator, filter => sub { + my ( $event ) = @_; + return unless $event->{type} eq "m.room.message"; + return unless $event->{room_id} eq $room_id; + + assert_eq( $event->{sender}, $user_id, + 'event sender' ); + assert_deeply_eq( $event->{content}, {}, + 'event content body' ); + + Future->done(1); + }); + }); + };