Search in sources :

Example 11 with AppBO

use of com.nexblocks.authguard.service.model.AppBO in project AuthGuard by AuthGuard.

the class ApplicationsServiceImplTest method getById.

@Test
void getById() {
    final AppBO app = random.nextObject(AppBO.class).withDeleted(false);
    Mockito.when(applicationsRepository.getById(any())).thenReturn(CompletableFuture.completedFuture(Optional.of(serviceMapper.toDO(app))));
    final Optional<AppBO> retrieved = applicationsService.getById("");
    final List<PermissionBO> expectedPermissions = app.getPermissions().stream().map(permission -> permission.withEntityType(null)).collect(Collectors.toList());
    assertThat(retrieved).isPresent();
    assertThat(retrieved.get()).isEqualToIgnoringGivenFields(app.withPermissions(expectedPermissions), "permissions", "entityType");
}
Also used : ServiceMapper(com.nexblocks.authguard.service.mappers.ServiceMapper) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) MessageBus(com.nexblocks.authguard.emb.MessageBus) RequestContextBO(com.nexblocks.authguard.service.model.RequestContextBO) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ServiceMapperImpl(com.nexblocks.authguard.service.mappers.ServiceMapperImpl) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) AccountsService(com.nexblocks.authguard.service.AccountsService) AppBO(com.nexblocks.authguard.service.model.AppBO) ApplicationsService(com.nexblocks.authguard.service.ApplicationsService) IdempotencyService(com.nexblocks.authguard.service.IdempotencyService) EasyRandomParameters(org.jeasy.random.EasyRandomParameters) AppDO(com.nexblocks.authguard.dal.model.AppDO) ApplicationsRepository(com.nexblocks.authguard.dal.persistence.ApplicationsRepository) EasyRandom(org.jeasy.random.EasyRandom) AccountBO(com.nexblocks.authguard.service.model.AccountBO) PermissionBO(com.nexblocks.authguard.service.model.PermissionBO) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Optional(java.util.Optional) AppBO(com.nexblocks.authguard.service.model.AppBO) PermissionBO(com.nexblocks.authguard.service.model.PermissionBO) Test(org.junit.jupiter.api.Test)

Example 12 with AppBO

use of com.nexblocks.authguard.service.model.AppBO in project AuthGuard by AuthGuard.

the class DefaultApiKeyExchangeTest method generateKey.

@Test
void generateKey() {
    final AppBO app = AppBO.builder().id("app").build();
    final AuthResponseBO expected = AuthResponseBO.builder().type("api_key").entityType(EntityType.APPLICATION).entityId(app.getId()).build();
    final AuthResponseBO actual = exchange.generateKey(app);
    assertThat(actual).isEqualToIgnoringGivenFields(expected, "token");
    assertThat(actual.getToken()).isNotNull();
}
Also used : AppBO(com.nexblocks.authguard.service.model.AppBO) AuthResponseBO(com.nexblocks.authguard.service.model.AuthResponseBO) Test(org.junit.jupiter.api.Test)

Aggregations

AppBO (com.nexblocks.authguard.service.model.AppBO)12 Test (org.junit.jupiter.api.Test)8 AppDO (com.nexblocks.authguard.dal.model.AppDO)4 Error (com.nexblocks.authguard.api.dto.entities.Error)3 ApplicationsRepository (com.nexblocks.authguard.dal.persistence.ApplicationsRepository)2 MessageBus (com.nexblocks.authguard.emb.MessageBus)2 AccountsService (com.nexblocks.authguard.service.AccountsService)2 ApplicationsService (com.nexblocks.authguard.service.ApplicationsService)2 IdempotencyService (com.nexblocks.authguard.service.IdempotencyService)2 ServiceMapper (com.nexblocks.authguard.service.mappers.ServiceMapper)2 ServiceMapperImpl (com.nexblocks.authguard.service.mappers.ServiceMapperImpl)2 AccountBO (com.nexblocks.authguard.service.model.AccountBO)2 AuthResponseBO (com.nexblocks.authguard.service.model.AuthResponseBO)2 PermissionBO (com.nexblocks.authguard.service.model.PermissionBO)2 RequestContextBO (com.nexblocks.authguard.service.model.RequestContextBO)2 List (java.util.List)2 Optional (java.util.Optional)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Supplier (java.util.function.Supplier)2 Collectors (java.util.stream.Collectors)2