use of com.nexblocks.authguard.dal.model.SessionDO in project AuthGuard by AuthGuard.
the class SessionsServiceImpl method create.
@Override
public SessionBO create(final SessionBO session) {
final SessionDO sessionDO = serviceMapper.toDO(session);
sessionDO.setId(ID.generate());
sessionDO.setSessionToken(cryptographicRandom.base64Url(config.getRandomSize()));
return sessionsRepository.save(sessionDO).thenApply(created -> {
emb.publish(CHANNEL, Messages.created(created));
return serviceMapper.toBO(created);
}).join();
}
use of com.nexblocks.authguard.dal.model.SessionDO in project AuthGuard by AuthGuard.
the class SessionsServiceImplTest method deleteByToken.
@Test
void deleteByToken() {
final SessionDO sessionDO = SessionDO.builder().id("session-id").accountId("account").sessionToken("token").data(Collections.singletonMap("key", "value")).build();
Mockito.when(repository.deleteByToken(sessionDO.getSessionToken())).thenReturn(CompletableFuture.completedFuture(Optional.of(sessionDO)));
final SessionBO expected = serviceMapper.toBO(sessionDO);
final Optional<SessionBO> actual = service.deleteByToken(sessionDO.getSessionToken());
assertThat(actual).contains(expected);
}
use of com.nexblocks.authguard.dal.model.SessionDO in project AuthGuard by AuthGuard.
the class SessionsServiceImplTest method getByToken.
@Test
void getByToken() {
final SessionDO sessionDO = SessionDO.builder().id("session-id").accountId("account").sessionToken("token").data(Collections.singletonMap("key", "value")).build();
Mockito.when(repository.getByToken(sessionDO.getSessionToken())).thenReturn(CompletableFuture.completedFuture(Optional.of(sessionDO)));
final SessionBO expected = serviceMapper.toBO(sessionDO);
final Optional<SessionBO> actual = service.getByToken(sessionDO.getSessionToken());
assertThat(actual).contains(expected);
}
use of com.nexblocks.authguard.dal.model.SessionDO in project AuthGuard by AuthGuard.
the class SessionsServiceImplTest method getById.
@Test
void getById() {
final SessionDO sessionDO = SessionDO.builder().id("session-id").accountId("account").data(Collections.singletonMap("key", "value")).build();
Mockito.when(repository.getById(sessionDO.getId())).thenReturn(CompletableFuture.completedFuture(Optional.of(sessionDO)));
final SessionBO expected = serviceMapper.toBO(sessionDO);
final Optional<SessionBO> actual = service.getById(sessionDO.getId());
assertThat(actual).contains(expected);
}
Aggregations