Normalize integration source text without changing pinned texture bytes

This commit is contained in:
Dev 2026-11-23 20:29:15 +01:00
commit a6d4389470

View file

@ -1,25 +1,25 @@
package com.dunerealms.gui;
import java.util.Map;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PlanetMaterialPolicyTest {
@Test void exactWorldAliasesDoNotLeakPlanetTexturesIntoNetherOrUnknownWorlds(){
var aliases=Map.of("arrakduin","arrakis","guild_lobby","guild","world","caladan");
assertEquals("arrakis",PlanetMaterialPolicy.profile("Arrakduin",aliases));
assertEquals("guild",PlanetMaterialPolicy.profile("guild_lobby",aliases));
assertEquals("caladan",PlanetMaterialPolicy.profile("world",aliases));
assertNull(PlanetMaterialPolicy.profile("Arrakduin_nether",aliases));
assertNull(PlanetMaterialPolicy.profile("world_the_end",aliases));
assertNull(PlanetMaterialPolicy.profile("somewhere_else",aliases));
}
@Test void onlyMatchingImmutableHostedPacksAndRealSha1PinsAreAccepted(){
String url="https://www.dunerealms.com/downloads/DuneRealms-Materials-arrakis-v1.zip",hash="0123456789abcdef0123456789abcdef01234567";
assertDoesNotThrow(()->PlanetMaterialPolicy.validate("arrakis",url,hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("caladan",url,hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url.replace("https:","http:"),hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url.replace("www.dunerealms.com","evil.example"),hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url+"?changed=true",hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url,"not-a-sha1"));
}
}
package com.dunerealms.gui;
import java.util.Map;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PlanetMaterialPolicyTest {
@Test void exactWorldAliasesDoNotLeakPlanetTexturesIntoNetherOrUnknownWorlds(){
var aliases=Map.of("arrakduin","arrakis","guild_lobby","guild","world","caladan");
assertEquals("arrakis",PlanetMaterialPolicy.profile("Arrakduin",aliases));
assertEquals("guild",PlanetMaterialPolicy.profile("guild_lobby",aliases));
assertEquals("caladan",PlanetMaterialPolicy.profile("world",aliases));
assertNull(PlanetMaterialPolicy.profile("Arrakduin_nether",aliases));
assertNull(PlanetMaterialPolicy.profile("world_the_end",aliases));
assertNull(PlanetMaterialPolicy.profile("somewhere_else",aliases));
}
@Test void onlyMatchingImmutableHostedPacksAndRealSha1PinsAreAccepted(){
String url="https://www.dunerealms.com/downloads/DuneRealms-Materials-arrakis-v1.zip",hash="0123456789abcdef0123456789abcdef01234567";
assertDoesNotThrow(()->PlanetMaterialPolicy.validate("arrakis",url,hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("caladan",url,hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url.replace("https:","http:"),hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url.replace("www.dunerealms.com","evil.example"),hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url+"?changed=true",hash));
assertThrows(IllegalArgumentException.class,()->PlanetMaterialPolicy.validate("arrakis",url,"not-a-sha1"));
}
}