Search in sources :

Example 6 with Settings

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));
}
Also used : SecuritySettings(fr.xephi.authme.settings.properties.SecuritySettings) Settings(fr.xephi.authme.settings.Settings) Test(org.junit.Test)

Example 7 with Settings

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));
}
Also used : SecuritySettings(fr.xephi.authme.settings.properties.SecuritySettings) Settings(fr.xephi.authme.settings.Settings) Test(org.junit.Test)

Example 8 with Settings

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));
}
Also used : SecuritySettings(fr.xephi.authme.settings.properties.SecuritySettings) Settings(fr.xephi.authme.settings.Settings) Test(org.junit.Test)

Example 9 with Settings

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);
}
Also used : SecuritySettings(fr.xephi.authme.settings.properties.SecuritySettings) Settings(fr.xephi.authme.settings.Settings) Test(org.junit.Test)

Example 10 with Settings

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));
}
Also used : Settings(fr.xephi.authme.settings.Settings) PluginSettings(fr.xephi.authme.settings.properties.PluginSettings) Test(org.junit.Test)

Aggregations

Settings (fr.xephi.authme.settings.Settings)37 Test (org.junit.Test)23 SecuritySettings (fr.xephi.authme.settings.properties.SecuritySettings)21 PluginSettings (fr.xephi.authme.settings.properties.PluginSettings)12 BeforeClass (org.junit.BeforeClass)5 Property (ch.jalu.configme.properties.Property)4 InjectorBuilder (ch.jalu.injector.InjectorBuilder)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 File (java.io.File)3 Player (org.bukkit.entity.Player)3 Answer (org.mockito.stubbing.Answer)3 PropertyResource (ch.jalu.configme.resource.PropertyResource)2 Injector (ch.jalu.injector.Injector)2 FactoryDependencyHandler (fr.xephi.authme.initialization.factory.FactoryDependencyHandler)2 SingletonStoreDependencyHandler (fr.xephi.authme.initialization.factory.SingletonStoreDependencyHandler)2 DatabaseSettings (fr.xephi.authme.settings.properties.DatabaseSettings)2 HooksSettings (fr.xephi.authme.settings.properties.HooksSettings)2 Path (java.nio.file.Path)2 ConfigurationData (ch.jalu.configme.configurationdata.ConfigurationData)1 YamlFileResource (ch.jalu.configme.resource.YamlFileResource)1