Merge pull request #263 from simoleo89/fix/room-moderation-targets

fix(room-moderation): protect owners
This commit is contained in:
DuckieTM
2026-06-18 12:52:07 +02:00
committed by GitHub
2 changed files with 26 additions and 0 deletions
@@ -1625,6 +1625,9 @@ public class RoomManager {
if (rights != null && !room.hasRights(rights))
return;
if (room.getOwnerId() == userId)
return;
String name = "";
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
@@ -0,0 +1,23 @@
package com.eu.habbo.habbohotel.rooms;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertTrue;
class RoomManagerModerationContractTest {
@Test
void roomBanCannotTargetRoomOwner() throws Exception {
String source = Files.readString(Path.of("src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java"));
int rightsGuard = source.indexOf("rights != null && !room.hasRights(rights)");
int ownerGuard = source.indexOf("room.getOwnerId() == userId");
int banCreate = source.indexOf("new RoomBan(roomId, userId");
assertTrue(rightsGuard > -1, "room bans must require rights");
assertTrue(ownerGuard > rightsGuard, "room bans must guard owner targets after rights are checked");
assertTrue(ownerGuard < banCreate, "room owner must be rejected before a RoomBan is created");
}
}