use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ClientFactoryTest method testBuildSecureClientCAMode.
@Test
public void testBuildSecureClientCAMode() throws URISyntaxException {
ServerConfig serverConfig = mock(ServerConfig.class);
SslConfig sslConfig = mock(SslConfig.class);
when(serverConfig.isSsl()).thenReturn(true);
when(serverConfig.getServerUri()).thenReturn(new URI("https://localhost:8080"));
when(serverConfig.getSslConfig()).thenReturn(sslConfig);
Map<String, String> props = new HashMap<>();
props.put("partyInfoInterval", "20000");
when(serverConfig.getProperties()).thenReturn(props);
SSLContext sslContext = mock(SSLContext.class);
when(sslContextFactory.from(serverConfig.getServerUri().toString(), sslConfig)).thenReturn(sslContext);
Client client = factory.buildFrom(serverConfig);
assertThat(client).isNotNull();
Map clientProperties = client.target(serverConfig.getServerUri()).getConfiguration().getProperties();
assertThat(clientProperties.get(ClientProperties.READ_TIMEOUT)).isEqualTo(15000);
assertThat(clientProperties.get(ClientProperties.CONNECT_TIMEOUT)).isEqualTo(15000);
verify(sslContextFactory).from(serverConfig.getServerUri().toString(), sslConfig);
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ClientFactoryTest method createUnixSocketClient.
@Test
public void createUnixSocketClient() {
ServerConfig serverConfig = new ServerConfig();
serverConfig.setServerAddress("unix:/tmp/bogus.socket");
serverConfig.setApp(AppType.Q2T);
serverConfig.setCommunicationType(CommunicationType.REST);
org.glassfish.jersey.client.JerseyClient result = (org.glassfish.jersey.client.JerseyClient) factory.buildFrom(serverConfig);
assertThat(result.getConfiguration().getProperty("unixfile")).isNotNull().isInstanceOf(URI.class);
assertThat(result.getConfiguration().getProperty("unixfile").toString()).isEqualTo("unix:/tmp/bogus.socket");
assertThat(result.getConfiguration().getConnectorProvider().getClass().getName()).isEqualTo("com.quorum.tessera.jaxrs.unixsocket.JerseyUnixSocketConnectorProvider");
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ClientFactoryTest method testBuildInsecureClient.
@Test
public void testBuildInsecureClient() {
ServerConfig serverConfig = mock(ServerConfig.class);
when(serverConfig.isSsl()).thenReturn(false);
when(serverConfig.getProperties()).thenReturn(Collections.emptyMap());
Client client = factory.buildFrom(serverConfig);
assertThat(client).isNotNull();
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ResendClientProviderTest method provider.
@Test
public void provider() {
try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
var clientSSLContextFactoryMockedStatic = mockStatic(ClientSSLContextFactory.class)) {
ConfigFactory configFactory = mock(ConfigFactory.class);
Config config = mock(Config.class);
ServerConfig serverConfig = mock(ServerConfig.class);
when(config.getP2PServerConfig()).thenReturn(serverConfig);
when(configFactory.getConfig()).thenReturn(config);
configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
clientSSLContextFactoryMockedStatic.when(ClientSSLContextFactory::create).thenReturn(mock(ClientSSLContextFactory.class));
ResendClient resendClient = ResendClientProvider.provider();
assertThat(resendClient).isNotNull().isExactlyInstanceOf(RestResendClient.class);
clientSSLContextFactoryMockedStatic.verify(ClientSSLContextFactory::create);
clientSSLContextFactoryMockedStatic.verifyNoMoreInteractions();
configFactoryMockedStatic.verify(ConfigFactory::create);
configFactoryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class JerseyServerIT 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");
CrossDomainConfig crossDomainConfig = new CrossDomainConfig();
crossDomainConfig.setAllowedOrigins(Arrays.asList("*.acme.com", "*.other.com"));
serverConfig.setCrossDomainConfig(crossDomainConfig);
JaxbUtil.marshalWithNoValidation(serverConfig, System.out);
server = new JerseyServer(serverConfig, SampleApplication.class);
server.start();
}
Aggregations