Close #449 Rename NewSetting class to Settings :)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.cache;
|
||||
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CaptchaManagerTest {
|
||||
@Test
|
||||
public void shouldAddCounts() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(3, 4);
|
||||
Settings settings = mockSettings(3, 4);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
String player = "tester";
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CaptchaManagerTest {
|
||||
public void shouldCreateAndCheckCaptcha() {
|
||||
// given
|
||||
String player = "Miner";
|
||||
NewSetting settings = mockSettings(1, 4);
|
||||
Settings settings = mockSettings(1, 4);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
String captchaCode = manager.getCaptchaCodeOrGenerateNew(player);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CaptchaManagerTest {
|
||||
public void shouldHaveSameCodeAfterGeneration() {
|
||||
// given
|
||||
String player = "Tester";
|
||||
NewSetting settings = mockSettings(1, 5);
|
||||
Settings settings = mockSettings(1, 5);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
|
||||
// when
|
||||
@@ -88,7 +88,7 @@ public class CaptchaManagerTest {
|
||||
public void shouldIncreaseAndResetCount() {
|
||||
// given
|
||||
String player = "plaYer";
|
||||
NewSetting settings = mockSettings(2, 3);
|
||||
Settings settings = mockSettings(2, 3);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
|
||||
// when
|
||||
@@ -111,7 +111,7 @@ public class CaptchaManagerTest {
|
||||
public void shouldNotIncreaseCountForDisabledCaptcha() {
|
||||
// given
|
||||
String player = "someone_";
|
||||
NewSetting settings = mockSettings(1, 3);
|
||||
Settings settings = mockSettings(1, 3);
|
||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class CaptchaManagerTest {
|
||||
public void shouldNotCheckCountIfCaptchaIsDisabled() {
|
||||
// given
|
||||
String player = "Robert001";
|
||||
NewSetting settings = mockSettings(1, 5);
|
||||
Settings settings = mockSettings(1, 5);
|
||||
CaptchaManager manager = new CaptchaManager(settings);
|
||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
||||
|
||||
@@ -144,8 +144,8 @@ public class CaptchaManagerTest {
|
||||
assertThat(result, equalTo(false));
|
||||
}
|
||||
|
||||
private static NewSetting mockSettings(int maxTries, int captchaLength) {
|
||||
NewSetting settings = mock(NewSetting.class);
|
||||
private static Settings mockSettings(int maxTries, int captchaLength) {
|
||||
Settings settings = mock(Settings.class);
|
||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(true);
|
||||
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA)).willReturn(maxTries);
|
||||
given(settings.getProperty(SecuritySettings.CAPTCHA_LENGTH)).willReturn(captchaLength);
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.cache;
|
||||
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -24,7 +24,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldHaveSession() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(true, 10);
|
||||
Settings settings = mockSettings(true, 10);
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
String player = "playah";
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldNotHaveSession() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(true, 10);
|
||||
Settings settings = mockSettings(true, 10);
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
String player = "playah";
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldNotAddSessionBecauseDisabled() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(false, 10);
|
||||
Settings settings = mockSettings(false, 10);
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
String player = "playah";
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldNotAddSessionBecauseTimeoutIsZero() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(true, 0);
|
||||
Settings settings = mockSettings(true, 0);
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
String player = "playah";
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldRemoveSession() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(true, 10);
|
||||
Settings settings = mockSettings(true, 10);
|
||||
String player = "user";
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
manager.addSession(player);
|
||||
@@ -93,7 +93,7 @@ public class SessionManagerTest {
|
||||
public void shouldDenySessionIfTimeoutHasExpired() {
|
||||
// given
|
||||
int timeout = 20;
|
||||
NewSetting settings = mockSettings(true, timeout);
|
||||
Settings settings = mockSettings(true, timeout);
|
||||
String player = "patrick";
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
Map<String, Long> sessions = getSessionsMap(manager);
|
||||
@@ -110,7 +110,7 @@ public class SessionManagerTest {
|
||||
@Test
|
||||
public void shouldClearAllSessionsAfterDisable() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(true, 10);
|
||||
Settings settings = mockSettings(true, 10);
|
||||
SessionManager manager = new SessionManager(settings);
|
||||
manager.addSession("player01");
|
||||
manager.addSession("player02");
|
||||
@@ -129,8 +129,8 @@ public class SessionManagerTest {
|
||||
}
|
||||
|
||||
|
||||
private static NewSetting mockSettings(boolean isEnabled, int sessionTimeout) {
|
||||
NewSetting settings = mock(NewSetting.class);
|
||||
private static Settings mockSettings(boolean isEnabled, int sessionTimeout) {
|
||||
Settings settings = mock(Settings.class);
|
||||
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(isEnabled);
|
||||
given(settings.getProperty(PluginSettings.SESSIONS_TIMEOUT)).willReturn(sessionTimeout);
|
||||
return settings;
|
||||
|
||||
+10
-10
@@ -4,7 +4,7 @@ import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -44,7 +44,7 @@ public class TempbanManagerTest {
|
||||
@Test
|
||||
public void shouldAddCounts() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(3, 60);
|
||||
Settings settings = mockSettings(3, 60);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
String address = "192.168.1.1";
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TempbanManagerTest {
|
||||
public void shouldIncreaseAndResetCount() {
|
||||
// given
|
||||
String address = "192.168.1.2";
|
||||
NewSetting settings = mockSettings(3, 60);
|
||||
Settings settings = mockSettings(3, 60);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
|
||||
// when
|
||||
@@ -88,7 +88,7 @@ public class TempbanManagerTest {
|
||||
public void shouldNotIncreaseCountForDisabledTempban() {
|
||||
// given
|
||||
String address = "192.168.1.3";
|
||||
NewSetting settings = mockSettings(1, 5);
|
||||
Settings settings = mockSettings(1, 5);
|
||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class TempbanManagerTest {
|
||||
public void shouldNotCheckCountIfTempbanIsDisabled() {
|
||||
// given
|
||||
String address = "192.168.1.4";
|
||||
NewSetting settings = mockSettings(1, 5);
|
||||
Settings settings = mockSettings(1, 5);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class TempbanManagerTest {
|
||||
@Test
|
||||
public void shouldNotIssueBanIfDisabled() {
|
||||
// given
|
||||
NewSetting settings = mockSettings(0, 0);
|
||||
Settings settings = mockSettings(0, 0);
|
||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||
Player player = mock(Player.class);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
@@ -144,7 +144,7 @@ public class TempbanManagerTest {
|
||||
TestHelper.mockPlayerIp(player, ip);
|
||||
String banReason = "IP ban too many logins";
|
||||
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
||||
NewSetting settings = mockSettings(2, 100);
|
||||
Settings settings = mockSettings(2, 100);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
|
||||
// when
|
||||
@@ -171,7 +171,7 @@ public class TempbanManagerTest {
|
||||
TestHelper.mockPlayerIp(player, ip);
|
||||
String banReason = "kick msg";
|
||||
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
||||
NewSetting settings = mockSettings(10, 60);
|
||||
Settings settings = mockSettings(10, 60);
|
||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||
manager.increaseCount(ip);
|
||||
manager.increaseCount(ip);
|
||||
@@ -186,8 +186,8 @@ public class TempbanManagerTest {
|
||||
assertHasCount(manager, ip, null);
|
||||
}
|
||||
|
||||
private static NewSetting mockSettings(int maxTries, int tempbanLength) {
|
||||
NewSetting settings = mock(NewSetting.class);
|
||||
private static Settings mockSettings(int maxTries, int tempbanLength) {
|
||||
Settings settings = mock(Settings.class);
|
||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(true);
|
||||
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN)).willReturn(maxTries);
|
||||
given(settings.getProperty(SecuritySettings.TEMPBAN_LENGTH)).willReturn(tempbanLength);
|
||||
|
||||
@@ -3,7 +3,7 @@ package fr.xephi.authme.cache.limbo;
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import org.bukkit.Location;
|
||||
@@ -35,7 +35,7 @@ public class LimboCacheTest {
|
||||
private LimboCache limboCache;
|
||||
|
||||
@Mock
|
||||
private NewSetting settings;
|
||||
private Settings settings;
|
||||
|
||||
@Mock
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
Reference in New Issue
Block a user