#792 Add columns for registration IP and registration date
- Add columns for reg date and IP - Rename "ip" to "last IP"
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.Set;
|
||||
import static fr.xephi.authme.AuthMeMatchers.equalToHash;
|
||||
import static fr.xephi.authme.AuthMeMatchers.hasAuthBasicData;
|
||||
import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation;
|
||||
import static fr.xephi.authme.AuthMeMatchers.hasRegistrationInfo;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
@@ -97,11 +98,13 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
|
||||
assertThat(bobbyAuth, hasAuthBasicData("bobby", "Bobby", "your@email.com", "123.45.67.89"));
|
||||
assertThat(bobbyAuth, hasAuthLocation(1.05, 2.1, 4.2, "world", -0.44f, 2.77f));
|
||||
assertThat(bobbyAuth, hasRegistrationInfo("127.0.4.22", 1436778723L));
|
||||
assertThat(bobbyAuth.getLastLogin(), equalTo(1449136800L));
|
||||
assertThat(bobbyAuth.getPassword(), equalToHash("$SHA$11aa0706173d7272$dbba966"));
|
||||
|
||||
assertThat(userAuth, hasAuthBasicData("user", "user", "user@example.org", "34.56.78.90"));
|
||||
assertThat(userAuth, hasAuthLocation(124.1, 76.3, -127.8, "nether", 0.23f, 4.88f));
|
||||
assertThat(userAuth, hasRegistrationInfo(null, 0));
|
||||
assertThat(userAuth.getLastLogin(), equalTo(1453242857L));
|
||||
assertThat(userAuth.getPassword(), equalToHash("b28c32f624a4eb161d6adc9acb5bfc5b", "f750ba32"));
|
||||
}
|
||||
@@ -211,7 +214,7 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
DataSource dataSource = getDataSource();
|
||||
PlayerAuth bobby = PlayerAuth.builder()
|
||||
.name("bobby").realName("BOBBY").lastLogin(123L)
|
||||
.ip("12.12.12.12").build();
|
||||
.lastIp("12.12.12.12").build();
|
||||
|
||||
// when
|
||||
boolean response = dataSource.updateSession(bobby);
|
||||
@@ -298,7 +301,9 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
List<String> initialList = dataSource.getAllAuthsByIp("123.45.67.89");
|
||||
List<String> emptyList = dataSource.getAllAuthsByIp("8.8.8.8");
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
dataSource.saveAuth(PlayerAuth.builder().name("test-" + i).ip("123.45.67.89").build());
|
||||
PlayerAuth auth = PlayerAuth.builder().name("test-" + i).lastIp("123.45.67.89").build();
|
||||
dataSource.saveAuth(auth);
|
||||
dataSource.updateSession(auth); // trigger storage of last IP
|
||||
}
|
||||
List<String> updatedList = dataSource.getAllAuthsByIp("123.45.67.89");
|
||||
|
||||
@@ -329,8 +334,9 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
public void shouldGetRecordsToPurge() {
|
||||
// given
|
||||
DataSource dataSource = getDataSource();
|
||||
PlayerAuth auth = PlayerAuth.builder().name("potato").lastLogin(0).build();
|
||||
PlayerAuth auth = PlayerAuth.builder().name("potato").lastLogin(0L).build();
|
||||
dataSource.saveAuth(auth);
|
||||
dataSource.updateSession(auth);
|
||||
// 1453242857 -> user, 1449136800 -> bobby, 0 -> potato
|
||||
|
||||
// when
|
||||
|
||||
@@ -79,7 +79,7 @@ public class FlatFileIntegrationTest {
|
||||
public void shouldAddAuth() {
|
||||
// given / when
|
||||
boolean response = dataSource.saveAuth(
|
||||
PlayerAuth.builder().name("Test").email("user@EXAMPLE.org").ip("123.45.67.77").build());
|
||||
PlayerAuth.builder().name("Test").email("user@EXAMPLE.org").lastIp("123.45.67.77").build());
|
||||
List<PlayerAuth> authList = dataSource.getAllAuths();
|
||||
|
||||
// then
|
||||
|
||||
+1
@@ -98,6 +98,7 @@ public class AbstractDataSourceConverterTest {
|
||||
verify(destination).getType();
|
||||
verify(destination, times(3)).isAuthAvailable(anyString());
|
||||
verify(destination, times(2)).saveAuth(any(PlayerAuth.class));
|
||||
verify(destination, times(2)).updateSession(any(PlayerAuth.class));
|
||||
verify(destination, times(2)).updateQuitLoc(any(PlayerAuth.class));
|
||||
verifyNoMoreInteractions(destination);
|
||||
verify(sender).sendMessage(argThat(containsString(auths.get(0).getNickname())));
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.sql.Statement;
|
||||
import static fr.xephi.authme.AuthMeMatchers.equalToHash;
|
||||
import static fr.xephi.authme.AuthMeMatchers.hasAuthLocation;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -71,16 +73,19 @@ public class LoginSecurityConverterTest {
|
||||
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).getRegistrationDate(), equalTo(1494242093400L));
|
||||
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(0).getLastIp(), 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(1).getLastIp(), 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));
|
||||
assertThat(captor.getAllValues().get(2).getLastIp(), equalTo("127.0.0.1"));
|
||||
assertIsCloseTo(captor.getAllValues().get(2).getRegistrationDate(), System.currentTimeMillis(), 500L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,11 +104,12 @@ public class LoginSecurityConverterTest {
|
||||
assertThat(captor.getAllValues().get(0).getRealName(), equalTo("Player1"));
|
||||
assertThat(captor.getAllValues().get(0).getLastLogin(), equalTo(1494242093000L));
|
||||
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(0).getLastIp(), equalTo("127.0.0.1"));
|
||||
assertThat(captor.getAllValues().get(0).getRegistrationDate(), equalTo(1494194400000L));
|
||||
|
||||
assertThat(captor.getAllValues().get(1).getNickname(), equalTo("player2"));
|
||||
assertThat(captor.getAllValues().get(1).getLastLogin(), equalTo(1489317753000L));
|
||||
assertThat(captor.getAllValues().get(1).getIp(), equalTo("127.4.5.6"));
|
||||
assertThat(captor.getAllValues().get(1).getLastIp(), equalTo("127.4.5.6"));
|
||||
|
||||
assertThat(captor.getAllValues().get(2).getRealName(), equalTo("Player3"));
|
||||
assertThat(captor.getAllValues().get(2).getPassword(), equalToHash("$2a$10$WFui8KSXMLDOVXKFpCLyPukPi4M82w1cv/rNojsAnwJjba3pp8sba"));
|
||||
@@ -129,4 +135,8 @@ public class LoginSecurityConverterTest {
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
private static void assertIsCloseTo(long value1, long value2, long tolerance) {
|
||||
assertThat(Math.abs(value1 - value2), not(greaterThan(tolerance)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user