You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
fix(room-moderation): protect owners
This commit is contained in:
@@ -1625,6 +1625,9 @@ public class RoomManager {
|
|||||||
if (rights != null && !room.hasRights(rights))
|
if (rights != null && !room.hasRights(rights))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (room.getOwnerId() == userId)
|
||||||
|
return;
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
|
|
||||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||||
|
|||||||
+23
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user