* Introduce hasSession field in datasource That makes isLogged more consistent as it will be '1' only when the player is online. * Fixes * Fix unit testing * Update config doc * Create SessionService * Create test for SessionService, avoid DB operations if sessions are disabled * Cleanup: remove outdated warning for session timeout = 0 - Remove outdated warning - Encapsulate session enabled check in SessionService * Fix failing SessionServiceTest, add data source integration tests for session methods
This commit is contained in:
@@ -416,4 +416,36 @@ public abstract class AbstractDataSourceIntegrationTest {
|
||||
// then
|
||||
assertThat(loggedPlayersWithEmptyMail, contains("Bobby"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGrantAndRetrieveSessionFlag() {
|
||||
// given
|
||||
DataSource dataSource = getDataSource();
|
||||
|
||||
// when
|
||||
dataSource.grantSession("bobby");
|
||||
dataSource.grantSession("doesNotExist");
|
||||
|
||||
// then
|
||||
assertThat(dataSource.hasSession("bobby"), equalTo(true));
|
||||
assertThat(dataSource.hasSession("user"), equalTo(false));
|
||||
assertThat(dataSource.hasSession("bogus"), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRevokeSession() {
|
||||
// given
|
||||
DataSource dataSource = getDataSource();
|
||||
dataSource.grantSession("bobby");
|
||||
dataSource.grantSession("user");
|
||||
|
||||
// when
|
||||
dataSource.revokeSession("bobby");
|
||||
dataSource.revokeSession("userNotInDatabase");
|
||||
|
||||
// then
|
||||
assertThat(dataSource.hasSession("bobby"), equalTo(false));
|
||||
assertThat(dataSource.hasSession("user"), equalTo(true));
|
||||
assertThat(dataSource.hasSession("nonExistentName"), equalTo(false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user