use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.
the class CrazyLoginConverter method migrateAccount.
/**
* Moves an account from CrazyLogin to the AuthMe database.
*
* @param line line read from the CrazyLogin file (one account)
*/
private void migrateAccount(String line) {
String[] args = line.split("\\|");
if (args.length < 2 || "name".equalsIgnoreCase(args[0])) {
return;
}
String playerName = args[0];
String password = args[1];
if (password != null) {
PlayerAuth auth = PlayerAuth.builder().name(playerName.toLowerCase()).realName(playerName).password(password, null).build();
database.saveAuth(auth);
}
}
use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.
the class NewAPITest method shouldGetLastLocation.
@Test
public void shouldGetLastLocation() {
// given
String name = "Gary";
Player player = mockPlayerWithName(name);
PlayerAuth auth = PlayerAuth.builder().name(name).locWorld("world").locX(12.4).locY(24.6).locZ(-438.2).locYaw(3.41f).locPitch(0.29f).build();
given(playerCache.getAuth(name)).willReturn(auth);
Server server = mock(Server.class);
ReflectionTestUtils.setField(Bukkit.class, null, "server", server);
World world = mock(World.class);
given(server.getWorld(auth.getWorld())).willReturn(world);
// when
Location result = api.getLastLocation(player);
// then
assertThat(result, not(nullValue()));
assertThat(result.getX(), equalTo(auth.getQuitLocX()));
assertThat(result.getY(), equalTo(auth.getQuitLocY()));
assertThat(result.getZ(), equalTo(auth.getQuitLocZ()));
assertThat(result.getWorld(), equalTo(world));
}
use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.
the class AbstractDataSourceConverterTest method shouldConvertAndSkipExistingPlayers.
@Test
public void shouldConvertAndSkipExistingPlayers() {
// given
DataSource source = mock(DataSource.class);
DataSource destination = mock(DataSource.class);
DataSourceType destinationType = DataSourceType.MYSQL;
given(destination.getType()).willReturn(destinationType);
List<PlayerAuth> auths = Arrays.asList(mockAuthWithName("Steven"), mockAuthWithName("bobby"), mockAuthWithName("Jack"));
given(source.getAllAuths()).willReturn(auths);
given(destination.isAuthAvailable(auths.get(0).getNickname())).willReturn(true);
Converter converter = new DataSourceConverterTestImpl<>(source, destination, destinationType);
CommandSender sender = mock(CommandSender.class);
// when
converter.execute(sender);
// then
verify(destination).getType();
verify(destination, times(3)).isAuthAvailable(anyString());
verify(destination, times(2)).saveAuth(any(PlayerAuth.class));
verify(destination, times(2)).updateQuitLoc(any(PlayerAuth.class));
verifyNoMoreInteractions(destination);
verify(sender).sendMessage(argThat(containsString(auths.get(0).getNickname())));
verify(sender).sendMessage(argThat(containsString("successfully converted")));
}
use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.
the class CrazyLoginConverterTest method shouldImportUsers.
@Test
public void shouldImportUsers() {
// given
given(settings.getProperty(ConverterSettings.CRAZYLOGIN_FILE_NAME)).willReturn("crazylogin.db");
CommandSender sender = mock(CommandSender.class);
// when
crazyLoginConverter.execute(sender);
// then
ArgumentCaptor<PlayerAuth> authCaptor = ArgumentCaptor.forClass(PlayerAuth.class);
verify(dataSource, times(2)).saveAuth(authCaptor.capture());
List<PlayerAuth> savedAuths = authCaptor.getAllValues();
assertNameAndRealName(savedAuths.get(0), "qotato", "qotaTo");
assertThat(savedAuths.get(0).getPassword(), equalToHash("8267663ab198a96437b9f455429a2c1b6c943111613c217bf2703c14d08a309d34e510ddb5549507b1500759dbcf9d4a99bc765ff37b32bd31adbb1e92e74ac5"));
assertNameAndRealName(savedAuths.get(1), "bobby", "Bobby");
assertThat(savedAuths.get(1).getPassword(), equalToHash("ad50dbc841e6321210530801f5219a5ffb4c7c41f11878d465374a4b8db2965c50f69b6098918a58e4adea312e3633c7724b15e24a217009e6fa2b3c299d55f2"));
}
use of fr.xephi.authme.data.auth.PlayerAuth in project AuthMeReloaded by AuthMe.
the class ForceFlatToSqliteTest method shouldConvertToSqlite.
@Test
public void shouldConvertToSqlite() {
// given
DataSource dataSource = mock(DataSource.class);
given(dataSource.getType()).willReturn(DataSourceType.MYSQL);
ForceFlatToSqlite converter = new ForceFlatToSqlite(flatFile, dataSource);
// when
converter.execute(null);
// then
ArgumentCaptor<PlayerAuth> authCaptor = ArgumentCaptor.forClass(PlayerAuth.class);
verify(dataSource, times(7)).saveAuth(authCaptor.capture());
List<PlayerAuth> auths = authCaptor.getAllValues();
assertThat(auths, hasItem(hasAuthBasicData("bobby", "Player", "your@email.com", "123.45.67.89")));
assertThat(auths, hasItem(hasAuthLocation(1.05, 2.1, 4.2, "world", 0, 0)));
assertThat(auths, hasItem(hasAuthBasicData("user", "Player", "user@example.org", "34.56.78.90")));
assertThat(auths, hasItem(hasAuthLocation(124.1, 76.3, -127.8, "nether", 0, 0)));
assertThat(auths, hasItem(hasAuthBasicData("eightfields", "Player", "your@email.com", "6.6.6.66")));
assertThat(auths, hasItem(hasAuthLocation(8.8, 17.6, 26.4, "eightworld", 0, 0)));
}
Aggregations