diff --git a/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java b/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java index 50c73d300..be172f3d6 100644 --- a/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java +++ b/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java @@ -18,36 +18,10 @@ import static org.mockito.Mockito.mock; */ public class IpAddressManagerTest { - @Test - public void shouldRetrieveFromCache() { - // given - IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(true)); - ipAddressManager.addCache("Test", "my test IP"); - - // when - String result = ipAddressManager.getPlayerIp(mockPlayer("test", "123.123.123.123")); - - // then - assertThat(result, equalTo("my test IP")); - } - - @Test - public void shouldReturnPlainIp() { - // given - IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(false)); - - // when - String result = ipAddressManager.getPlayerIp(mockPlayer("bobby", "8.8.8.8")); - - // then - assertThat(result, equalTo("8.8.8.8")); - } - - - - private static NewSetting mockSettings(boolean useVeryGames) { + private static NewSetting mockSettings(boolean useVeryGames, boolean useBungee) { NewSetting settings = mock(NewSetting.class); given(settings.getProperty(HooksSettings.ENABLE_VERYGAMES_IP_CHECK)).willReturn(useVeryGames); + given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(useBungee); return settings; } @@ -61,4 +35,29 @@ public class IpAddressManagerTest { return player; } + @Test + public void shouldRetrieveFromCache() { + // given + IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(true, true)); + ipAddressManager.addCache("Test", "my test IP"); + + // when + String result = ipAddressManager.getPlayerIp(mockPlayer("test", "123.123.123.123")); + + // then + assertThat(result, equalTo("my test IP")); + } + + @Test + public void shouldReturnPlainIp() { + // given + IpAddressManager ipAddressManager = new IpAddressManager(mockSettings(false, false)); + + // when + String result = ipAddressManager.getPlayerIp(mockPlayer("bobby", "8.8.8.8")); + + // then + assertThat(result, equalTo("8.8.8.8")); + } + }