use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldNotAddSessionBecauseTimeoutIsZero.
@Test
public void shouldNotAddSessionBecauseTimeoutIsZero() {
// given
Settings settings = mockSettings(true, 0);
SessionManager manager = new SessionManager(settings);
String player = "playah";
// when
manager.addSession(player);
// then
assertThat(manager.hasSession(player), equalTo(false));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldNotHaveSession.
@Test
public void shouldNotHaveSession() {
// given
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
String player = "playah";
// when/then
assertThat(manager.hasSession(player), equalTo(false));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldAddCounts.
@Test
public void shouldAddCounts() {
// given
Settings settings = mockSettings(3, 4);
CaptchaManager manager = new CaptchaManager(settings);
String player = "tester";
// when
for (int i = 0; i < 2; ++i) {
manager.increaseCount(player);
}
// then
assertThat(manager.isCaptchaRequired(player), equalTo(false));
manager.increaseCount(player);
assertThat(manager.isCaptchaRequired(player.toUpperCase()), equalTo(true));
assertThat(manager.isCaptchaRequired("otherPlayer"), equalTo(false));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldNotIncreaseCountForDisabledCaptcha.
@Test
public void shouldNotIncreaseCountForDisabledCaptcha() {
// given
String player = "someone_";
Settings settings = mockSettings(1, 3);
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
CaptchaManager manager = new CaptchaManager(settings);
// when
manager.increaseCount(player);
// then
assertThat(manager.isCaptchaRequired(player), equalTo(false));
assertHasCount(manager, player, 0);
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method mockSettings.
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);
given(settings.getProperty(SecuritySettings.CAPTCHA_COUNT_MINUTES_BEFORE_RESET)).willReturn(30);
return settings;
}
Aggregations