From 833612501ccd20f60f8eced1256d114c916b28f4 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 3 Feb 2020 18:38:46 +0000 Subject: [PATCH 1/9] Remove tests that assumed PL50 for room upgrade, fix others --- tests/30rooms/12thirdpartyinvite.pl | 72 ----------------- tests/30rooms/60version_upgrade.pl | 91 +--------------------- tests/41end-to-end-keys/06-device-lists.pl | 4 +- 3 files changed, 6 insertions(+), 161 deletions(-) diff --git a/tests/30rooms/12thirdpartyinvite.pl b/tests/30rooms/12thirdpartyinvite.pl index 1384453a0..728b5e8fa 100644 --- a/tests/30rooms/12thirdpartyinvite.pl +++ b/tests/30rooms/12thirdpartyinvite.pl @@ -44,48 +44,6 @@ }); }; -test "Can invite existing 3pid with no ops", - requires => [ local_user_fixtures( 3 ), id_server_fixture() ], - - do => sub { - my ( $creator, $inviter, $invitee, $id_server ) = @_; - - my $invitee_mxid = $invitee->user_id; - - my $room_id; - my $id_access_token = $id_server->get_access_token; - - $id_server->bind_identity( undef, "email", $invitee_email, $invitee ) - ->then( sub { - matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", with_invite => 1 ) - })->then( sub { - ( $room_id ) = @_; - - do_request_json_for( $inviter, - method => "POST", - uri => "/r0/rooms/$room_id/invite", - - content => { - id_server => $id_server->name, - id_access_token => $id_access_token, - medium => "email", - address => $invitee_email, - }, - ); - })->then( sub { - matrix_get_room_state( $inviter, $room_id, - type => "m.room.member", - state_key => $invitee_mxid, - ); - })->on_done( sub { - my ( $body ) = @_; - - log_if_fail "Body", $body; - assert_eq( $body->{membership}, "invite", - 'invited user membership' ); - }); - }; - test "Can invite existing 3pid in createRoom", requires => [ local_user_fixtures( 2 ), id_server_fixture() ], @@ -155,36 +113,6 @@ }); }; -test "Can invite unbound 3pid with no ops", - requires => [ local_user_fixtures( 3 ), $main::HOMESERVER_INFO[0], - id_server_fixture() ], - - do => sub { - my ( $creator, $inviter, $invitee, $info, $id_server ) = @_; - my $hs_uribase = $info->client_location; - - matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", with_invite => 1 ) - ->then( sub { - my ( $room_id ) = @_; - can_invite_unbound_3pid( $room_id, $inviter, $invitee, $hs_uribase, $id_server ); - }); - }; - -test "Can invite unbound 3pid over federation with no ops", - requires => [ local_user_fixtures( 2 ), remote_user_fixture(), - $main::HOMESERVER_INFO[1], id_server_fixture() ], - - do => sub { - my ( $creator, $inviter, $invitee, $info, $id_server ) = @_; - my $hs_uribase = $info->client_location; - - matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", with_invite => 1 ) - ->then( sub { - my ( $room_id ) = @_; - can_invite_unbound_3pid( $room_id, $inviter, $invitee, $hs_uribase, $id_server ); - }); - }; - sub can_invite_unbound_3pid { my ( $room_id, $inviter, $invitee, $hs_uribase, $id_server ) = @_; diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 51f5f37f9..4f9b61c7b 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -374,94 +374,6 @@ sub upgrade_room_synced { }); }; -test "/upgrade preserves the power level of the upgrading user in old and new rooms", - requires => [ - local_user_and_room_fixtures(), - local_user_fixture(), - qw( can_upgrade_room_version can_change_power_levels ), - ], - - do => sub { - my ( $creator, $room_id, $upgrader ) = @_; - - my ( $pl_content, $new_room_id ); - - # Note that this test assumes that moderators by default are allowed to upgrade rooms - - matrix_join_room_synced( - $upgrader, $room_id - )->then( sub { - # Make the joined user a moderator - matrix_change_room_power_levels( - $creator, $room_id, sub { - ( $pl_content ) = @_; - $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); - log_if_fail "PL content in old room", $pl_content; - } - ) - })->then( sub { - matrix_sync( $upgrader ); - })->then( sub { - upgrade_room_synced( - $upgrader, $room_id, - expected_event_counts => { 'm.room.power_levels' => 1 }, - new_version => $TEST_NEW_VERSION, - ); - })->then( sub { - ( $new_room_id, ) = @_; - - matrix_sync_again( $upgrader ); - })->then( sub { - my ( $sync_body ) = @_; - - log_if_fail "sync body", $sync_body; - - # Two power level events will be sent in the new room. The first is to make the - # upgrader user (previously a moderator) an Administrator (which can only be done - # when creating the room). This is such that they could send the initial state - # events. The second power level event is to downgrade the upgrader user from a - # Administrator to a Moderator again to keep a consistent state with the old room - - # Grab the latest power level state of the new room - my $url_encoded_new_room_id = uri_escape( $new_room_id ); - do_request_json_for( - $upgrader, - method => "GET", - uri => "/r0/rooms/$url_encoded_new_room_id/state/m.room.power_levels/", - content => {}, - ); - })->then( sub { - my ( $new_room_pl_content ) = @_; - - # Check that the power levels in the new room match the original PLs - assert_deeply_eq( - $new_room_pl_content, - $pl_content, - "power levels in replacement room", - ); - - # Grab the latest power level state of the old room - my $url_encoded_old_room_id = uri_escape( $room_id ); - do_request_json_for( - $upgrader, - method => "GET", - uri => "/r0/rooms/$url_encoded_old_room_id/state/m.room.power_levels/", - content => {}, - ); - })->then( sub { - my ( $old_room_pl_content ) = @_; - - # Check that the power levels in the old room have not changed - assert_deeply_eq( - $old_room_pl_content, - $pl_content, - "power levels in old room", - ); - - Future->done(1); - }); - }; - test "/upgrade copies important state to the new room", requires => [ local_user_and_room_fixtures(), @@ -510,6 +422,9 @@ sub upgrade_room_synced { foreach my $k ( keys %STATE_DICT ) { $levels->{events}->{$k} = 80; } + # Modify tombstone requirements to 50 so we are able to upgrade the room + $levels->{events}->{"m.room.tombstone"} = 50; + $levels->{users}->{$creator->user_id} = 50; }, ); diff --git a/tests/41end-to-end-keys/06-device-lists.pl b/tests/41end-to-end-keys/06-device-lists.pl index 089d395d7..7fd5b6843 100644 --- a/tests/41end-to-end-keys/06-device-lists.pl +++ b/tests/41end-to-end-keys/06-device-lists.pl @@ -687,8 +687,10 @@ sub sync_until_user_in_device_list my ( $room_id, $from_token, $to_token ); - matrix_create_room( $creator, + matrix_create_room($creator, invite => [ $remote_user->user_id ], + # Allow default PL users to invite others + preset => "private_chat", )->then( sub { ( $room_id ) = @_; From e381a9237e1aa8938f31544320e871c88cd6cdc8 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 17 Feb 2020 12:23:16 +0000 Subject: [PATCH 2/9] Re-add tests, but change semantics to be in a private room --- tests/30rooms/12thirdpartyinvite.pl | 85 +++++++++++++++++++++++++++ tests/30rooms/60version_upgrade.pl | 90 +++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) diff --git a/tests/30rooms/12thirdpartyinvite.pl b/tests/30rooms/12thirdpartyinvite.pl index 728b5e8fa..232283dee 100644 --- a/tests/30rooms/12thirdpartyinvite.pl +++ b/tests/30rooms/12thirdpartyinvite.pl @@ -44,6 +44,53 @@ }); }; +test "Can invite existing 3pid with no ops into a private room", + requires => [ local_user_fixtures( 3 ), id_server_fixture() ], + + do => sub { + my ( $creator, $inviter, $invitee, $id_server ) = @_; + + my $invitee_mxid = $invitee->user_id; + + my $room_id; + my $id_access_token = $id_server->get_access_token; + + $id_server->bind_identity( undef, "email", $invitee_email, $invitee ) + ->then( sub { + matrix_create_and_join_room( + [ $creator, $inviter ], + visibility => "private", + preset => "private_chat", + with_invite => 1, + ) + })->then( sub { + ( $room_id ) = @_; + + do_request_json_for( $inviter, + method => "POST", + uri => "/r0/rooms/$room_id/invite", + + content => { + id_server => $id_server->name, + id_access_token => $id_access_token, + medium => "email", + address => $invitee_email, + }, + ); + })->then( sub { + matrix_get_room_state( $inviter, $room_id, + type => "m.room.member", + state_key => $invitee_mxid, + ); + })->on_done( sub { + my ( $body ) = @_; + + log_if_fail "Body", $body; + assert_eq( $body->{membership}, "invite", + 'invited user membership' ); + }); + }; + test "Can invite existing 3pid in createRoom", requires => [ local_user_fixtures( 2 ), id_server_fixture() ], @@ -113,6 +160,44 @@ }); }; +test "Can invite unbound 3pid with no ops into a private room", + requires => [ local_user_fixtures( 3 ), $main::HOMESERVER_INFO[0], + id_server_fixture() ], + + do => sub { + my ( $creator, $inviter, $invitee, $info, $id_server ) = @_; + my $hs_uribase = $info->client_location; + + matrix_create_and_join_room( + [ $creator, $inviter ], + visibility => "private", + preset => "private_chat", + with_invite => 1, + )->then( sub { + my ( $room_id ) = @_; + can_invite_unbound_3pid( $room_id, $inviter, $invitee, $hs_uribase, $id_server ); + }); + }; + +test "Can invite unbound 3pid over federation with no ops into a private room", + requires => [ local_user_fixtures( 2 ), remote_user_fixture(), + $main::HOMESERVER_INFO[1], id_server_fixture() ], + + do => sub { + my ( $creator, $inviter, $invitee, $info, $id_server ) = @_; + my $hs_uribase = $info->client_location; + + matrix_create_and_join_room( + [ $creator, $inviter ], + visibility => "private", + preset => "private_chat", + with_invite => 1, + )->then( sub { + my ( $room_id ) = @_; + can_invite_unbound_3pid( $room_id, $inviter, $invitee, $hs_uribase, $id_server ); + }); + }; + sub can_invite_unbound_3pid { my ( $room_id, $inviter, $invitee, $hs_uribase, $id_server ) = @_; diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index f720c5710..4f5b7f784 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -462,6 +462,96 @@ sub upgrade_room_synced { }); }; +test "/upgrade preserves the power level of the upgrading user in old and new rooms", + requires => [ + local_user_and_room_fixtures(), + local_user_fixture(), + qw( can_upgrade_room_version can_change_power_levels ), + ], + + do => sub { + my ( $creator, $room_id, $upgrader ) = @_; + + my ( $pl_content, $new_room_id ); + + matrix_join_room_synced( + $upgrader, $room_id + )->then( sub { + # Make the joined user a moderator + matrix_change_room_power_levels( + $creator, $room_id, sub { + ( $pl_content ) = @_; + $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); + + # Note that this test assumes that moderators by default are allowed to upgrade rooms + # Change the PL rules to allow moderators to send tombstones + $pl_content->{events}->{"m.room.tombstone"} = JSON::number(50); + + log_if_fail "PL content in old room", $pl_content; + } + ) + })->then( sub { + matrix_sync( $upgrader ); + })->then( sub { + upgrade_room_synced( + $upgrader, $room_id, + expected_event_counts => { 'm.room.power_levels' => 1 }, + new_version => $TEST_NEW_VERSION, + ); + })->then( sub { + ( $new_room_id, ) = @_; + + matrix_sync_again( $upgrader ); + })->then( sub { + my ( $sync_body ) = @_; + + log_if_fail "sync body", $sync_body; + + # Two power level events will be sent in the new room. The first is to make the + # upgrader user (previously a moderator) an Administrator (which can only be done + # when creating the room). This is such that they could send the initial state + # events. The second power level event is to downgrade the upgrader user from a + # Administrator to a Moderator again to keep a consistent state with the old room + + # Grab the latest power level state of the new room + my $url_encoded_new_room_id = uri_escape( $new_room_id ); + do_request_json_for( + $upgrader, + method => "GET", + uri => "/r0/rooms/$url_encoded_new_room_id/state/m.room.power_levels/", + content => {}, + ); + })->then( sub { + my ( $new_room_pl_content ) = @_; + + # Check that the power levels in the new room match the original PLs + assert_deeply_eq( + $new_room_pl_content, + $pl_content, + "power levels in replacement room", + ); + + # Grab the latest power level state of the old room + my $url_encoded_old_room_id = uri_escape( $room_id ); + do_request_json_for( + $upgrader, + method => "GET", + uri => "/r0/rooms/$url_encoded_old_room_id/state/m.room.power_levels/", + content => {}, + ); + })->then( sub { + my ( $old_room_pl_content ) = @_; + + # Check that the power levels in the old room have not changed + assert_deeply_eq( + $old_room_pl_content, + $pl_content, + "power levels in old room", + ); + + Future->done(1); + }); + }; test "/upgrade copies ban events to the new room", requires => [ From e9767712c85b3af08dabef472840a7b0b10aea58 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 10:22:15 +0000 Subject: [PATCH 3/9] Review comments --- tests/30rooms/60version_upgrade.pl | 183 +++++++++++---------- tests/41end-to-end-keys/06-device-lists.pl | 2 +- 2 files changed, 93 insertions(+), 92 deletions(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 4f5b7f784..ca42a60ee 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -374,6 +374,98 @@ sub upgrade_room_synced { }); }; +test "/upgrade preserves the power level of the upgrading user in old and new rooms", + requires => [ + local_user_and_room_fixtures(), + local_user_fixture(), + qw( can_upgrade_room_version can_change_power_levels ), + ], + + do => sub { + my ( $creator, $room_id, $upgrader ) = @_; + + my ( $pl_content, $new_room_id ); + + matrix_join_room_synced( + $upgrader, $room_id + )->then( sub { + # Make the joined user a moderator + matrix_change_room_power_levels( + $creator, $room_id, sub { + ( $pl_content ) = @_; + $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); + + # Note that this test assumes that moderators by default are allowed to upgrade rooms + # Change the PL rules to allow moderators to send tombstones + $pl_content->{events}->{"m.room.tombstone"} = JSON::number(50); + + log_if_fail "PL content in old room", $pl_content; + } + ) + })->then( sub { + matrix_sync( $upgrader ); + })->then( sub { + upgrade_room_synced( + $upgrader, $room_id, + expected_event_counts => { 'm.room.power_levels' => 1 }, + new_version => $TEST_NEW_VERSION, + ); + })->then( sub { + ( $new_room_id, ) = @_; + + matrix_sync_again( $upgrader ); + })->then( sub { + my ( $sync_body ) = @_; + + log_if_fail "sync body", $sync_body; + + # Two power level events will be sent in the new room. The first is to make the + # upgrader user (previously a moderator) an Administrator (which can only be done + # when creating the room). This is such that they could send the initial state + # events. The second power level event is to downgrade the upgrader user from a + # Administrator to a Moderator again to keep a consistent state with the old room + + # Grab the latest power level state of the new room + my $url_encoded_new_room_id = uri_escape( $new_room_id ); + do_request_json_for( + $upgrader, + method => "GET", + uri => "/r0/rooms/$url_encoded_new_room_id/state/m.room.power_levels/", + content => {}, + ); + })->then( sub { + my ( $new_room_pl_content ) = @_; + + # Check that the power levels in the new room match the original PLs + assert_deeply_eq( + $new_room_pl_content, + $pl_content, + "power levels in replacement room", + ); + + # Grab the latest power level state of the old room + my $url_encoded_old_room_id = uri_escape( $room_id ); + do_request_json_for( + $upgrader, + method => "GET", + uri => "/r0/rooms/$url_encoded_old_room_id/state/m.room.power_levels/", + content => {}, + ); + })->then( sub { + my ( $old_room_pl_content ) = @_; + + # Check that the power levels in the old room have not changed + assert_deeply_eq( + $old_room_pl_content, + $pl_content, + "power levels in old room", + ); + + Future->done(1); + }); + }; + + test "/upgrade copies important state to the new room", requires => [ local_user_and_room_fixtures(), @@ -462,97 +554,6 @@ sub upgrade_room_synced { }); }; -test "/upgrade preserves the power level of the upgrading user in old and new rooms", - requires => [ - local_user_and_room_fixtures(), - local_user_fixture(), - qw( can_upgrade_room_version can_change_power_levels ), - ], - - do => sub { - my ( $creator, $room_id, $upgrader ) = @_; - - my ( $pl_content, $new_room_id ); - - matrix_join_room_synced( - $upgrader, $room_id - )->then( sub { - # Make the joined user a moderator - matrix_change_room_power_levels( - $creator, $room_id, sub { - ( $pl_content ) = @_; - $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); - - # Note that this test assumes that moderators by default are allowed to upgrade rooms - # Change the PL rules to allow moderators to send tombstones - $pl_content->{events}->{"m.room.tombstone"} = JSON::number(50); - - log_if_fail "PL content in old room", $pl_content; - } - ) - })->then( sub { - matrix_sync( $upgrader ); - })->then( sub { - upgrade_room_synced( - $upgrader, $room_id, - expected_event_counts => { 'm.room.power_levels' => 1 }, - new_version => $TEST_NEW_VERSION, - ); - })->then( sub { - ( $new_room_id, ) = @_; - - matrix_sync_again( $upgrader ); - })->then( sub { - my ( $sync_body ) = @_; - - log_if_fail "sync body", $sync_body; - - # Two power level events will be sent in the new room. The first is to make the - # upgrader user (previously a moderator) an Administrator (which can only be done - # when creating the room). This is such that they could send the initial state - # events. The second power level event is to downgrade the upgrader user from a - # Administrator to a Moderator again to keep a consistent state with the old room - - # Grab the latest power level state of the new room - my $url_encoded_new_room_id = uri_escape( $new_room_id ); - do_request_json_for( - $upgrader, - method => "GET", - uri => "/r0/rooms/$url_encoded_new_room_id/state/m.room.power_levels/", - content => {}, - ); - })->then( sub { - my ( $new_room_pl_content ) = @_; - - # Check that the power levels in the new room match the original PLs - assert_deeply_eq( - $new_room_pl_content, - $pl_content, - "power levels in replacement room", - ); - - # Grab the latest power level state of the old room - my $url_encoded_old_room_id = uri_escape( $room_id ); - do_request_json_for( - $upgrader, - method => "GET", - uri => "/r0/rooms/$url_encoded_old_room_id/state/m.room.power_levels/", - content => {}, - ); - })->then( sub { - my ( $old_room_pl_content ) = @_; - - # Check that the power levels in the old room have not changed - assert_deeply_eq( - $old_room_pl_content, - $pl_content, - "power levels in old room", - ); - - Future->done(1); - }); - }; - test "/upgrade copies ban events to the new room", requires => [ local_user_and_room_fixtures(), diff --git a/tests/41end-to-end-keys/06-device-lists.pl b/tests/41end-to-end-keys/06-device-lists.pl index 7fd5b6843..f2da9fb90 100644 --- a/tests/41end-to-end-keys/06-device-lists.pl +++ b/tests/41end-to-end-keys/06-device-lists.pl @@ -687,7 +687,7 @@ sub sync_until_user_in_device_list my ( $room_id, $from_token, $to_token ); - matrix_create_room($creator, + matrix_create_room( $creator, invite => [ $remote_user->user_id ], # Allow default PL users to invite others preset => "private_chat", From 9ed260919fba17cc4444c7be606376d112733671 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 10:32:27 +0000 Subject: [PATCH 4/9] Remove PL50 mod test --- tests/30rooms/60version_upgrade.pl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index ca42a60ee..3144b57c2 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -505,24 +505,6 @@ sub upgrade_room_synced { } $f->then( sub { - # to make things harder, we now restrict our ability to change each of - # those states: the server should make sure it sets up the state - # *before* it replicates the PL. - matrix_change_room_power_levels( - $creator, $room_id, sub { - my ( $levels ) = @_; - foreach my $k ( keys %STATE_DICT ) { - $levels->{events}->{$k} = 80; - } - # Modify tombstone requirements to 50 so we are able to upgrade the room - $levels->{events}->{"m.room.tombstone"} = 50; - - $levels->{users}->{$creator->user_id} = 50; - }, - ); - })->then( sub { - matrix_sync( $creator ); - })->then( sub { upgrade_room_synced( $creator, $room_id, new_version => $TEST_NEW_VERSION, From 334e3109a8eae5ecb94f5f2b92adf1531baf0bbd Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 10:33:23 +0000 Subject: [PATCH 5/9] Remove extra space --- tests/30rooms/60version_upgrade.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 3144b57c2..e92b0ef3d 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -465,7 +465,6 @@ sub upgrade_room_synced { }); }; - test "/upgrade copies important state to the new room", requires => [ local_user_and_room_fixtures(), From a951cd2242992277a8c255a97567d541c663c98a Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 10:34:28 +0000 Subject: [PATCH 6/9] Add some helpful comments --- tests/30rooms/12thirdpartyinvite.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/30rooms/12thirdpartyinvite.pl b/tests/30rooms/12thirdpartyinvite.pl index 232283dee..cbaa0c4c0 100644 --- a/tests/30rooms/12thirdpartyinvite.pl +++ b/tests/30rooms/12thirdpartyinvite.pl @@ -60,7 +60,7 @@ matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", - preset => "private_chat", + preset => "private_chat", # Allow default PL users to invite others with_invite => 1, ) })->then( sub { @@ -171,7 +171,7 @@ matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", - preset => "private_chat", + preset => "private_chat", # Allow default PL users to invite others with_invite => 1, )->then( sub { my ( $room_id ) = @_; From 735bfb3ff8c83482deb54d06ad8744e3c1750057 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 11:01:32 +0000 Subject: [PATCH 7/9] Return matrix_sync back --- tests/30rooms/60version_upgrade.pl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index e92b0ef3d..debf2aa13 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -392,15 +392,15 @@ sub upgrade_room_synced { # Make the joined user a moderator matrix_change_room_power_levels( $creator, $room_id, sub { - ( $pl_content ) = @_; - $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); + ( $pl_content ) = @_; + $pl_content->{users}->{$upgrader->user_id} = JSON::number(50); - # Note that this test assumes that moderators by default are allowed to upgrade rooms - # Change the PL rules to allow moderators to send tombstones - $pl_content->{events}->{"m.room.tombstone"} = JSON::number(50); + # Note that this test assumes that moderators by default are allowed to upgrade rooms + # Change the PL rules to allow moderators to send tombstones + $pl_content->{events}->{"m.room.tombstone"} = JSON::number(50); - log_if_fail "PL content in old room", $pl_content; - } + log_if_fail "PL content in old room", $pl_content; + } ) })->then( sub { matrix_sync( $upgrader ); @@ -504,6 +504,8 @@ sub upgrade_room_synced { } $f->then( sub { + matrix_sync( $creator ); + }->then( sub { upgrade_room_synced( $creator, $room_id, new_version => $TEST_NEW_VERSION, From 522b21e39a8ef94e5a9c0346ad452e145f94eca7 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 11:03:15 +0000 Subject: [PATCH 8/9] Closing paran --- tests/30rooms/60version_upgrade.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index debf2aa13..9939ea533 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -505,7 +505,7 @@ sub upgrade_room_synced { $f->then( sub { matrix_sync( $creator ); - }->then( sub { + })->then( sub { upgrade_room_synced( $creator, $room_id, new_version => $TEST_NEW_VERSION, From fff43315f550c375e5081b8484ea8a15e496b332 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 18 Feb 2020 11:07:34 +0000 Subject: [PATCH 9/9] Add context comment --- tests/30rooms/60version_upgrade.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 9939ea533..4e847e5c2 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -374,6 +374,7 @@ sub upgrade_room_synced { }); }; +# See https://github.com/matrix-org/synapse/issues/6632 for details test "/upgrade preserves the power level of the upgrading user in old and new rooms", requires => [ local_user_and_room_fixtures(),