Search in sources :

Example 1 with ServerConfig

use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.

the class ServerConfigsValidatorTest method isNotValidWhenNoQ2TServersAreDefined.

@Test
public void isNotValidWhenNoQ2TServersAreDefined() {
    List<ServerConfig> serverConfigList = serverConfigList().stream().filter(s -> s.getApp() != AppType.Q2T).collect(Collectors.toList());
    Config config = new Config();
    config.setServerConfigs(serverConfigList);
    assertThat(validator.isValid(config, cvc)).isFalse();
    verify(cvc).disableDefaultConstraintViolation();
    verify(cvc).buildConstraintViolationWithTemplate(eq("At least one Q2T server must be configured or bootstrap mode enabled."));
}
Also used : AppType(com.quorum.tessera.config.AppType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConstraintValidatorContext(jakarta.validation.ConstraintValidatorContext) HashMap(java.util.HashMap) Test(org.junit.Test) ServerConfig(com.quorum.tessera.config.ServerConfig) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Mockito(org.mockito.Mockito) CommunicationType(com.quorum.tessera.config.CommunicationType) List(java.util.List) Map(java.util.Map) After(org.junit.After) Config(com.quorum.tessera.config.Config) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Before(org.junit.Before) ServerConfig(com.quorum.tessera.config.ServerConfig) ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 2 with ServerConfig

use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.

the class ServerConfigsValidatorTest method isNotValidWhenQ2TServersAreDefinedOnBootstrapNode.

@Test
public void isNotValidWhenQ2TServersAreDefinedOnBootstrapNode() {
    List<ServerConfig> serverConfigList = serverConfigList();
    Config config = new Config();
    config.setBootstrapNode(true);
    config.setServerConfigs(serverConfigList);
    assertThat(validator.isValid(config, cvc)).isFalse();
    verify(cvc).disableDefaultConstraintViolation();
    verify(cvc).buildConstraintViolationWithTemplate(eq("Q2T server cannot be specified on a bootstrap node."));
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 3 with ServerConfig

use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.

the class ServerConfigsValidatorTest method isValidWhenValidDataIsSupplied.

@Test
public void isValidWhenValidDataIsSupplied() {
    List<ServerConfig> serverConfigList = serverConfigList();
    Config config = new Config();
    config.setServerConfigs(serverConfigList);
    assertThat(validator.isValid(config, cvc)).isTrue();
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) Test(org.junit.Test)

Example 4 with ServerConfig

use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.

the class JerseyServerFactory method createServer.

@Override
public TesseraServer createServer(ServerConfig serverConfig, Set<Object> services) {
    LOGGER.debug("Creating JAXRS application with {} services: {}", serverConfig, services.stream().map(Object::toString).collect(Collectors.joining(",")));
    Application application = services.stream().filter(TesseraApp.class::isInstance).filter(Application.class::isInstance).map(TesseraApp.class::cast).filter(a -> a.getAppType().equals(serverConfig.getApp())).map(Application.class::cast).findFirst().get();
    LOGGER.debug("Created JAXRS application {}", application);
    return new JerseyServer(serverConfig, application.getClass());
}
Also used : TesseraApp(com.quorum.tessera.config.apps.TesseraApp) CommunicationType(com.quorum.tessera.config.CommunicationType) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Application(jakarta.ws.rs.core.Application) Set(java.util.Set) TesseraServer(com.quorum.tessera.server.TesseraServer) ServerConfig(com.quorum.tessera.config.ServerConfig) Collectors(java.util.stream.Collectors) TesseraServerFactory(com.quorum.tessera.server.TesseraServerFactory) TesseraApp(com.quorum.tessera.config.apps.TesseraApp) Application(jakarta.ws.rs.core.Application)

Example 5 with ServerConfig

use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.

the class VersionHeaderDecoratorTest method onSetUp.

@Before
public void onSetUp() throws Exception {
    System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.setCommunicationType(CommunicationType.REST);
    serverConfig.setServerAddress("http://localhost:8080");
    final ResourceConfig config = new ResourceConfig(SomeResource.class);
    this.server = ServerUtils.buildWebServer(serverConfig);
    ServletContextHandler context = new ServletContextHandler(server, "/");
    ServletContainer servletContainer = new ServletContainer(config);
    ServletHolder jerseyServlet = new ServletHolder(servletContainer);
    context.addServlet(jerseyServlet, "/*");
    // Sample Usage
    context.addFilter(VersionHeaderDecorator.class, "/*", EnumSet.allOf(DispatcherType.class));
    server.start();
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) DispatcherType(jakarta.servlet.DispatcherType) Before(org.junit.Before)

Aggregations

ServerConfig (com.quorum.tessera.config.ServerConfig)27 Config (com.quorum.tessera.config.Config)20 Test (org.junit.Test)19 Before (org.junit.Before)13 Client (jakarta.ws.rs.client.Client)11 Collectors (java.util.stream.Collectors)10 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)9 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)9 After (org.junit.After)9 JsonObject (jakarta.json.JsonObject)7 Response (jakarta.ws.rs.core.Response)7 Stream (java.util.stream.Stream)7 EncryptorConfig (com.quorum.tessera.config.EncryptorConfig)6 ConfigKeyPair (com.quorum.tessera.config.keypairs.ConfigKeyPair)6 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)6 KeyEncryptorFactory (com.quorum.tessera.config.keys.KeyEncryptorFactory)6 KeyDataUtil (com.quorum.tessera.config.util.KeyDataUtil)6 PublicKey (com.quorum.tessera.encryption.PublicKey)6 PartyInfoParser (com.quorum.tessera.p2p.partyinfo.PartyInfoParser)6 PartyInfo (com.quorum.tessera.partyinfo.model.PartyInfo)6