Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:matrix-org/sytest into neilj/pri…
Browse files Browse the repository at this point in the history
…vacy_by_default_room_dir
  • Loading branch information
neilisfragile committed Dec 4, 2019
2 parents 8d3b785 + afd2b6f commit 6e2a45c
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ sub start

require_membership_for_aliases => "false",

# Enable ephemeral message support (MSC2228)
enable_ephemeral_messages => "true",

$self->{recaptcha_config} ? (
recaptcha_siteverify_api => $self->{recaptcha_config}->{siteverify_api},
recaptcha_public_key => $self->{recaptcha_config}->{public_key},
Expand Down
50 changes: 50 additions & 0 deletions tests/30rooms/04messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,53 @@
})
});
};

# Test for MSC2228 for local messages.
test "Ephemeral messages received from clients are correctly expired",
requires => [ local_user_and_room_fixtures() ],

do => sub {
my ( $user, $room_id ) = @_;

my $now_ms = int( time() * 1000 );
my $filter = '{"types":["m.room.message"]}';

matrix_send_room_message( $user, $room_id,
content => {
msgtype => "m.text",
body => "This is a message",
"org.matrix.self_destruct_after" => $now_ms + 1000,
},
)->then( sub {
await_sync_timeline_contains($user, $room_id, check => sub {
my ($event) = @_;
return $event->{content}{body} eq "This is a message"
})
})->then( sub {
# wait for the message to expire
delay( 1.5 )
})->then( sub {
my $iter = 0;
retry_until_success {
matrix_get_room_messages( $user, $room_id, filter => $filter )->then( sub {
$iter++;
my ( $body ) = @_;
log_if_fail "Iteration $iter: response body after expiry", $body;

my $chunk = $body->{chunk};

@$chunk == 1 or
die "Expected 1 message";

# Check that we can't read the message's content after its expiry.
assert_deeply_eq( $chunk->[0]{content}, {}, 'chunk[0] content size' );

Future->done(1);
})->on_fail( sub {
my ( $exc ) = @_;
chomp $exc;
log_if_fail "Iteration $iter: not ready yet: $exc";
});
}
});
};
56 changes: 56 additions & 0 deletions tests/50federation/31room-send.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use Time::HiRes qw( time );
use Protocol::Matrix qw( redact_event );


Expand Down Expand Up @@ -145,3 +146,58 @@
});
});
};

# Test for MSC2228 for messages received through federation.
test "Ephemeral messages received from servers are correctly expired",
requires => [ local_user_and_room_fixtures(), remote_user_fixture() ],

do => sub {
my ( $local_user, $room_id, $federated_user ) = @_;

my $filter = '{"types":["m.room.message"]}';

matrix_invite_user_to_room( $local_user, $federated_user, $room_id )->then( sub {
matrix_join_room( $federated_user, $room_id )
})->then( sub {
my $now_ms = int( time() * 1000 );

matrix_send_room_message( $local_user, $room_id,
content => {
msgtype => "m.text",
body => "This is a message",
"org.matrix.self_destruct_after" => $now_ms + 1000,
},
)
})->then( sub {
await_sync_timeline_contains($local_user, $room_id, check => sub {
my ($event) = @_;
return $event->{content}{body} eq "This is a message"
})
})->then( sub {
# wait for the message to expire
delay( 1.5 )
})->then( sub {
my $iter = 0;
retry_until_success {
matrix_get_room_messages( $local_user, $room_id, filter => $filter )->then( sub {
$iter++;
my ( $body ) = @_;
log_if_fail "Iteration $iter: response body after expiry", $body;

my $chunk = $body->{chunk};

@$chunk == 1 or
die "Expected 1 message";

# Check that we can't read the message's content after its expiry.
assert_deeply_eq( $chunk->[0]{content}, {}, 'chunk[0] content size' );

Future->done(1);
})->on_fail( sub {
my ( $exc ) = @_;
chomp $exc;
log_if_fail "Iteration $iter: not ready yet: $exc";
});
}
});
};

0 comments on commit 6e2a45c

Please sign in to comment.