Search in sources :

Example 61 with PlayerAuth

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

the class OnJoinVerifierTest method shouldAcceptCasingMismatchForDisabledSetting.

@Test
public void shouldAcceptCasingMismatchForDisabledSetting() throws FailedVerificationException {
    // given
    Player player = newPlayerWithName("Test");
    PlayerAuth auth = PlayerAuth.builder().name("test").realName("TEST").build();
    given(settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)).willReturn(false);
    // 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 62 with PlayerAuth

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

the class OnJoinVerifierTest method shouldUpdateDefaultRealName.

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

Example 63 with PlayerAuth

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

the class AbstractDataSourceIntegrationTest method shouldUpdateLastLoc.

@Test
public void shouldUpdateLastLoc() {
    // given
    DataSource dataSource = getDataSource();
    PlayerAuth user = PlayerAuth.builder().name("user").locX(143).locY(-42.12).locZ(29.47).locWorld("the_end").locYaw(2.2f).locPitch(0.45f).build();
    // when
    boolean response = dataSource.updateQuitLoc(user);
    // then
    assertThat(response, equalTo(true));
    assertThat(dataSource.getAuth("user"), hasAuthLocation(user));
}
Also used : PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Example 64 with PlayerAuth

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

the class AbstractDataSourceIntegrationTest method shouldGetRecordsToPurge.

@Test
public void shouldGetRecordsToPurge() {
    // given
    DataSource dataSource = getDataSource();
    PlayerAuth auth = PlayerAuth.builder().name("potato").lastLogin(0).build();
    dataSource.saveAuth(auth);
    // 1453242857 -> user, 1449136800 -> bobby, 0 -> potato
    // when
    Set<String> records1 = dataSource.getRecordsToPurge(1450000000, true);
    Set<String> records2 = dataSource.getRecordsToPurge(1460000000, false);
    // then
    assertThat(records1, containsInAnyOrder("bobby", "potato"));
    assertThat(records2, containsInAnyOrder("bobby", "user"));
    // check that the entry was not deleted because of running this command
    assertThat(dataSource.isAuthAvailable("bobby"), equalTo(true));
}
Also used : PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) Test(org.junit.Test)

Example 65 with PlayerAuth

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

the class AbstractDataSourceIntegrationTest method shouldUpdatePasswordWithPlayerAuth.

@Test
public void shouldUpdatePasswordWithPlayerAuth() {
    // given
    DataSource dataSource = getDataSource("salt");
    PlayerAuth bobbyAuth = PlayerAuth.builder().name("bobby").password(new HashedPassword("tt", "cc")).build();
    PlayerAuth invalidAuth = PlayerAuth.builder().name("invalid").password(new HashedPassword("tt", "cc")).build();
    // when
    boolean response1 = dataSource.updatePassword(bobbyAuth);
    boolean response2 = dataSource.updatePassword(invalidAuth);
    // then
    assertThat(response1 && response2, equalTo(true));
    assertThat(dataSource.getPassword("bobby"), equalToHash("tt", "cc"));
}
Also used : PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) HashedPassword(fr.xephi.authme.security.crypts.HashedPassword) 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