use of com.nexblocks.authguard.service.model.SessionBO in project AuthGuard by AuthGuard.
the class SessionVerifierTest method verifyExpiredSession.
@Test
void verifyExpiredSession() {
final SessionsService sessionsService = Mockito.mock(SessionsService.class);
final SessionVerifier sessionVerifier = new SessionVerifier(sessionsService);
final SessionBO session = SessionBO.builder().id("session-id").sessionToken("token").accountId("account-id").expiresAt(OffsetDateTime.now().minus(Duration.ofMinutes(20))).build();
Mockito.when(sessionsService.getByToken(session.getSessionToken())).thenReturn(Optional.of(session));
final Either<Exception, String> result = sessionVerifier.verifyAccountToken("session-id");
assertThat(result.isLeft());
assertThat(result.getLeft()).isInstanceOf(ServiceAuthorizationException.class);
}
use of com.nexblocks.authguard.service.model.SessionBO in project AuthGuard by AuthGuard.
the class SessionVerifierTest method verify.
@Test
void verify() {
final SessionsService sessionsService = Mockito.mock(SessionsService.class);
final SessionVerifier sessionVerifier = new SessionVerifier(sessionsService);
final SessionBO session = SessionBO.builder().id("session-id").sessionToken("token").accountId("account-id").expiresAt(OffsetDateTime.now().plus(Duration.ofMinutes(20))).build();
Mockito.when(sessionsService.getByToken(session.getSessionToken())).thenReturn(Optional.of(session));
final Either<Exception, String> accountId = sessionVerifier.verifyAccountToken(session.getSessionToken());
assertThat(accountId.get()).isEqualTo(session.getAccountId());
}
Aggregations