mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-06 20:28:06 +02:00
Fix test
This commit is contained in:
parent
c63b9786f8
commit
46a10da40f
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user