You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-20 07:26:18 +00:00
fix(rcon): bound mute and achievement mutations
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.eu.habbo.messages.rcon;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class MuteUserGuardTest {
|
||||
@Test
|
||||
void parsesInvalidDurationCeilingsAsDefault() {
|
||||
assertEquals(MuteUser.DEFAULT_MAX_DURATION_SECONDS, MuteUser.parseMaxDuration(null));
|
||||
assertEquals(MuteUser.DEFAULT_MAX_DURATION_SECONDS, MuteUser.parseMaxDuration("-1"));
|
||||
assertEquals(0, MuteUser.parseMaxDuration("0"));
|
||||
assertEquals(60, MuteUser.parseMaxDuration("60"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsNegativeAndOversizedMuteDurations() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/com/eu/habbo/messages/rcon/MuteUser.java"));
|
||||
|
||||
assertTrue(source.contains("json.duration < 0 || json.duration > maxDuration"),
|
||||
"RCON mute must reject negative durations and configured-duration overflows");
|
||||
assertTrue(source.contains("json.duration == 0 ? 0 : Emulator.getIntUnixTimestamp() + json.duration"),
|
||||
"Offline unmute must clear mute_end_timestamp instead of writing the current timestamp");
|
||||
assertTrue(source.contains("rcon.mute.max_duration_seconds"),
|
||||
"RCON mute duration ceiling must be configurable");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.eu.habbo.messages.rcon;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class ProgressAchievementGuardTest {
|
||||
@Test
|
||||
void parsesInvalidProgressCeilingsAsDefault() {
|
||||
assertEquals(ProgressAchievement.DEFAULT_MAX_PROGRESS, ProgressAchievement.parseMaxProgress(null));
|
||||
assertEquals(ProgressAchievement.DEFAULT_MAX_PROGRESS, ProgressAchievement.parseMaxProgress("0"));
|
||||
assertEquals(50, ProgressAchievement.parseMaxProgress("50"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void validatesAchievementProgressPayload() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/com/eu/habbo/messages/rcon/ProgressAchievement.java"));
|
||||
|
||||
assertTrue(source.contains("@Positive(message = \"invalid user\")"),
|
||||
"RCON achievement progress must reject invalid target users before execution");
|
||||
assertTrue(source.contains("@Positive(message = \"invalid achievement\")"),
|
||||
"RCON achievement progress must reject invalid achievement ids before execution");
|
||||
assertTrue(source.contains("@Positive(message = \"invalid progress\")"),
|
||||
"RCON achievement progress must reject zero or negative progress before execution");
|
||||
assertTrue(source.contains("json.progress > maxProgress"),
|
||||
"RCON achievement progress must reject configured-progress overflows");
|
||||
assertTrue(source.contains("rcon.achievement.max_progress"),
|
||||
"RCON achievement progress ceiling must be configurable");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user