Search in sources :

Example 1 with AccountsService

use of com.nexblocks.authguard.service.AccountsService in project AuthGuard by AuthGuard.

the class AuthorizationCodeToOidcTest method setup.

@BeforeEach
void setup() {
    authorizationCodeVerifier = Mockito.mock(AuthorizationCodeVerifier.class);
    accountsService = Mockito.mock(AccountsService.class);
    openIdConnectTokenProvider = Mockito.mock(OpenIdConnectTokenProvider.class);
    serviceMapper = new ServiceMapperImpl();
    authorizationCodeToOidc = new AuthorizationCodeToOidc(new AccountsServiceAdapter(accountsService), authorizationCodeVerifier, openIdConnectTokenProvider, serviceMapper);
}
Also used : ServiceMapperImpl(com.nexblocks.authguard.service.mappers.ServiceMapperImpl) AccountsService(com.nexblocks.authguard.service.AccountsService) AuthorizationCodeVerifier(com.nexblocks.authguard.jwt.oauth.AuthorizationCodeVerifier) OpenIdConnectTokenProvider(com.nexblocks.authguard.jwt.OpenIdConnectTokenProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with AccountsService

use of com.nexblocks.authguard.service.AccountsService in project AuthGuard by AuthGuard.

the class ApplicationsServiceImplTest method setup.

@BeforeEach
void setup() {
    applicationsRepository = Mockito.mock(ApplicationsRepository.class);
    accountsService = Mockito.mock(AccountsService.class);
    idempotencyService = Mockito.mock(IdempotencyService.class);
    messageBus = Mockito.mock(MessageBus.class);
    serviceMapper = new ServiceMapperImpl();
    applicationsService = new ApplicationsServiceImpl(applicationsRepository, accountsService, idempotencyService, serviceMapper, messageBus);
}
Also used : MessageBus(com.nexblocks.authguard.emb.MessageBus) ApplicationsRepository(com.nexblocks.authguard.dal.persistence.ApplicationsRepository) ServiceMapperImpl(com.nexblocks.authguard.service.mappers.ServiceMapperImpl) AccountsService(com.nexblocks.authguard.service.AccountsService) IdempotencyService(com.nexblocks.authguard.service.IdempotencyService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with AccountsService

use of com.nexblocks.authguard.service.AccountsService in project AuthGuard by AuthGuard.

the class CredentialsServiceImplTest method setup.

@BeforeEach
void setup() {
    accountsService = Mockito.mock(AccountsService.class);
    idempotencyService = Mockito.mock(IdempotencyService.class);
    credentialsRepository = Mockito.mock(CredentialsRepository.class);
    credentialsAuditRepository = Mockito.mock(CredentialsAuditRepository.class);
    accountTokensRepository = Mockito.mock(AccountTokensRepository.class);
    securePassword = Mockito.mock(SecurePassword.class);
    securePasswordProvider = Mockito.mock(SecurePasswordProvider.class);
    messageBus = Mockito.mock(MessageBus.class);
    serviceMapper = new ServiceMapperImpl();
    Mockito.when(securePasswordProvider.get()).thenReturn(securePassword);
    Mockito.when(securePasswordProvider.getCurrentVersion()).thenReturn(1);
    final PasswordValidator passwordValidator = new PasswordValidator(PasswordsConfig.builder().conditions(PasswordConditions.builder().build()).build());
    credentialsService = new CredentialsServiceImpl(accountsService, idempotencyService, credentialsRepository, credentialsAuditRepository, accountTokensRepository, securePasswordProvider, passwordValidator, messageBus, serviceMapper);
    Mockito.when(accountsService.getById(any())).thenReturn(Optional.of(RANDOM.nextObject(AccountBO.class)));
}
Also used : MessageBus(com.nexblocks.authguard.emb.MessageBus) CredentialsRepository(com.nexblocks.authguard.dal.persistence.CredentialsRepository) AccountTokensRepository(com.nexblocks.authguard.dal.cache.AccountTokensRepository) SecurePasswordProvider(com.nexblocks.authguard.basic.passwords.SecurePasswordProvider) ServiceMapperImpl(com.nexblocks.authguard.service.mappers.ServiceMapperImpl) AccountsService(com.nexblocks.authguard.service.AccountsService) SecurePassword(com.nexblocks.authguard.basic.passwords.SecurePassword) PasswordValidator(com.nexblocks.authguard.basic.passwords.PasswordValidator) IdempotencyService(com.nexblocks.authguard.service.IdempotencyService) CredentialsAuditRepository(com.nexblocks.authguard.dal.persistence.CredentialsAuditRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with AccountsService

use of com.nexblocks.authguard.service.AccountsService in project AuthGuard by AuthGuard.

the class OAuthServiceTest method setup.

@BeforeAll
void setup() {
    testIdentityServer = new TestIdentityServer();
    testIdentityServer.start();
    clientConfiguration = ImmutableOAuthClientConfiguration.builder().provider("test").authUrl("http://localhost:" + testIdentityServer.getPort() + "/auth").tokenUrl("http://localhost:" + testIdentityServer.getPort() + "/token").authRedirectUrl("http://localhost/redirect").tokenRedirectUrl("http://localhost/redirect").clientId("unit-tests").clientSecret("secret").addDefaultScopes("openid", "profile").build();
    accountProviderClientConfiguration = ImmutableOAuthClientConfiguration.builder().provider("account_test").authUrl("http://localhost:" + testIdentityServer.getPort() + "/auth").tokenUrl("http://localhost:" + testIdentityServer.getPort() + "/token").authRedirectUrl("http://localhost/redirect").tokenRedirectUrl("http://localhost/redirect").clientId("unit-tests").clientSecret("secret").addDefaultScopes("openid", "profile").accountProvider(true).emailField("email").build();
    final ImmutableOAuthConfiguration oAuthConfiguration = ImmutableOAuthConfiguration.builder().addClients(clientConfiguration).addClients(accountProviderClientConfiguration).build();
    sessionsService = Mockito.mock(SessionsService.class);
    accountsService = Mockito.mock(AccountsService.class);
    oAuthService = new OAuthService(oAuthConfiguration, sessionsService, accountsService);
}
Also used : TestIdentityServer(com.nexblocks.authguard.jwt.oauth.TestIdentityServer) SessionsService(com.nexblocks.authguard.service.SessionsService) AccountsService(com.nexblocks.authguard.service.AccountsService) ImmutableOAuthConfiguration(com.nexblocks.authguard.jwt.oauth.config.ImmutableOAuthConfiguration)

Aggregations

AccountsService (com.nexblocks.authguard.service.AccountsService)4 ServiceMapperImpl (com.nexblocks.authguard.service.mappers.ServiceMapperImpl)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 MessageBus (com.nexblocks.authguard.emb.MessageBus)2 IdempotencyService (com.nexblocks.authguard.service.IdempotencyService)2 PasswordValidator (com.nexblocks.authguard.basic.passwords.PasswordValidator)1 SecurePassword (com.nexblocks.authguard.basic.passwords.SecurePassword)1 SecurePasswordProvider (com.nexblocks.authguard.basic.passwords.SecurePasswordProvider)1 AccountTokensRepository (com.nexblocks.authguard.dal.cache.AccountTokensRepository)1 ApplicationsRepository (com.nexblocks.authguard.dal.persistence.ApplicationsRepository)1 CredentialsAuditRepository (com.nexblocks.authguard.dal.persistence.CredentialsAuditRepository)1 CredentialsRepository (com.nexblocks.authguard.dal.persistence.CredentialsRepository)1 OpenIdConnectTokenProvider (com.nexblocks.authguard.jwt.OpenIdConnectTokenProvider)1 AuthorizationCodeVerifier (com.nexblocks.authguard.jwt.oauth.AuthorizationCodeVerifier)1 TestIdentityServer (com.nexblocks.authguard.jwt.oauth.TestIdentityServer)1 ImmutableOAuthConfiguration (com.nexblocks.authguard.jwt.oauth.config.ImmutableOAuthConfiguration)1 SessionsService (com.nexblocks.authguard.service.SessionsService)1