|
7 | 7 |
|
8 | 8 | sub lockeddown_room_fixture |
9 | 9 | { |
| 10 | + my ( %options ) = @_; |
| 11 | + |
10 | 12 | fixture( |
11 | 13 | requires => [ $creator_fixture, $user_fixture, |
12 | 14 | qw( can_change_power_levels ) ], |
13 | 15 |
|
14 | 16 | setup => sub { |
15 | 17 | my ( $creator, $test_user ) = @_; |
16 | 18 |
|
17 | | - matrix_create_and_join_room( [ $creator, $test_user ] ) |
| 19 | + matrix_create_and_join_room( [ $creator, $test_user ], %options ) |
18 | 20 | ->then( sub { |
19 | 21 | my ( $room_id ) = @_; |
20 | 22 |
|
@@ -157,3 +159,24 @@ sub test_powerlevel |
157 | 159 | })->SyTest::pass_on_done( "Fails at setting 75" ); |
158 | 160 | }; |
159 | 161 | } |
| 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