From ac23101b2ef767038dcc94af27941d374220d766 Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Tue, 18 Feb 2020 11:30:30 +0000 Subject: [PATCH] Update tests that assumed PL50 for room upgrade, fix others (#805) --- tests/30rooms/12thirdpartyinvite.pl | 29 ++++++++++++++++------ tests/30rooms/60version_upgrade.pl | 22 +++++----------- tests/41end-to-end-keys/06-device-lists.pl | 2 ++ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/tests/30rooms/12thirdpartyinvite.pl b/tests/30rooms/12thirdpartyinvite.pl index 1384453a0..cbaa0c4c0 100644 --- a/tests/30rooms/12thirdpartyinvite.pl +++ b/tests/30rooms/12thirdpartyinvite.pl @@ -44,7 +44,7 @@ }); }; -test "Can invite existing 3pid with no ops", +test "Can invite existing 3pid with no ops into a private room", requires => [ local_user_fixtures( 3 ), id_server_fixture() ], do => sub { @@ -57,7 +57,12 @@ $id_server->bind_identity( undef, "email", $invitee_email, $invitee ) ->then( sub { - matrix_create_and_join_room( [ $creator, $inviter ], visibility => "private", with_invite => 1 ) + matrix_create_and_join_room( + [ $creator, $inviter ], + visibility => "private", + preset => "private_chat", # Allow default PL users to invite others + with_invite => 1, + ) })->then( sub { ( $room_id ) = @_; @@ -155,7 +160,7 @@ }); }; -test "Can invite unbound 3pid with no ops", +test "Can invite unbound 3pid with no ops into a private room", requires => [ local_user_fixtures( 3 ), $main::HOMESERVER_INFO[0], id_server_fixture() ], @@ -163,14 +168,18 @@ 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 { + matrix_create_and_join_room( + [ $creator, $inviter ], + visibility => "private", + preset => "private_chat", # Allow default PL users to invite others + 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", +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() ], @@ -178,8 +187,12 @@ 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 { + 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 ); }); diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 0f1c8e0f5..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(), @@ -386,8 +387,6 @@ sub upgrade_room_synced { 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 { @@ -396,6 +395,11 @@ sub upgrade_room_synced { $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; } ) @@ -501,19 +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; - } - $levels->{users}->{$creator->user_id} = 50; - }, - ); - })->then( sub { matrix_sync( $creator ); })->then( sub { upgrade_room_synced( @@ -547,7 +538,6 @@ sub upgrade_room_synced { }); }; - 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 089d395d7..f2da9fb90 100644 --- a/tests/41end-to-end-keys/06-device-lists.pl +++ b/tests/41end-to-end-keys/06-device-lists.pl @@ -689,6 +689,8 @@ sub sync_until_user_in_device_list matrix_create_room( $creator, invite => [ $remote_user->user_id ], + # Allow default PL users to invite others + preset => "private_chat", )->then( sub { ( $room_id ) = @_;