Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests that assumed PL50 for room upgrade, fix others #805

Merged
merged 10 commits into from
Feb 18, 2020
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
31 changes: 9 additions & 22 deletions tests/30rooms/60version_upgrade.pl
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,21 @@ 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 {
# 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;
}
( $pl_content ) = @_;
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
$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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to instead have the creator upgrade tbh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should stick this in a comment, but the bug that this tested for was a moderator getting upgraded to an admin in the old room. So changing the upgrader to be an admin initially may not preserve the test case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, Ok

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment.


log_if_fail "PL content in old room", $pl_content;
}
)
})->then( sub {
matrix_sync( $upgrader );
Expand Down Expand Up @@ -501,21 +504,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 );
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
})->then( sub {
upgrade_room_synced(
$creator, $room_id,
new_version => $TEST_NEW_VERSION,
Expand Down Expand Up @@ -547,7 +535,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