Skip to content

Commit dbc682a

Browse files
committed
Add a test for asserting the notifications power levels of room ver 6.
1 parent d10ad89 commit dbc682a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

tests/30rooms/08levels.pl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
sub lockeddown_room_fixture
99
{
10+
my ( %options ) = @_;
11+
1012
fixture(
1113
requires => [ $creator_fixture, $user_fixture,
1214
qw( can_change_power_levels ) ],
1315

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

17-
matrix_create_and_join_room( [ $creator, $test_user ] )
19+
matrix_create_and_join_room( [ $creator, $test_user ], %options )
1820
->then( sub {
1921
my ( $room_id ) = @_;
2022

@@ -157,3 +159,24 @@ sub test_powerlevel
157159
})->SyTest::pass_on_done( "Fails at setting 75" );
158160
};
159161
}
162+
163+
multi_test "Users cannot set notifications powerlevel higher than their own",
164+
requires => [ $creator_fixture, $user_fixture, lockeddown_room_fixture( room_version => "6" ),
165+
qw( can_change_power_levels )],
166+
167+
do => sub {
168+
my ( $user, undef, $room_id ) = @_;
169+
170+
matrix_change_room_power_levels( $user, $room_id, sub {
171+
my ( $levels ) = @_;
172+
173+
$levels->{notifications}{room} = 25;
174+
})->SyTest::pass_on_done( "Succeeds at setting 25" )
175+
->then( sub {
176+
matrix_change_room_power_levels( $user, $room_id, sub {
177+
my ( $levels ) = @_;
178+
179+
$levels->{notifications}{room} = 10000000;
180+
})->main::expect_http_403
181+
})->SyTest::pass_on_done( "Fails at setting 75" );
182+
};

0 commit comments

Comments
 (0)