Skip to content

Commit

Permalink
Add a test for asserting the notifications power levels of room ver 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed May 15, 2020
1 parent d10ad89 commit dbc682a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/30rooms/08levels.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

sub lockeddown_room_fixture
{
my ( %options ) = @_;

fixture(
requires => [ $creator_fixture, $user_fixture,
qw( can_change_power_levels ) ],

setup => sub {
my ( $creator, $test_user ) = @_;

matrix_create_and_join_room( [ $creator, $test_user ] )
matrix_create_and_join_room( [ $creator, $test_user ], %options )
->then( sub {
my ( $room_id ) = @_;

Expand Down Expand Up @@ -157,3 +159,24 @@ sub test_powerlevel
})->SyTest::pass_on_done( "Fails at setting 75" );
};
}

multi_test "Users cannot set notifications powerlevel higher than their own",
requires => [ $creator_fixture, $user_fixture, lockeddown_room_fixture( room_version => "6" ),
qw( can_change_power_levels )],

do => sub {
my ( $user, undef, $room_id ) = @_;

matrix_change_room_power_levels( $user, $room_id, sub {
my ( $levels ) = @_;

$levels->{notifications}{room} = 25;
})->SyTest::pass_on_done( "Succeeds at setting 25" )
->then( sub {
matrix_change_room_power_levels( $user, $room_id, sub {
my ( $levels ) = @_;

$levels->{notifications}{room} = 10000000;
})->main::expect_http_403
})->SyTest::pass_on_done( "Fails at setting 75" );
};

0 comments on commit dbc682a

Please sign in to comment.