#792 #814 Implement SQLite migration, allow last IP to be nullable in MySQL

- Old SQLite setups have the last IP column as NOT NULL but without a default value. With the new concept (where we don't set a last IP on player registration) it fails.
  - Create an /authme debug child that allows to migrate SQLite (tricky because SQLite does not support dropping or modifying columns)
  - Allow last IP column to be NOT NULL in MySQL as well (extend MySQL /authme debug child)
- Add TODO comments with follow-up issue to extend our commands with new registration IP field
This commit is contained in:
ljacqu
2017-10-21 10:24:40 +02:00
parent b5ea48085c
commit 1651a61063
29 changed files with 688 additions and 130 deletions
@@ -213,6 +213,30 @@ public class SessionServiceTest {
verify(dataSource).getAuth(name);
}
@Test
public void shouldHandlePlayerAuthWithNullLastIp() {
// given
String name = "Charles";
Player player = mockPlayerWithNameAndIp(name, "144.117.118.145");
given(dataSource.hasSession(name)).willReturn(true);
PlayerAuth auth = PlayerAuth.builder()
.name(name)
.lastIp(null)
.lastLogin(System.currentTimeMillis()).build();
given(dataSource.getAuth(name)).willReturn(auth);
// when
boolean result = sessionService.canResumeSession(player);
// then
assertThat(result, equalTo(false));
verify(commonService).getProperty(PluginSettings.SESSIONS_ENABLED);
verify(dataSource).hasSession(name);
verify(dataSource).setUnlogged(name);
verify(dataSource).revokeSession(name);
verify(dataSource).getAuth(name);
}
private static Player mockPlayerWithNameAndIp(String name, String ip) {
Player player = mock(Player.class);
given(player.getName()).willReturn(name);