Search in sources :

Example 16 with ServerConfig

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

the class PayloadPublisherProviderTest method provider.

@Test
public void provider() {
    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);
    try (var configFactoryMockedStatic = mockStatic(ConfigFactory.class);
        var discoveryMockedStatic = mockStatic(Discovery.class)) {
        configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
        discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
        PayloadPublisher payloadPublisher = PayloadPublisherProvider.provider();
        assertThat(payloadPublisher).isNotNull();
        configFactoryMockedStatic.verify(ConfigFactory::create);
        configFactoryMockedStatic.verifyNoMoreInteractions();
        discoveryMockedStatic.verify(Discovery::create);
        discoveryMockedStatic.verifyNoMoreInteractions();
    }
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) PayloadPublisher(com.quorum.tessera.transaction.publish.PayloadPublisher) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) Discovery(com.quorum.tessera.discovery.Discovery) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 17 with ServerConfig

use of com.quorum.tessera.config.ServerConfig 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 18 with ServerConfig

use of com.quorum.tessera.config.ServerConfig 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 19 with ServerConfig

use of com.quorum.tessera.config.ServerConfig 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)

Example 20 with ServerConfig

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

the class ServerConfigsValidatorTest method onSetUp.

@Before
public void onSetUp() {
    cvc = mock(ConstraintValidatorContext.class);
    for (AppType appType : AppType.values()) {
        ServerConfig serverConfig = new ServerConfig();
        serverConfig.setApp(appType);
        serverConfig.setServerAddress("localhost:123");
        serverConfig.setCommunicationType(CommunicationType.REST);
        serverConfig.setSslConfig(null);
        serverConfig.setInfluxConfig(null);
        serverConfig.setBindingAddress(null);
        serverConfigsMap.put(appType, serverConfig);
    }
    validator = new ServerConfigsValidator();
    when(cvc.buildConstraintViolationWithTemplate(anyString())).thenReturn(mock(ConstraintValidatorContext.ConstraintViolationBuilder.class));
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) ConstraintValidatorContext(jakarta.validation.ConstraintValidatorContext) AppType(com.quorum.tessera.config.AppType) 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