use of com.nexblocks.authguard.config.ConfigContext in project AuthGuard by AuthGuard.
the class AuthenticationServiceImplTest method setup.
@BeforeAll
void setup() {
exchangeService = Mockito.mock(ExchangeService.class);
accountLocksService = Mockito.mock(AccountLocksService.class);
final ConfigContext configContext = Mockito.mock(ConfigContext.class);
final AuthenticationConfig config = AuthenticationConfig.builder().generateToken("accessToken").build();
Mockito.when(exchangeService.supportsExchange("basic", "accessToken")).thenReturn(true);
Mockito.when(configContext.asConfigBean(AuthenticationConfig.class)).thenReturn(config);
authenticationService = new AuthenticationServiceImpl(exchangeService, accountLocksService, configContext);
}
use of com.nexblocks.authguard.config.ConfigContext in project AuthGuard by AuthGuard.
the class OtpServiceImplTest method setup.
void setup(final OtpConfig otpConfig) {
mockExchangeService = Mockito.mock(ExchangeService.class);
final ConfigContext configContext = Mockito.mock(ConfigContext.class);
Mockito.when(configContext.asConfigBean(OtpConfig.class)).thenReturn(otpConfig);
otpService = new OtpServiceImpl(mockExchangeService, configContext);
}
use of com.nexblocks.authguard.config.ConfigContext in project AuthGuard by AuthGuard.
the class AutoSubscribersTest method subscribe.
@Test
void subscribe() {
final ObjectNode configRoot = new ObjectNode(JsonNodeFactory.instance);
final ArrayNode allowed = new ArrayNode(JsonNodeFactory.instance).add("com.nexblocks.authguard.emb.AutoSubscribersTest.ToBeSubscribed").add("com.nexblocks.authguard.emb.AutoSubscribersTest.NotToBeSubscribed");
configRoot.set("subscribers", allowed);
final MessageBus messageBus = Mockito.mock(MessageBus.class);
final ToBeSubscribed toBeSubscribed = new ToBeSubscribed();
final NotToBeSubscribed notToBeSubscribed = new NotToBeSubscribed();
final ConfigContext configContext = new JacksonConfigContext(configRoot);
final AutoSubscribers autoSubscribers = new AutoSubscribers(messageBus, ImmutableSet.of(toBeSubscribed, notToBeSubscribed), configContext);
autoSubscribers.subscribe();
Mockito.verify(messageBus, Mockito.times(1)).subscribe("test", toBeSubscribed);
Mockito.verify(messageBus, Mockito.never()).subscribe(Mockito.any(), Mockito.eq(notToBeSubscribed));
}
use of com.nexblocks.authguard.config.ConfigContext in project AuthGuard by AuthGuard.
the class OtpProviderTest method setup.
void setup(final OtpConfig otpConfig) {
mockOtpRepository = Mockito.mock(OtpRepository.class);
messageBus = Mockito.mock(MessageBus.class);
final ConfigContext configContext = Mockito.mock(ConfigContext.class);
Mockito.when(configContext.asConfigBean(OtpConfig.class)).thenReturn(otpConfig);
otpProvider = new OtpProvider(mockOtpRepository, new ServiceMapperImpl(), messageBus, configContext);
}
use of com.nexblocks.authguard.config.ConfigContext in project AuthGuard by AuthGuard.
the class ExchangesBinderTest method exchangesInjected.
@Test
void exchangesInjected() {
final ConfigContext rootContext = Mockito.mock(ConfigContext.class);
final ConfigContext exchangeContext = Mockito.mock(ConfigContext.class);
final ExchangesBinder.ExchangeConfig allowedExchange = new ExchangesBinder.ExchangeConfig();
allowedExchange.setFrom("basic");
allowedExchange.setTo("random");
Mockito.when(rootContext.getSubContext("exchange")).thenReturn(exchangeContext);
Mockito.when(exchangeContext.getAsCollection("allowed", ExchangesBinder.ExchangeConfig.class)).thenReturn(Collections.singletonList(allowedExchange));
final Collection<String> searchPackages = Collections.singletonList("com.nexblocks.authguard.bindings");
final Injector injector = Guice.createInjector(new ExchangesBinder(rootContext, searchPackages));
final NeedsExchanges needsExchanges = injector.getInstance(NeedsExchanges.class);
assertThat(needsExchanges.exchanges).hasSize(1);
assertThat(needsExchanges.exchanges.get(0)).isInstanceOf(FirstExchange.class);
}
Aggregations