From 4e08d6b66c3025b7256afec9743c136731a85e88 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 31 Aug 2020 19:42:20 +0300 Subject: [PATCH 01/16] first cut at a test for MSC2753 on dendrite --- tests/31sync/17peeking.pl | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/31sync/17peeking.pl diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl new file mode 100644 index 000000000..f2644273f --- /dev/null +++ b/tests/31sync/17peeking.pl @@ -0,0 +1,58 @@ +use Future::Utils qw( repeat ); + +# Tests MSC2753 style peeking + +test "Local users can peek by room ID", + requires => [ local_user_and_room_fixtures(), local_user_fixture() ], + + check => sub { + my ( $user, $room_id, $peeking_user ) = @_; + + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek")->then(sub { + do_request_json_for( $peeking_user, + method => "POST", + uri => "/r0/peek/$room_id", + ) + })->then(sub { + matrix_sync( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + + my $room = $body->{rooms}{peek}{$room_id}; + assert_json_keys( $room, qw( timeline state ephemeral )); + assert_json_keys( $room->{timeline}, qw( events limited prev_batch )); + assert_json_keys( $room->{state}, qw( events )); + assert_json_keys( $room->{ephemeral}, qw( events )); + + # TODO: check that state and timeline is 'right' + # TODO: check that peeked room doesn't show up in the 'join' room + + matrix_sync_again( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + + my $room = $body->{rooms}{peek}{$room_id}; + (!defined $room) or die "Unchanged rooms shouldn't be in the sync response"; + })->then( sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek") + })->then( sub { + matrix_sync_again( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + + my $room = $body->{rooms}{peek}{$room_id}; + # TODO: check that the new message shows up in the 'peek' block + + Future->done(1) + }) + }; + +# test "Local users can peek by room alias", + +# test "Peeked rooms only turn up in the sync for the device who peeked them" + +# test "Users can unpeek from rooms" + +# test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking", + +# test "Parting a room which was joined after being peeked" From 9ca6148776b3c1900779c38c5a723a50f8fd70a3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 31 Aug 2020 23:33:02 +0300 Subject: [PATCH 02/16] make test run --- tests/31sync/17peeking.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index f2644273f..f2d5f3606 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -12,6 +12,7 @@ do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/$room_id", + content => {}, ) })->then(sub { matrix_sync( $peeking_user ); From 3ee4dc5e11caea2ca6398db34d84eb872d6c677e Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 31 Aug 2020 23:33:13 +0300 Subject: [PATCH 03/16] warn about sodium version --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index 55cc8217d..71d7abaf2 100644 --- a/README.rst +++ b/README.rst @@ -90,6 +90,11 @@ some configuration output, rather than an error:: $ pkg-config --libs libsodium -L/usr/local/Cellar/libsodium/1.0.8/lib -lsodium +It's possible that Crypt::NaCL::Sodium has got out of sync with brew's libsodium, +causing errors about aes128ctr, which was removed in 1.0.8.1 of libsodium. +In which case you may want to strip out the aes128ctr stuff from Sodium.xs to +get it to install... :/ + Then force an install of Crypt::NaCl::Sodium:: $ cpan From 41dd900013f4471cce2372ce7337495776d747ea Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 1 Sep 2020 21:57:07 +0100 Subject: [PATCH 04/16] first passing test :) --- tests/31sync/17peeking.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index f2d5f3606..7f64ec8d8 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -19,19 +19,26 @@ })->then( sub { my ( $body ) = @_; + log_if_fail "first sync response", $body; + my $room = $body->{rooms}{peek}{$room_id}; assert_json_keys( $room, qw( timeline state ephemeral )); assert_json_keys( $room->{timeline}, qw( events limited prev_batch )); assert_json_keys( $room->{state}, qw( events )); assert_json_keys( $room->{ephemeral}, qw( events )); - # TODO: check that state and timeline is 'right' - # TODO: check that peeked room doesn't show up in the 'join' room + assert_ok( $room->{timeline}->{events}->[0]->{type} eq 'm.room.create', "peek has m.room.create" ); + assert_ok( $room->{timeline}->{events}->[-1]->{type} eq 'm.room.message', "peek has message type" ); + assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something to peek', "peek has message body" ); + assert_ok( @{$room->{state}->{events}} == 0 ); + + assert_ok( scalar keys(%{$body->{rooms}{join}}) == 0, "no joined rooms present"); matrix_sync_again( $peeking_user ); })->then( sub { my ( $body ) = @_; + log_if_fail "second sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; (!defined $room) or die "Unchanged rooms shouldn't be in the sync response"; })->then( sub { @@ -41,8 +48,11 @@ })->then( sub { my ( $body ) = @_; + log_if_fail "third sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; - # TODO: check that the new message shows up in the 'peek' block + + assert_ok( $room->{timeline}->{events}->[-1]->{type} eq 'm.room.message', "second peek has message type" ); + assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something else to peek', "second peek has message body" ); Future->done(1) }) From f7d696d058adecfdfbe844bafe33dd80dd571407 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 1 Sep 2020 22:20:31 +0100 Subject: [PATCH 05/16] test peeking by alias --- tests/31sync/17peeking.pl | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index 7f64ec8d8..f8f58e051 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -58,12 +58,41 @@ }) }; -# test "Local users can peek by room alias", +my $room_alias_name = sprintf("peektest-%s", $TEST_RUN_ID); +test "Local users can peek by room alias", + requires => [ + local_user_and_room_fixtures(room_opts => { room_alias_name => $room_alias_name, $TEST_RUN_ID}), + local_user_fixture() + ], + + check => sub { + my ( $user, $room_id, $peeking_user ) = @_; + + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek")->then(sub { + do_request_json_for( $peeking_user, + method => "POST", + uri => "/r0/peek/#$room_alias_name:".$user->http->server_name, + content => {}, + ) + })->then(sub { + matrix_sync( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + + log_if_fail "first sync response", $body; + + my $room = $body->{rooms}{peek}{$room_id}; + assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something to peek', "peek has message body" ); + Future->done(1) + }) + }; + +# test "We can't peek into private rooms" # test "Peeked rooms only turn up in the sync for the device who peeked them" # test "Users can unpeek from rooms" -# test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking", +# test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking" # test "Parting a room which was joined after being peeked" From ff13930d483c3372593a28f2f66ef136c7a66cc7 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 1 Sep 2020 22:42:59 +0100 Subject: [PATCH 06/16] add test that only the peeking device get peeked msgs --- tests/31sync/17peeking.pl | 53 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index f8f58e051..7704b7595 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -58,10 +58,11 @@ }) }; + my $room_alias_name = sprintf("peektest-%s", $TEST_RUN_ID); test "Local users can peek by room alias", requires => [ - local_user_and_room_fixtures(room_opts => { room_alias_name => $room_alias_name, $TEST_RUN_ID}), + local_user_and_room_fixtures(room_opts => { room_alias_name => $room_alias_name }), local_user_fixture() ], @@ -87,9 +88,55 @@ }) }; -# test "We can't peek into private rooms" -# test "Peeked rooms only turn up in the sync for the device who peeked them" +test "Peeked rooms only turn up in the sync for the device who peeked them", + requires => [ local_user_and_room_fixtures(), local_user_fixture() ], + + check => sub { + my ( $user, $room_id, $peeking_user ) = @_; + my ( $peeking_user_device2 ); + + matrix_login_again_with_user($peeking_user)->then(sub { + $peeking_user_device2 = $_[0]; + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek") + })->then(sub { + do_request_json_for( $peeking_user, + method => "POST", + uri => "/r0/peek/$room_id", + content => {}, + ) + })->then(sub { + matrix_sync( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + log_if_fail "device 1 first sync response", $body; + my $room = $body->{rooms}{peek}{$room_id}; + assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something to peek', "peek has message body" ); + })->then(sub { + matrix_sync( $peeking_user_device2 ); + })->then( sub { + my ( $body ) = @_; + log_if_fail "device 2 first sync response", $body; + assert_ok( scalar keys(%{$body->{rooms}{peek}}) == 0, "no peeked rooms present"); + })->then( sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek") + })->then( sub { + matrix_sync_again( $peeking_user ); + })->then( sub { + my ( $body ) = @_; + log_if_fail "device 1 second sync response", $body; + my $room = $body->{rooms}{peek}{$room_id}; + assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something else to peek', "second peek has message body" ); + matrix_sync_again( $peeking_user_device2 ); + })->then( sub { + my ( $body ) = @_; + log_if_fail "device 2 second sync response", $body; + assert_ok( scalar keys(%{$body->{rooms}{peek}}) == 0, "still no peeked rooms present"); + Future->done(1) + }) + }; + +# test "We can't peek into private rooms" # test "Users can unpeek from rooms" From cac05b1458e5c69a46a3afb75984b1dfab16d727 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 1 Sep 2020 23:19:08 +0100 Subject: [PATCH 07/16] add failing test for ensuring peeks require world_readable history visibility --- tests/31sync/17peeking.pl | 48 +++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index 7704b7595..2bd46080f 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -2,13 +2,15 @@ # Tests MSC2753 style peeking -test "Local users can peek by room ID", +test "Local users can peek into world_readable rooms by room ID", requires => [ local_user_and_room_fixtures(), local_user_fixture() ], check => sub { my ( $user, $room_id, $peeking_user ) = @_; - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek")->then(sub { + matrix_set_room_history_visibility( $user, $room_id, "world_readable" )->then(sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); + })->then(sub { do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/$room_id", @@ -42,7 +44,7 @@ my $room = $body->{rooms}{peek}{$room_id}; (!defined $room) or die "Unchanged rooms shouldn't be in the sync response"; })->then( sub { - matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek") + matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek"); })->then( sub { matrix_sync_again( $peeking_user ); })->then( sub { @@ -59,6 +61,31 @@ }; +for my $visibility (qw(shared invited joined)) { + test "We can't peek into rooms with $visibility history_visibility", + requires => [ local_user_and_room_fixtures(), local_user_fixture() ], + + check => sub { + my ( $user, $room_id, $peeking_user ) = @_; + + matrix_set_room_history_visibility( $user, $room_id, $visibility )->then(sub { + do_request_json_for( $peeking_user, + method => "POST", + uri => "/r0/peek/$room_id", + content => {}, + ); + })->main::expect_http_403() + ->then( sub { + my ( $response ) = @_; + my $body = decode_json( $response->content ); + log_if_fail "error body", $body; + assert_eq( $body->{errcode}, "M_FORBIDDEN", 'responsecode' ); + Future->done( 1 ); + }); + }; +} + + my $room_alias_name = sprintf("peektest-%s", $TEST_RUN_ID); test "Local users can peek by room alias", requires => [ @@ -69,7 +96,9 @@ check => sub { my ( $user, $room_id, $peeking_user ) = @_; - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek")->then(sub { + matrix_set_room_history_visibility( $user, $room_id, "world_readable" )->then(sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); + })->then(sub { do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/#$room_alias_name:".$user->http->server_name, @@ -88,7 +117,6 @@ }) }; - test "Peeked rooms only turn up in the sync for the device who peeked them", requires => [ local_user_and_room_fixtures(), local_user_fixture() ], @@ -96,9 +124,11 @@ my ( $user, $room_id, $peeking_user ) = @_; my ( $peeking_user_device2 ); - matrix_login_again_with_user($peeking_user)->then(sub { + matrix_set_room_history_visibility( $user, $room_id, "world_readable" )->then(sub { + matrix_login_again_with_user($peeking_user); + })->then(sub { $peeking_user_device2 = $_[0]; - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek") + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); })->then(sub { do_request_json_for( $peeking_user, method => "POST", @@ -136,10 +166,10 @@ }) }; -# test "We can't peek into private rooms" - # test "Users can unpeek from rooms" # test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking" # test "Parting a room which was joined after being peeked" + +# test "Changing history visibility to non-world_readable terminates peeks" \ No newline at end of file From fb08c360ab5e8483b204f02d66caf16ca6640b0c Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 3 Sep 2020 22:15:14 +0100 Subject: [PATCH 08/16] fix worldreadable test; add new stubs --- tests/31sync/17peeking.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index 2bd46080f..2b46710ca 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -1,4 +1,5 @@ use Future::Utils qw( repeat ); +use JSON qw( decode_json ); # Tests MSC2753 style peeking @@ -168,8 +169,10 @@ # test "Users can unpeek from rooms" +# test "Peeking with full_state=true does the right thing" + # test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking" -# test "Parting a room which was joined after being peeked" +# test "Parting a room which was joined after being peeked doesn't go back to being peeked" -# test "Changing history visibility to non-world_readable terminates peeks" \ No newline at end of file +# test "Changing history visibility to non-world_readable terminates peeks" From 9a7cbd96051b0a497b4a6fd3fb02edb58b031f85 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 8 Sep 2020 00:50:10 +0100 Subject: [PATCH 09/16] derace matrix_sync --- tests/31sync/17peeking.pl | 60 +++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index 2b46710ca..943f52618 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -17,10 +17,18 @@ uri => "/r0/peek/$room_id", content => {}, ) - })->then(sub { - matrix_sync( $peeking_user ); + })->then( sub { + await_sync( $peeking_user, + since => $peeking_user->sync_next_batch, + check => sub { + my ( $body ) = @_; + return 0 unless $body->{rooms}{peek}{$room_id}; + return $body; + } + ) })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "first sync response", $body; @@ -40,6 +48,7 @@ matrix_sync_again( $peeking_user ); })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "second sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; @@ -47,9 +56,17 @@ })->then( sub { matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek"); })->then( sub { - matrix_sync_again( $peeking_user ); + await_sync( $peeking_user, + since => $peeking_user->sync_next_batch, + check => sub { + my ( $body ) = @_; + return 0 unless $body->{rooms}{peek}{$room_id}; + return $body; + } + ) })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "third sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; @@ -61,7 +78,6 @@ }) }; - for my $visibility (qw(shared invited joined)) { test "We can't peek into rooms with $visibility history_visibility", requires => [ local_user_and_room_fixtures(), local_user_fixture() ], @@ -106,9 +122,17 @@ content => {}, ) })->then(sub { - matrix_sync( $peeking_user ); + await_sync( $peeking_user, + since => $peeking_user->sync_next_batch, + check => sub { + my ( $body ) = @_; + return 0 unless $body->{rooms}{peek}{$room_id}; + return $body; + } + ) })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "first sync response", $body; @@ -137,14 +161,23 @@ content => {}, ) })->then(sub { - matrix_sync( $peeking_user ); + await_sync( $peeking_user, + since => $peeking_user->sync_next_batch, + check => sub { + my ( $body ) = @_; + return 0 unless $body->{rooms}{peek}{$room_id}; + return $body; + } + ) })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "device 1 first sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something to peek', "peek has message body" ); })->then(sub { - matrix_sync( $peeking_user_device2 ); + # FIXME: racey - this may return blank due to the peek not having taken effect yet + matrix_sync( $peeking_user_device2, timeout => 1000 ); })->then( sub { my ( $body ) = @_; log_if_fail "device 2 first sync response", $body; @@ -152,13 +185,22 @@ })->then( sub { matrix_send_room_text_message_synced( $user, $room_id, body => "something else to peek") })->then( sub { - matrix_sync_again( $peeking_user ); + await_sync( $peeking_user, + since => $peeking_user->sync_next_batch, + check => sub { + my ( $body ) = @_; + return 0 unless $body->{rooms}{peek}{$room_id}; + return $body; + } + ) })->then( sub { my ( $body ) = @_; + $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "device 1 second sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; assert_ok( $room->{timeline}->{events}->[-1]->{content}->{body} eq 'something else to peek', "second peek has message body" ); - matrix_sync_again( $peeking_user_device2 ); + # FIXME: racey - this may return blank due to the peek not having taken effect yet + matrix_sync_again( $peeking_user_device2, timeout => 1000 ); })->then( sub { my ( $body ) = @_; log_if_fail "device 2 second sync response", $body; From ef863afd0671c4b725ead66ff60db8294ed0d9d8 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 9 Sep 2020 02:37:09 +0100 Subject: [PATCH 10/16] remove rogue line --- tests/31sync/17peeking.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index 943f52618..e5346dbfe 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -48,7 +48,6 @@ matrix_sync_again( $peeking_user ); })->then( sub { my ( $body ) = @_; - $peeking_user->sync_next_batch = $body->{next_batch}; log_if_fail "second sync response", $body; my $room = $body->{rooms}{peek}{$room_id}; From 03b26e7effe5ea25613e33f477884837a68f1287 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 9 Sep 2020 11:25:26 +0100 Subject: [PATCH 11/16] allow running against dendrite + sqlite --- lib/SyTest/Homeserver/Dendrite.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SyTest/Homeserver/Dendrite.pm b/lib/SyTest/Homeserver/Dendrite.pm index 9c02c2eec..75d2d472a 100644 --- a/lib/SyTest/Homeserver/Dendrite.pm +++ b/lib/SyTest/Homeserver/Dendrite.pm @@ -63,7 +63,8 @@ sub _check_db_config my $self = shift; my ( %config ) = @_; - $config{type} eq "pg" or die "Dendrite can only run against postgres"; + # We're in the business of running sytest against dendrite+sqlite these days + #$config{type} eq "pg" or die "Dendrite can only run against postgres"; return $self->SUPER::_check_db_config( @_ ); } From feb60691965c9089ddf50e3e5651cb5a71914e8b Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 9 Sep 2020 11:25:54 +0100 Subject: [PATCH 12/16] fix spurious r flag causing a warning --- lib/SyTest/Homeserver/ProcessManager.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SyTest/Homeserver/ProcessManager.pm b/lib/SyTest/Homeserver/ProcessManager.pm index 00e953439..4aa3c9b0f 100644 --- a/lib/SyTest/Homeserver/ProcessManager.pm +++ b/lib/SyTest/Homeserver/ProcessManager.pm @@ -316,7 +316,7 @@ sub _await_ready_notification # We replace null byte with '@' to allow us to pass it in via env. (This is # as per the sd_notify spec). my $path_env = $path; - $path_env =~ s/\0/\@/rg; + $path_env =~ s/\0/\@/g; $env->{"NOTIFY_SOCKET"} = $path_env; # Create a future that gets resolved when we receive a `READY=1` From d62a4de5b4c1846d47c05720248d40961c3a2019 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 9 Sep 2020 11:36:47 +0100 Subject: [PATCH 13/16] disambiguate room alias to ensure re-running the test doesn't break --- tests/10apidoc/30room-create.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/10apidoc/30room-create.pl b/tests/10apidoc/30room-create.pl index 91c726588..cc7f52f7f 100644 --- a/tests/10apidoc/30room-create.pl +++ b/tests/10apidoc/30room-create.pl @@ -16,7 +16,7 @@ content => { visibility => "public", # This is just the localpart - room_alias_name => "30room-create", + room_alias_name => "30room-create-".time, }, )->then( sub { my ( $body ) = @_; From d9a7427adf13b6c9d7fc13afb0216d2ccfebded8 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 10 Sep 2020 10:25:51 +0100 Subject: [PATCH 14/16] fix race: send the peekable msg after rather than before the /peek --- tests/31sync/17peeking.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index e5346dbfe..eb105cf02 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -10,14 +10,14 @@ my ( $user, $room_id, $peeking_user ) = @_; matrix_set_room_history_visibility( $user, $room_id, "world_readable" )->then(sub { - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); - })->then(sub { do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/$room_id", content => {}, ) })->then( sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); + })->then(sub { await_sync( $peeking_user, since => $peeking_user->sync_next_batch, check => sub { @@ -77,6 +77,7 @@ }) }; + for my $visibility (qw(shared invited joined)) { test "We can't peek into rooms with $visibility history_visibility", requires => [ local_user_and_room_fixtures(), local_user_fixture() ], @@ -113,13 +114,13 @@ my ( $user, $room_id, $peeking_user ) = @_; matrix_set_room_history_visibility( $user, $room_id, "world_readable" )->then(sub { - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); - })->then(sub { do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/#$room_alias_name:".$user->http->server_name, content => {}, ) + })->then(sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); })->then(sub { await_sync( $peeking_user, since => $peeking_user->sync_next_batch, @@ -152,13 +153,13 @@ matrix_login_again_with_user($peeking_user); })->then(sub { $peeking_user_device2 = $_[0]; - matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); - })->then(sub { do_request_json_for( $peeking_user, method => "POST", uri => "/r0/peek/$room_id", content => {}, ) + })->then(sub { + matrix_send_room_text_message_synced( $user, $room_id, body => "something to peek"); })->then(sub { await_sync( $peeking_user, since => $peeking_user->sync_next_batch, From 50557244ecb51e7e937984d5663f7a1be777cab1 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 10 Sep 2020 10:28:47 +0100 Subject: [PATCH 15/16] #942 got fixed --- README.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.rst b/README.rst index 71d7abaf2..55cc8217d 100644 --- a/README.rst +++ b/README.rst @@ -90,11 +90,6 @@ some configuration output, rather than an error:: $ pkg-config --libs libsodium -L/usr/local/Cellar/libsodium/1.0.8/lib -lsodium -It's possible that Crypt::NaCL::Sodium has got out of sync with brew's libsodium, -causing errors about aes128ctr, which was removed in 1.0.8.1 of libsodium. -In which case you may want to strip out the aes128ctr stuff from Sodium.xs to -get it to install... :/ - Then force an install of Crypt::NaCl::Sodium:: $ cpan From ae7243051f588bd692ac9210d48612c0046bfa72 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 10 Sep 2020 12:32:33 +0100 Subject: [PATCH 16/16] add stub test --- tests/31sync/17peeking.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/31sync/17peeking.pl b/tests/31sync/17peeking.pl index eb105cf02..2e23ead0e 100644 --- a/tests/31sync/17peeking.pl +++ b/tests/31sync/17peeking.pl @@ -211,6 +211,8 @@ # test "Users can unpeek from rooms" +# test "Users can peek, unpeek and peek again" + # test "Peeking with full_state=true does the right thing" # test "Joining a peeked room moves it atomically from peeked to joined rooms and stops peeking"