Search in sources :

Example 1 with ClientSSLContextFactory

use of com.quorum.tessera.ssl.context.ClientSSLContextFactory 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();
    }
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ClientSSLContextFactory(com.quorum.tessera.ssl.context.ClientSSLContextFactory) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 2 with ClientSSLContextFactory

use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.

the class RecoveryClientProviderTest 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));
        RecoveryClient recoveryClient = RecoveryClientProvider.provider();
        assertThat(recoveryClient).isNotNull().isExactlyInstanceOf(RestRecoveryClient.class);
        clientSSLContextFactoryMockedStatic.verify(ClientSSLContextFactory::create);
        clientSSLContextFactoryMockedStatic.verifyNoMoreInteractions();
        configFactoryMockedStatic.verify(ConfigFactory::create);
        configFactoryMockedStatic.verifyNoMoreInteractions();
    }
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ClientSSLContextFactory(com.quorum.tessera.ssl.context.ClientSSLContextFactory) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 3 with ClientSSLContextFactory

use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.

the class P2pClientProvider method provider.

public static P2pClient provider() {
    Config config = ConfigFactory.create().getConfig();
    SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
    ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
    Client client = clientFactory.buildFrom(config.getP2PServerConfig());
    return new RestP2pClient(client);
}
Also used : Config(com.quorum.tessera.config.Config) ClientFactory(com.quorum.tessera.jaxrs.client.ClientFactory) ClientSSLContextFactory(com.quorum.tessera.ssl.context.ClientSSLContextFactory) SSLContextFactory(com.quorum.tessera.ssl.context.SSLContextFactory) Client(jakarta.ws.rs.client.Client) P2pClient(com.quorum.tessera.partyinfo.P2pClient)

Example 4 with ClientSSLContextFactory

use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.

the class RecoveryClientProvider method provider.

public static RecoveryClient provider() {
    final Config config = ConfigFactory.create().getConfig();
    final ServerConfig serverConfig = config.getP2PServerConfig();
    final Map<String, String> properties = serverConfig.getProperties();
    final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
    final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
    final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
    final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
    client.property("jersey.config.client.readTimeout", waitTime);
    return new RestRecoveryClient(client);
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) IntervalPropertyHelper(com.quorum.tessera.config.util.IntervalPropertyHelper) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) ClientFactory(com.quorum.tessera.jaxrs.client.ClientFactory) ClientSSLContextFactory(com.quorum.tessera.ssl.context.ClientSSLContextFactory) SSLContextFactory(com.quorum.tessera.ssl.context.SSLContextFactory) Client(jakarta.ws.rs.client.Client)

Example 5 with ClientSSLContextFactory

use of com.quorum.tessera.ssl.context.ClientSSLContextFactory in project tessera by ConsenSys.

the class ResendClientProvider method provider.

public static ResendClient provider() {
    final Config config = ConfigFactory.create().getConfig();
    final ServerConfig serverConfig = config.getP2PServerConfig();
    final Map<String, String> properties = serverConfig.getProperties();
    final String waitTime = new IntervalPropertyHelper(properties).resendWaitTime();
    final SSLContextFactory clientSSLContextFactory = ClientSSLContextFactory.create();
    final ClientFactory clientFactory = new ClientFactory(clientSSLContextFactory);
    final Client client = clientFactory.buildFrom(config.getP2PServerConfig());
    client.property("jersey.config.client.readTimeout", waitTime);
    return new RestResendClient(client);
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) IntervalPropertyHelper(com.quorum.tessera.config.util.IntervalPropertyHelper) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) ClientFactory(com.quorum.tessera.jaxrs.client.ClientFactory) ClientSSLContextFactory(com.quorum.tessera.ssl.context.ClientSSLContextFactory) SSLContextFactory(com.quorum.tessera.ssl.context.SSLContextFactory) Client(jakarta.ws.rs.client.Client)

Aggregations

Config (com.quorum.tessera.config.Config)5 ClientSSLContextFactory (com.quorum.tessera.ssl.context.ClientSSLContextFactory)5 ServerConfig (com.quorum.tessera.config.ServerConfig)4 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)3 SSLContextFactory (com.quorum.tessera.ssl.context.SSLContextFactory)3 Client (jakarta.ws.rs.client.Client)3 ConfigFactory (com.quorum.tessera.config.ConfigFactory)2 IntervalPropertyHelper (com.quorum.tessera.config.util.IntervalPropertyHelper)2 Test (org.junit.Test)2 P2pClient (com.quorum.tessera.partyinfo.P2pClient)1