diff --git a/tests/30rooms/05aliases.pl b/tests/30rooms/05aliases.pl index b6cbe592d..46e026e44 100644 --- a/tests/30rooms/05aliases.pl +++ b/tests/30rooms/05aliases.pl @@ -158,6 +158,26 @@ } )->main::expect_matrix_error( 400, "M_INVALID_PARAM" ) ->SyTest::pass_on_done( "m.room.canonical_alias rejects invalid aliases" ); + })->then( sub { + # Create a second room with an alias on it. + my $other_alias_name = $room_alias_name . "2"; + + matrix_create_room( $user, + room_alias_name => $other_alias_name, + )->then( sub { + my ( $other_room_id, $other_room_alias ) = @_; + + # Attempt to set a canonical alias for the original room using an + # alias from the second room. + matrix_put_room_state( $user, $room_id, + type => "m.room.canonical_alias", + content => { + alias => $room_alias, + alt_aliases => [ $other_room_alias ], + } + )->main::expect_matrix_error( 400, "M_BAD_ALIAS" ) + ->SyTest::pass_on_done( "m.room.canonical_alias rejects alias pointing to different room" ); + }) }); };