KEYCLOAK-13847 fix offline token refresh date

This commit is contained in:
Yoshiyuki Tabata 2021-11-25 17:06:22 +09:00 committed by Marek Posolda
parent d9bf511406
commit b1eeb0626e
2 changed files with 6 additions and 1 deletions

View file

@ -954,7 +954,7 @@ public class UserResource {
if (clientSession == null) { if (clientSession == null) {
return null; return null;
} }
rep.setLastAccess(clientSession.getTimestamp()); rep.setLastAccess(Time.toMillis(clientSession.getTimestamp()));
return rep; return rep;
} }
} }

View file

@ -19,8 +19,11 @@ package org.keycloak.testsuite.admin;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -536,6 +539,8 @@ public class ClientTest extends AbstractAdminTest {
List<UserSessionRepresentation> offlineUserSessions = realm.clients().get(id).getOfflineUserSessions(0, 100); List<UserSessionRepresentation> offlineUserSessions = realm.clients().get(id).getOfflineUserSessions(0, 100);
assertEquals(1, offlineUserSessions.size()); assertEquals(1, offlineUserSessions.size());
assertEquals("testuser", offlineUserSessions.get(0).getUsername()); assertEquals("testuser", offlineUserSessions.get(0).getUsername());
org.hamcrest.MatcherAssert.assertThat(offlineUserSessions.get(0).getLastAccess(),
allOf(greaterThan(Time.currentTimeMillis() - 10000L), lessThan(Time.currentTimeMillis())));
userSessions = realm.users().get(userId).getOfflineSessions(id); userSessions = realm.users().get(userId).getOfflineSessions(id);
assertEquals("There should be one offline session", 1, userSessions.size()); assertEquals("There should be one offline session", 1, userSessions.size());