use of com.nexblocks.authguard.rest.config.ImmutableServerConfig in project AuthGuard by AuthGuard.
the class JettyServerProviderTest method getNoSslEnabled.
@Test
void getNoSslEnabled() {
final ImmutableServerConfig config = ImmutableServerConfig.builder().build();
final JettyServerProvider provider = new JettyServerProvider(config);
final Server server = provider.get();
assertThat(server.getConnectors()).hasSize(1).allMatch(connector -> connector.getProtocols().size() == 1 && connector.getProtocols().get(0).equals("http/1.1"));
}
use of com.nexblocks.authguard.rest.config.ImmutableServerConfig in project AuthGuard by AuthGuard.
the class ServerRunner method run.
public void run(final ConfigContext configContext) {
// class search
final Collection<String> searchPackages = configContext.getSubContext("injection").getAsCollection("packages", String.class);
final ClassSearch classSearch = new ClassSearch(searchPackages);
// injectors
final Injector injector = Guice.createInjector(new MappersBinder(), new ConfigBinder(configContext), new ExchangesBinder(configContext, searchPackages), new ApiKeysExchangeBinder(configContext, searchPackages), new ApiRoutesBinder(searchPackages, configContext), new ServicesBinder(configContext), new JwtBinder(configContext), new DalBinder(configContext, searchPackages), new EmbBinder(searchPackages), new ExternalProvidersBinder(configContext, searchPackages));
log.info("Initialed injection binders");
// run bootstraps
new BootstrapRunner(classSearch, injector).runAll();
log.info("Completed bootstrap");
// run the server
final ImmutableServerConfig serverConfig = Optional.ofNullable(configContext.getAsConfigBean("server", ImmutableServerConfig.class)).orElseGet(() -> ImmutableServerConfig.builder().port(3000).build());
new AuthGuardServer(injector).start(Javalin.create(config -> {
config.enforceSsl = serverConfig.enforceSsl();
config.server(() -> new JettyServerProvider(serverConfig).get());
config.accessManager(new RolesAccessManager());
}));
}
use of com.nexblocks.authguard.rest.config.ImmutableServerConfig in project AuthGuard by AuthGuard.
the class JettyServerProviderTest method getSslEnabledNoKeystore.
@Test
void getSslEnabledNoKeystore() {
final ImmutableServerConfig config = ImmutableServerConfig.builder().enableSsl(true).build();
final JettyServerProvider provider = new JettyServerProvider(config);
assertThatThrownBy(provider::get).isInstanceOf(InitializationException.class);
}
use of com.nexblocks.authguard.rest.config.ImmutableServerConfig in project AuthGuard by AuthGuard.
the class JettyServerProviderTest method getSslEnabled.
@Test
void getSslEnabled() {
final ImmutableServerConfig config = ImmutableServerConfig.builder().enableSsl(true).keystorePath("src/test/resources/keystore").keystorePassword(// taken from the Jetty example
"OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4").build();
final JettyServerProvider provider = new JettyServerProvider(config);
final Server server = provider.get();
assertThat(server.getConnectors()).anyMatch(connector -> connector.getProtocols().stream().anyMatch("ssl"::equals));
}
Aggregations