Search in sources :

Example 51 with PlayerAuth

use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.

the class LoginSecurityConverterTest method shouldConvertFromSqlite.

@Test
public void shouldConvertFromSqlite() throws SQLException {
    // given
    Connection connection = converter.createSqliteConnection(TestHelper.TEST_RESOURCES_FOLDER + TestHelper.PROJECT_ROOT + "datasource/converter/LoginSecurity.db");
    CommandSender sender = mock(CommandSender.class);
    // when
    converter.performConversion(sender, connection);
    // then
    ArgumentCaptor<PlayerAuth> captor = ArgumentCaptor.forClass(PlayerAuth.class);
    verify(dataSource, times(3)).saveAuth(captor.capture());
    assertThat(captor.getAllValues().get(0).getNickname(), equalTo("player1"));
    assertThat(captor.getAllValues().get(0).getRealName(), equalTo("Player1"));
    assertThat(captor.getAllValues().get(0).getLastLogin(), equalTo(1494242093652L));
    assertThat(captor.getAllValues().get(0).getPassword(), equalToHash("$2a$10$E1Ri7XKeIIBv4qVaiPplgepT7QH9xGFh3hbHfcmCjq7hiW.UBTiGK"));
    assertThat(captor.getAllValues().get(0).getIp(), equalTo("127.0.0.1"));
    assertThat(captor.getAllValues().get(1).getNickname(), equalTo("player2"));
    assertThat(captor.getAllValues().get(1).getLastLogin(), equalTo(1494242174589L));
    assertThat(captor.getAllValues().get(1).getIp(), equalTo("127.4.5.6"));
    assertThat(captor.getAllValues().get(2).getRealName(), equalTo("Player3"));
    assertThat(captor.getAllValues().get(2).getPassword(), equalToHash("$2a$10$WFui8KSXMLDOVXKFpCLyPukPi4M82w1cv/rNojsAnwJjba3pp8sba"));
    assertThat(captor.getAllValues().get(2), hasAuthLocation(14.24, 67.99, -12.83, "hubb", -10f, 185f));
}
Also used : Connection(java.sql.Connection) CommandSender(org.bukkit.command.CommandSender) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Example 52 with PlayerAuth

use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.

the class AbstractDataSourceConverterTest method mockAuthWithName.

private static PlayerAuth mockAuthWithName(String name) {
    PlayerAuth auth = mock(PlayerAuth.class);
    given(auth.getNickname()).willReturn(name);
    return auth;
}
Also used : PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth)

Example 53 with PlayerAuth

use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.

the class OnJoinVerifierTest method shouldAcceptNameForUnregisteredAccount.

@Test
public void shouldAcceptNameForUnregisteredAccount() throws FailedVerificationException {
    // given
    Player player = newPlayerWithName("MyPlayer");
    PlayerAuth auth = null;
    // when
    onJoinVerifier.checkNameCasing(player, auth);
    // then
    verifyZeroInteractions(dataSource);
}
Also used : Player(org.bukkit.entity.Player) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Example 54 with PlayerAuth

use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.

the class OnJoinVerifierTest method shouldAllowProperlyCasedName.

@Test
public void shouldAllowProperlyCasedName() throws FailedVerificationException {
    // given
    Player player = newPlayerWithName("Bobby");
    PlayerAuth auth = PlayerAuth.builder().name("bobby").realName("Bobby").build();
    given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true);
    // when
    onJoinVerifier.checkNameCasing(player, auth);
    // then
    verifyZeroInteractions(dataSource);
}
Also used : Player(org.bukkit.entity.Player) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Example 55 with PlayerAuth

use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.

the class OnJoinVerifierTest method shouldUpdateMissingRealName.

@Test
public void shouldUpdateMissingRealName() throws FailedVerificationException {
    // given
    Player player = newPlayerWithName("Authme");
    PlayerAuth auth = PlayerAuth.builder().name("authme").realName("").build();
    given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(true);
    // when
    onJoinVerifier.checkNameCasing(player, auth);
    // then
    verify(dataSource).updateRealName("authme", "Authme");
}
Also used : Player(org.bukkit.entity.Player) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Aggregations

PlayerAuth (fr.xephi.authme.data.auth.PlayerAuth)102 Test (org.junit.Test)65 Player (org.bukkit.entity.Player)33 HashedPassword (fr.xephi.authme.security.crypts.HashedPassword)21 CommandSender (org.bukkit.command.CommandSender)16 Location (org.bukkit.Location)14 LimboPlayer (fr.xephi.authme.data.limbo.LimboPlayer)9 IOException (java.io.IOException)7 World (org.bukkit.World)7 BufferedReader (java.io.BufferedReader)6 FileReader (java.io.FileReader)6 ArrayList (java.util.ArrayList)5 ValidationResult (fr.xephi.authme.service.ValidationService.ValidationResult)4 Connection (java.sql.Connection)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 AuthMeMatchers.hasAuthLocation (fr.xephi.authme.AuthMeMatchers.hasAuthLocation)3 File (java.io.File)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3