From ee177e8a3a8da5ccc05cd0590347af5286ed2690 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Fri, 8 Apr 2016 14:34:21 +0200 Subject: [PATCH] Remove the IPManager We don't need it anymore --- src/main/java/fr/xephi/authme/AuthMe.java | 24 ++-- .../xephi/authme/cache/IpAddressManager.java | 109 ------------------ .../xephi/authme/command/CommandService.java | 10 +- .../executable/authme/GetIpCommand.java | 2 +- .../xephi/authme/hooks/BungeeCordMessage.java | 11 +- .../xephi/authme/process/ProcessService.java | 14 +-- .../authme/process/join/AsynchronousJoin.java | 4 +- .../process/login/AsynchronousLogin.java | 2 +- .../authme/process/quit/AsynchronousQuit.java | 3 +- .../process/register/AsyncRegister.java | 4 +- .../register/ProcessSyncEmailRegister.java | 2 +- .../register/ProcessSyncPasswordRegister.java | 2 +- .../settings/properties/HooksSettings.java | 1 + src/main/java/fr/xephi/authme/util/Utils.java | 7 ++ .../authme/cache/IpAddressManagerTest.java | 29 ----- .../authme/command/CommandServiceTest.java | 14 +-- .../authme/process/ProcessServiceTest.java | 14 +-- 17 files changed, 33 insertions(+), 219 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/cache/IpAddressManager.java diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 01cccab1..2e7fae7b 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -2,7 +2,6 @@ package fr.xephi.authme; import fr.xephi.authme.api.API; import fr.xephi.authme.api.NewAPI; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.backup.JsonCache; @@ -135,7 +134,6 @@ public class AuthMe extends JavaPlugin { private JsonCache playerBackup; private PasswordSecurity passwordSecurity; private DataSource database; - private IpAddressManager ipAddressManager; private PluginHooks pluginHooks; private SpawnLoader spawnLoader; private AntiBot antiBot; @@ -253,7 +251,6 @@ public class AuthMe extends JavaPlugin { MigrationService.changePlainTextToSha256(newSettings, database, new SHA256()); passwordSecurity = new PasswordSecurity(getDataSource(), newSettings, Bukkit.getPluginManager()); - ipAddressManager = new IpAddressManager(newSettings); // Initialize spawn loader spawnLoader = new SpawnLoader(getDataFolder(), newSettings, pluginHooks); @@ -262,7 +259,7 @@ public class AuthMe extends JavaPlugin { // Set up the permissions manager and command handler permsMan = initializePermissionsManager(); ValidationService validationService = new ValidationService(newSettings, database, permsMan); - commandHandler = initializeCommandHandler(permsMan, messages, passwordSecurity, newSettings, ipAddressManager, + commandHandler = initializeCommandHandler(permsMan, messages, passwordSecurity, newSettings, pluginHooks, spawnLoader, antiBot, validationService); // AntiBot delay @@ -300,12 +297,12 @@ public class AuthMe extends JavaPlugin { setupApi(); // Set up the management - ProcessService processService = new ProcessService(newSettings, messages, this, database, ipAddressManager, + ProcessService processService = new ProcessService(newSettings, messages, this, database, passwordSecurity, pluginHooks, spawnLoader, validationService); management = new Management(this, processService, database, PlayerCache.getInstance()); // Set up the BungeeCord hook - setupBungeeCordHook(newSettings, ipAddressManager); + setupBungeeCordHook(newSettings); // Reload support hook reloadSupportHook(); @@ -423,24 +420,23 @@ public class AuthMe extends JavaPlugin { /** * Set up the BungeeCord hook. */ - private void setupBungeeCordHook(NewSetting settings, IpAddressManager ipAddressManager) { + private void setupBungeeCordHook(NewSetting settings) { if (settings.getProperty(HooksSettings.BUNGEECORD)) { Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Bukkit.getMessenger().registerIncomingPluginChannel( - this, "BungeeCord", new BungeeCordMessage(this, ipAddressManager)); + this, "BungeeCord", new BungeeCordMessage(this)); } } private CommandHandler initializeCommandHandler(PermissionsManager permissionsManager, Messages messages, PasswordSecurity passwordSecurity, NewSetting settings, - IpAddressManager ipAddressManager, PluginHooks pluginHooks, - SpawnLoader spawnLoader, AntiBot antiBot, - ValidationService validationService) { + PluginHooks pluginHooks, SpawnLoader spawnLoader, + AntiBot antiBot, ValidationService validationService) { HelpProvider helpProvider = new HelpProvider(permissionsManager, settings.getProperty(HELP_HEADER)); Set baseCommands = CommandInitializer.buildCommands(); CommandMapper mapper = new CommandMapper(baseCommands, permissionsManager); CommandService commandService = new CommandService(this, mapper, helpProvider, messages, passwordSecurity, - permissionsManager, settings, ipAddressManager, pluginHooks, spawnLoader, antiBot, validationService); + permissionsManager, settings, pluginHooks, spawnLoader, antiBot, validationService); return new CommandHandler(commandService); } @@ -775,7 +771,7 @@ public class AuthMe extends JavaPlugin { public String replaceAllInfo(String message, Player player) { String playersOnline = Integer.toString(Utils.getOnlinePlayers().size()); - String ipAddress = ipAddressManager.getPlayerIp(player); + String ipAddress = Utils.getPlayerIp(player); return message .replace("&", "\u00a7") .replace("{PLAYER}", player.getName()) @@ -792,7 +788,7 @@ public class AuthMe extends JavaPlugin { public boolean isLoggedIp(String name, String ip) { int count = 0; for (Player player : Utils.getOnlinePlayers()) { - if (ip.equalsIgnoreCase(ipAddressManager.getPlayerIp(player)) + if (ip.equalsIgnoreCase(Utils.getPlayerIp(player)) && database.isLogged(player.getName().toLowerCase()) && !player.getName().equalsIgnoreCase(name)) { ++count; diff --git a/src/main/java/fr/xephi/authme/cache/IpAddressManager.java b/src/main/java/fr/xephi/authme/cache/IpAddressManager.java deleted file mode 100644 index ff3398a5..00000000 --- a/src/main/java/fr/xephi/authme/cache/IpAddressManager.java +++ /dev/null @@ -1,109 +0,0 @@ -package fr.xephi.authme.cache; - -import com.google.common.base.Charsets; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import com.google.common.io.Resources; -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.settings.NewSetting; -import fr.xephi.authme.settings.properties.HooksSettings; -import fr.xephi.authme.util.StringUtils; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.net.URL; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Stateful manager for looking up IP address appropriately, including caching. - */ -public class IpAddressManager { - /** - * Whether or not to use the VeryGames API or BungeeCord for IP lookups. - */ - private final boolean useVeryGamesIpCheck; - private final boolean useBungee; - /** - * Cache for lookups. - */ - private final ConcurrentHashMap ipCache; - - /** - * Constructor. - * - * @param settings The settings instance - */ - public IpAddressManager(NewSetting settings) { - this.useVeryGamesIpCheck = settings.getProperty(HooksSettings.ENABLE_VERYGAMES_IP_CHECK); - this.useBungee = settings.getProperty(HooksSettings.BUNGEECORD); - this.ipCache = new ConcurrentHashMap<>(); - } - - /** - * Return the player's IP address. If enabled in the settings, the IP address returned by the - * VeryGames API will be returned. - * - * @param player The player to look up - * - * @return The IP address of the player - */ - public String getPlayerIp(Player player) { - final String playerName = player.getName().toLowerCase(); - final String cachedValue = ipCache.get(playerName); - if (cachedValue != null) { - return cachedValue; - } - - final String plainIp = player.getAddress().getAddress().getHostAddress(); - if (useBungee) { - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("IP"); - player.sendPluginMessage(AuthMe.getInstance(), "BungeeCord", out.toByteArray()); - } - if (useVeryGamesIpCheck) { - String veryGamesResult = getVeryGamesIp(plainIp, player.getAddress().getPort()); - if (veryGamesResult != null) { - ipCache.put(playerName, veryGamesResult); - return veryGamesResult; - } - } - return plainIp; - } - - /** - * Add a player to the IP address cache. - * - * @param player The player to add or update the cache entry for - * @param ip The IP address to add - */ - public void addCache(String player, String ip) { - ipCache.put(player.toLowerCase(), ip); - } - - /** - * Remove a player's cache entry. - * - * @param player The player to remove - */ - public void removeCache(String player) { - ipCache.remove(player.toLowerCase()); - } - - // returns null if IP could not be looked up - private String getVeryGamesIp(final String plainIp, final int port) { - final String sUrl = String.format("http://monitor-1.verygames.net/api/?action=ipclean-real-ip" - + "&out=raw&ip=%s&port=%d", plainIp, port); - - try { - String result = Resources.toString(new URL(sUrl), Charsets.UTF_8); - if (!StringUtils.isEmpty(result) && !result.contains("error")) { - return result; - } - } catch (IOException e) { - ConsoleLogger.logException("Could not fetch Very Games API with URL '" + sUrl + "':", e); - } - return null; - } - -} diff --git a/src/main/java/fr/xephi/authme/command/CommandService.java b/src/main/java/fr/xephi/authme/command/CommandService.java index 2fee46ad..8a6ae24c 100644 --- a/src/main/java/fr/xephi/authme/command/CommandService.java +++ b/src/main/java/fr/xephi/authme/command/CommandService.java @@ -5,7 +5,6 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.command.help.HelpProvider; import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; @@ -33,7 +32,6 @@ public class CommandService { private final PasswordSecurity passwordSecurity; private final PermissionsManager permissionsManager; private final NewSetting settings; - private final IpAddressManager ipAddressManager; private final PluginHooks pluginHooks; private final SpawnLoader spawnLoader; private final AntiBot antiBot; @@ -44,8 +42,7 @@ public class CommandService { */ public CommandService(AuthMe authMe, CommandMapper commandMapper, HelpProvider helpProvider, Messages messages, PasswordSecurity passwordSecurity, PermissionsManager permissionsManager, NewSetting settings, - IpAddressManager ipAddressManager, PluginHooks pluginHooks, SpawnLoader spawnLoader, - AntiBot antiBot, ValidationService validationService) { + PluginHooks pluginHooks, SpawnLoader spawnLoader, AntiBot antiBot, ValidationService validationService) { this.authMe = authMe; this.messages = messages; this.helpProvider = helpProvider; @@ -53,7 +50,6 @@ public class CommandService { this.passwordSecurity = passwordSecurity; this.permissionsManager = permissionsManager; this.settings = settings; - this.ipAddressManager = ipAddressManager; this.pluginHooks = pluginHooks; this.spawnLoader = spawnLoader; this.antiBot = antiBot; @@ -191,10 +187,6 @@ public class CommandService { return settings; } - public IpAddressManager getIpAddressManager() { - return ipAddressManager; - } - public PlayerCache getPlayerCache() { return PlayerCache.getInstance(); } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java index d3ba537d..1095b87c 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/GetIpCommand.java @@ -27,7 +27,7 @@ public class GetIpCommand implements ExecutableCommand { if (commandService.getProperty(HooksSettings.ENABLE_VERYGAMES_IP_CHECK)) { sender.sendMessage(player.getName() + "'s real IP is: " - + commandService.getIpAddressManager().getPlayerIp(player)); + + Utils.getPlayerIp(player)); } } } diff --git a/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java index 4b6534da..ed089b8a 100644 --- a/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java +++ b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java @@ -7,7 +7,6 @@ import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.security.crypts.HashedPassword; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -17,17 +16,14 @@ import org.bukkit.plugin.messaging.PluginMessageListener; public class BungeeCordMessage implements PluginMessageListener { private final AuthMe plugin; - private final IpAddressManager ipAddressManager; /** * Constructor for BungeeCordMessage. * * @param plugin The plugin instance - * @param ipAddressManager The IP address manager */ - public BungeeCordMessage(AuthMe plugin, IpAddressManager ipAddressManager) { + public BungeeCordMessage(AuthMe plugin) { this.plugin = plugin; - this.ipAddressManager = ipAddressManager; } @Override @@ -37,11 +33,6 @@ public class BungeeCordMessage implements PluginMessageListener { } ByteArrayDataInput in = ByteStreams.newDataInput(message); String subChannel = in.readUTF(); - if ("IP".equals(subChannel)) { // We need only the IP channel - String ip = in.readUTF(); - // Put the IP (only the ip not the port) in the hashMap - ipAddressManager.addCache(player.getName(), ip); - } if ("AuthMe".equalsIgnoreCase(subChannel)) { String str = in.readUTF(); final String[] args = str.split(";"); diff --git a/src/main/java/fr/xephi/authme/process/ProcessService.java b/src/main/java/fr/xephi/authme/process/ProcessService.java index fd08b7ba..7dcffe1c 100644 --- a/src/main/java/fr/xephi/authme/process/ProcessService.java +++ b/src/main/java/fr/xephi/authme/process/ProcessService.java @@ -1,7 +1,6 @@ package fr.xephi.authme.process; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.output.MessageKey; @@ -25,20 +24,18 @@ public class ProcessService { private final Messages messages; private final AuthMe authMe; private final DataSource dataSource; - private final IpAddressManager ipAddressManager; private final PasswordSecurity passwordSecurity; private final PluginHooks pluginHooks; private final SpawnLoader spawnLoader; private final ValidationService validationService; public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, DataSource dataSource, - IpAddressManager ipAddressManager, PasswordSecurity passwordSecurity, PluginHooks pluginHooks, + PasswordSecurity passwordSecurity, PluginHooks pluginHooks, SpawnLoader spawnLoader, ValidationService validationService) { this.settings = settings; this.messages = messages; this.authMe = authMe; this.dataSource = dataSource; - this.ipAddressManager = ipAddressManager; this.passwordSecurity = passwordSecurity; this.pluginHooks = pluginHooks; this.spawnLoader = spawnLoader; @@ -155,15 +152,6 @@ public class ProcessService { return authMe; } - /** - * Return the IP address manager. - * - * @return the ip address manager - */ - public IpAddressManager getIpAddressManager() { - return ipAddressManager; - } - /** * Compute the hash for the given password. * diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 4257cf37..60081984 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -69,7 +69,7 @@ public class AsynchronousJoin implements Process { service.getPluginHooks().setEssentialsSocialSpyStatus(player, false); } - final String ip = service.getIpAddressManager().getPlayerIp(player); + final String ip = Utils.getPlayerIp(player); if (isNameRestricted(name, ip, player.getAddress().getHostName(), service.getSettings())) { service.scheduleSyncDelayedTask(new Runnable() { @Override @@ -305,7 +305,7 @@ public class AsynchronousJoin implements Process { private boolean hasJoinedIp(String name, String ip, NewSetting settings) { int count = 0; for (Player player : Utils.getOnlinePlayers()) { - if (ip.equalsIgnoreCase(service.getIpAddressManager().getPlayerIp(player)) + if (ip.equalsIgnoreCase(Utils.getPlayerIp(player)) && !player.getName().equalsIgnoreCase(name)) { count++; } diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index bb039bf1..507a67eb 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -52,7 +52,7 @@ public class AsynchronousLogin implements Process { this.forceLogin = forceLogin; this.plugin = plugin; this.database = data; - this.ip = service.getIpAddressManager().getPlayerIp(player); + this.ip = Utils.getPlayerIp(player); this.service = service; } diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index cb2a79a9..c4e1a7f5 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -43,7 +43,7 @@ public class AsynchronousQuit implements Process { return; } - String ip = service.getIpAddressManager().getPlayerIp(player); + String ip = Utils.getPlayerIp(player); if (PlayerCache.getInstance().isAuthenticated(name)) { if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { @@ -94,7 +94,6 @@ public class AsynchronousQuit implements Process { database.setUnlogged(name); } - service.getIpAddressManager().removeCache(player.getName()); if (plugin.isEnabled()) { service.scheduleSyncDelayedTask(new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange)); } diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index dd41e9cd..5cacb105 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -17,6 +17,8 @@ import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.util.StringUtils; +import fr.xephi.authme.util.Utils; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -44,7 +46,7 @@ public class AsyncRegister implements Process { this.email = email; this.plugin = plugin; this.database = data; - this.ip = service.getIpAddressManager().getPlayerIp(player); + this.ip = Utils.getPlayerIp(player); this.playerCache = playerCache; this.service = service; } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java index a58fdded..f1d35039 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java @@ -58,7 +58,7 @@ public class ProcessSyncEmailRegister implements Process { player.saveData(); if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) { - ConsoleLogger.info(player.getName() + " registered " + service.getIpAddressManager().getPlayerIp(player)); + ConsoleLogger.info(player.getName() + " registered " + Utils.getPlayerIp(player)); } } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index c3411d92..8e839dda 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -116,7 +116,7 @@ public class ProcessSyncPasswordRegister implements Process { player.saveData(); if (!Settings.noConsoleSpam) { - ConsoleLogger.info(player.getName() + " registered " + service.getIpAddressManager().getPlayerIp(player)); + ConsoleLogger.info(player.getName() + " registered " + Utils.getPlayerIp(player)); } // Kick Player after Registration is enabled, kick the player diff --git a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java index 95d91f85..55e743e4 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java @@ -35,6 +35,7 @@ public class HooksSettings implements SettingsClass { public static final Property CACHE_CUSTOM_ATTRIBUTES = newProperty("Hooks.customAttributes", false); + // TODO REMOVE ME @Comment("These features are only available on VeryGames Server Provider") public static final Property ENABLE_VERYGAMES_IP_CHECK = newProperty("VeryGames.enableIpCheck", false); diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index 1eb4deb8..f2a32987 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -265,4 +265,11 @@ public final class Utils { NOTLOGGEDIN, LOGGEDIN } + + /** + * Returns the IP of the given player. + */ + public static String getPlayerIp(Player p) { + return p.getAddress().getAddress().getHostAddress(); + } } diff --git a/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java b/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java index be172f3d..1ee6cab0 100644 --- a/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java +++ b/src/test/java/fr/xephi/authme/cache/IpAddressManagerTest.java @@ -3,13 +3,9 @@ package fr.xephi.authme.cache; import fr.xephi.authme.settings.NewSetting; import fr.xephi.authme.settings.properties.HooksSettings; import org.bukkit.entity.Player; -import org.junit.Test; - import java.net.InetAddress; import java.net.InetSocketAddress; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -35,29 +31,4 @@ 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")); - } - } diff --git a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java index 6c7ed5e5..4f641086 100644 --- a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java @@ -2,7 +2,6 @@ package fr.xephi.authme.command; import fr.xephi.authme.AntiBot; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.command.help.HelpProvider; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.hooks.PluginHooks; @@ -57,8 +56,6 @@ public class CommandServiceTest { @Mock private NewSetting settings; @Mock - private IpAddressManager ipAddressManager; - @Mock private PluginHooks pluginHooks; @Mock private SpawnLoader spawnLoader; @@ -70,7 +67,7 @@ public class CommandServiceTest { @Before public void setUpService() { commandService = new CommandService(authMe, commandMapper, helpProvider, messages, passwordSecurity, - permissionsManager, settings, ipAddressManager, pluginHooks, spawnLoader, antiBot, validationService); + permissionsManager, settings, pluginHooks, spawnLoader, antiBot, validationService); } @Test @@ -223,15 +220,6 @@ public class CommandServiceTest { assertThat(result, equalTo(authMe)); } - @Test - public void shouldReturnIpAddressManager() { - // given/when - IpAddressManager ipManager = commandService.getIpAddressManager(); - - // then - assertThat(ipManager, equalTo(ipAddressManager)); - } - @Test public void shouldValidatePassword() { // given diff --git a/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java b/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java index 8e4acddf..6117e7f9 100644 --- a/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java +++ b/src/test/java/fr/xephi/authme/process/ProcessServiceTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.process; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.IpAddressManager; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.hooks.PluginHooks; import fr.xephi.authme.output.MessageKey; @@ -39,8 +38,6 @@ public class ProcessServiceTest { @Mock private Messages messages; @Mock - private IpAddressManager ipAddressManager; - @Mock private PasswordSecurity passwordSecurity; @Mock private AuthMe authMe; @@ -53,7 +50,7 @@ public class ProcessServiceTest { @Before public void setUpService() { - processService = new ProcessService(settings, messages, authMe, dataSource, ipAddressManager, passwordSecurity, + processService = new ProcessService(settings, messages, authMe, dataSource, passwordSecurity, pluginHooks, spawnLoader, validationService); } @@ -154,15 +151,6 @@ public class ProcessServiceTest { assertThat(result, equalTo(pluginHooks)); } - @Test - public void shouldReturnIpAddressManager() { - // given / when - IpAddressManager result = processService.getIpAddressManager(); - - // then - assertThat(result, equalTo(ipAddressManager)); - } - @Test public void shouldReturnSpawnLoader() { // given / when