Skip to content

Commit

Permalink
Update tests that assumed PL50 for room upgrade, fix others (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 authored Feb 18, 2020
1 parent dfb664d commit ac23101
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
29 changes: 21 additions & 8 deletions tests/30rooms/12thirdpartyinvite.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ) = @_;

Expand Down Expand Up @@ -155,31 +160,39 @@
});
};

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() ],

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 {
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() ],

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 {
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 );
});
Expand Down
22 changes: 6 additions & 16 deletions tests/30rooms/60version_upgrade.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 {
Expand All @@ -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;
}
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -547,7 +538,6 @@ sub upgrade_room_synced {
});
};


test "/upgrade copies ban events to the new room",
requires => [
local_user_and_room_fixtures(),
Expand Down
2 changes: 2 additions & 0 deletions tests/41end-to-end-keys/06-device-lists.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) = @_;

Expand Down

0 comments on commit ac23101

Please sign in to comment.