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));
}
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;
}
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);
}
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);
}
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");
}
Aggregations