mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Fail-closed review fixes
- Modded logins are refused only when this save's dimension registry lists the primary world - Otherwise Iris warns once and leaves routing idle - An unreadable dimension registry counts as expecting the primary world - A vanilla slot bound to Iris without Iris storage points at the bukkit.yml entry and /iris replace - The refusal consequence comes from whether startup worlds exist instead of the first tick - The first WorldLoadEvent or a hotload marks startup worlds as existing - A failed enable on a hotload says the server keeps running - Reconciler resolution failures report the refusal banner - Operators get a join notice for such failures until the world loads - The fail-closed generator is built even when the cause message cannot be read - Tests drive Iris.onEnable for the lock, the unsupported-server lock and the rethrow - The failed-enable teardown decision lives in FailedEnableLock with a test
This commit is contained in:
1 parent
3a4da2086e
commit
eefcbc40ef
13 files changed
+644
-84
No files matched your search
+68
-1
@@ -37,7 +37,7 @@ public class ModdedPrimaryWorldRouterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMissingPrimaryWorldRefusesPlayersOnceStartupHasRestoredDimensions() {
|
||||
public void aPrimaryWorldThisSaveListsButDidNotRestoreRefusesPlayers() {
|
||||
NativeModdedServer server = mock(NativeModdedServer.class);
|
||||
NativeProtocolPlayer online = mock(NativeProtocolPlayer.class);
|
||||
onlinePlayers(server, online);
|
||||
@@ -45,10 +45,12 @@ public class ModdedPrimaryWorldRouterTest {
|
||||
|
||||
try (MockedStatic<ModdedModConfig> configs = mockStatic(ModdedModConfig.class);
|
||||
MockedStatic<ModdedDimensionManager> manager = mockStatic(ModdedDimensionManager.class);
|
||||
MockedStatic<ModdedDimensionRegistryStore> registry = mockStatic(ModdedDimensionRegistryStore.class);
|
||||
MockedStatic<ModdedStartup> startup = mockStatic(ModdedStartup.class);
|
||||
MockedStatic<ModdedIrisLog> log = mockStatic(ModdedIrisLog.class)) {
|
||||
configs.when(ModdedModConfig::get).thenReturn(routed);
|
||||
manager.when(() -> ModdedDimensionManager.level(server, PRIMARY)).thenReturn(null);
|
||||
registry.when(() -> ModdedDimensionRegistryStore.get(server, PRIMARY)).thenReturn(persisted());
|
||||
startup.when(ModdedStartup::dimensionsRestored).thenReturn(true);
|
||||
|
||||
evaluate(server);
|
||||
@@ -63,6 +65,37 @@ public class ModdedPrimaryWorldRouterTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* primaryWorld lives in the instance-wide modded.json, but the dimension it names lives in one save. Another
|
||||
* save, a new world or a reset world folder never had it, so nothing failed there and nothing is refused.
|
||||
*/
|
||||
@Test
|
||||
public void aPrimaryWorldThisSaveNeverHadLeavesRoutingIdleWithOneWarning() {
|
||||
NativeModdedServer server = mock(NativeModdedServer.class);
|
||||
NativeProtocolPlayer online = mock(NativeProtocolPlayer.class);
|
||||
onlinePlayers(server, online);
|
||||
ModdedModConfig routed = config(true, PRIMARY);
|
||||
|
||||
try (MockedStatic<ModdedModConfig> configs = mockStatic(ModdedModConfig.class);
|
||||
MockedStatic<ModdedDimensionManager> manager = mockStatic(ModdedDimensionManager.class);
|
||||
MockedStatic<ModdedDimensionRegistryStore> registry = mockStatic(ModdedDimensionRegistryStore.class);
|
||||
MockedStatic<ModdedStartup> startup = mockStatic(ModdedStartup.class);
|
||||
MockedStatic<ModdedIrisLog> log = mockStatic(ModdedIrisLog.class)) {
|
||||
configs.when(ModdedModConfig::get).thenReturn(routed);
|
||||
manager.when(() -> ModdedDimensionManager.level(server, PRIMARY)).thenReturn(null);
|
||||
registry.when(() -> ModdedDimensionRegistryStore.get(server, PRIMARY)).thenReturn(null);
|
||||
startup.when(ModdedStartup::dimensionsRestored).thenReturn(true);
|
||||
|
||||
evaluate(server);
|
||||
evaluate(server);
|
||||
|
||||
verify(online, never()).disconnect(anyString());
|
||||
assertFalse(ModdedPrimaryWorldRouter.refuseIfUnavailable(mock(NativeProtocolPlayer.class)));
|
||||
log.verify(() -> ModdedIrisLog.warn(argThat((String line) -> line != null && line.contains(PRIMARY))), times(1));
|
||||
log.verify(() -> ModdedIrisLog.error(anyString()), never());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins are processed before the first Iris tick restores persistent dimensions, so a primary world that is
|
||||
* missing then is still loading, not broken.
|
||||
@@ -100,8 +133,10 @@ public class ModdedPrimaryWorldRouterTest {
|
||||
|
||||
try (MockedStatic<ModdedModConfig> configs = mockStatic(ModdedModConfig.class);
|
||||
MockedStatic<ModdedDimensionManager> manager = mockStatic(ModdedDimensionManager.class);
|
||||
MockedStatic<ModdedDimensionRegistryStore> registry = mockStatic(ModdedDimensionRegistryStore.class);
|
||||
MockedStatic<ModdedStartup> startup = mockStatic(ModdedStartup.class);
|
||||
MockedStatic<ModdedIrisLog> log = mockStatic(ModdedIrisLog.class)) {
|
||||
registry.when(() -> ModdedDimensionRegistryStore.get(server, PRIMARY)).thenReturn(persisted());
|
||||
startup.when(ModdedStartup::dimensionsRestored).thenReturn(true);
|
||||
configs.when(ModdedModConfig::get).thenReturn(routed);
|
||||
evaluate(server);
|
||||
@@ -119,6 +154,38 @@ public class ModdedPrimaryWorldRouterTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A registry that cannot be read cannot prove the primary world was never here, so it counts as expected.
|
||||
*/
|
||||
@Test
|
||||
public void anUnreadableRegistryRefusesPlayersRatherThanGuessing() {
|
||||
NativeModdedServer server = mock(NativeModdedServer.class);
|
||||
NativeProtocolPlayer online = mock(NativeProtocolPlayer.class);
|
||||
onlinePlayers(server, online);
|
||||
ModdedModConfig routed = config(true, PRIMARY);
|
||||
|
||||
try (MockedStatic<ModdedModConfig> configs = mockStatic(ModdedModConfig.class);
|
||||
MockedStatic<ModdedDimensionManager> manager = mockStatic(ModdedDimensionManager.class);
|
||||
MockedStatic<ModdedDimensionRegistryStore> registry = mockStatic(ModdedDimensionRegistryStore.class);
|
||||
MockedStatic<ModdedStartup> startup = mockStatic(ModdedStartup.class);
|
||||
MockedStatic<ModdedIrisLog> log = mockStatic(ModdedIrisLog.class)) {
|
||||
configs.when(ModdedModConfig::get).thenReturn(routed);
|
||||
manager.when(() -> ModdedDimensionManager.level(server, PRIMARY)).thenReturn(null);
|
||||
registry.when(() -> ModdedDimensionRegistryStore.get(server, PRIMARY))
|
||||
.thenThrow(new IllegalStateException("registry could not be read"));
|
||||
startup.when(ModdedStartup::dimensionsRestored).thenReturn(true);
|
||||
|
||||
evaluate(server);
|
||||
|
||||
verify(online).disconnect(contains(PRIMARY));
|
||||
assertTrue(ModdedPrimaryWorldRouter.refuseIfUnavailable(mock(NativeProtocolPlayer.class)));
|
||||
}
|
||||
}
|
||||
|
||||
private static ModdedDimensionRegistryStore.PersistentDimension persisted() {
|
||||
return new ModdedDimensionRegistryStore.PersistentDimension(PRIMARY, "overworld", "overworld", 1337L);
|
||||
}
|
||||
|
||||
private static void evaluate(NativeModdedServer server) {
|
||||
for (int tick = 0; tick < TICK_INTERVAL; tick++) {
|
||||
ModdedPrimaryWorldRouter.tick(server);
|
||||
|
||||
Reference in new issue
Block a user