use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class TempbanManagerTest method shouldAddCounts.
@Test
public void shouldAddCounts() {
// given
Settings settings = mockSettings(3, 60);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
String address = "192.168.1.1";
// when
manager.increaseCount(address, "Bob");
manager.increaseCount(address, "Todd");
// then
assertThat(manager.shouldTempban(address), equalTo(false));
assertHasCount(manager, address, "Bob", 1);
assertHasCount(manager, address, "Todd", 1);
manager.increaseCount(address, "Bob");
assertThat(manager.shouldTempban(address), equalTo(true));
assertThat(manager.shouldTempban("10.0.0.1"), equalTo(false));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldHaveSameCodeAfterGeneration.
@Test
public void shouldHaveSameCodeAfterGeneration() {
// given
String player = "Tester";
Settings settings = mockSettings(1, 5);
CaptchaManager manager = new CaptchaManager(settings);
// when
String code1 = manager.getCaptchaCodeOrGenerateNew(player);
String code2 = manager.getCaptchaCodeOrGenerateNew(player);
String code3 = manager.getCaptchaCodeOrGenerateNew(player);
// then
assertThat(code1.length(), equalTo(5));
assertThat(code2, equalTo(code1));
assertThat(code3, equalTo(code1));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldNotCheckCountIfCaptchaIsDisabled.
@Test
public void shouldNotCheckCountIfCaptchaIsDisabled() {
// given
String player = "Robert001";
Settings settings = mockSettings(1, 5);
CaptchaManager manager = new CaptchaManager(settings);
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
// when
manager.increaseCount(player);
// assumptions
assertThat(manager.isCaptchaRequired(player), equalTo(true));
assertHasCount(manager, player, 1);
// end assumptions
manager.reload(settings);
boolean result = manager.isCaptchaRequired(player);
// then
assertThat(result, equalTo(false));
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class CaptchaManagerTest method shouldIncreaseAndResetCount.
@Test
public void shouldIncreaseAndResetCount() {
// given
String player = "plaYer";
Settings settings = mockSettings(2, 3);
CaptchaManager manager = new CaptchaManager(settings);
// when
manager.increaseCount(player);
manager.increaseCount(player);
// then
assertThat(manager.isCaptchaRequired(player), equalTo(true));
assertHasCount(manager, player, 2);
// when 2
manager.resetCounts(player);
// then 2
assertThat(manager.isCaptchaRequired(player), equalTo(false));
assertHasCount(manager, player, 0);
}
use of fr.xephi.authme.settings.Settings in project AuthMeReloaded by AuthMe.
the class SessionManagerTest method shouldRemoveSession.
@Test
public void shouldRemoveSession() {
// given
Settings settings = mockSettings(true, 10);
String player = "user";
SessionManager manager = new SessionManager(settings);
manager.addSession(player);
// when
manager.removeSession(player);
// then
assertThat(manager.hasSession(player), equalTo(false));
}
Aggregations