use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldCreateAndCheckCaptcha.
@Test
public void shouldCreateAndCheckCaptcha() {
// given
String player = "Miner";
Settings settings = mockSettings(1, 4);
CaptchaManager manager = new CaptchaManager(settings);
String captchaCode = manager.getCaptchaCodeOrGenerateNew(player);
// when
boolean badResult = manager.checkCode(player, "wrong_code");
boolean goodResult = manager.checkCode(player, captchaCode);
// then
assertThat(captchaCode.length(), equalTo(4));
assertThat(badResult, equalTo(false));
assertThat(goodResult, equalTo(true));
// Supplying correct code should clear the entry, and any code should be valid if no entry is present
assertThat(manager.checkCode(player, "bogus"), equalTo(true));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldClearAllSessionsAfterDisable.
@Test
public void shouldClearAllSessionsAfterDisable() {
// given
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
manager.addSession("player01");
manager.addSession("player02");
// when
manager.reload(mockSettings(false, 20));
// then
assertThat(getSessionsMap(manager).isEmpty(), equalTo(true));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldPerformCleanup.
@Test
public void shouldPerformCleanup() {
// given
Settings settings = mockSettings(true, 1);
SessionManager manager = new SessionManager(settings);
ExpiringSet<String> expiringSet = mockExpiringSet();
setSessionsMap(manager, expiringSet);
// when
manager.performCleanup();
// then
verify(expiringSet).removeExpiredEntries();
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method mockSettings.
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;
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldHaveSession.
@Test
public void shouldHaveSession() {
// given
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
String player = "playah";
// when
manager.addSession(player);
// then
assertThat(manager.hasSession(player), equalTo(true));
}
Aggregations