use of com.quorum.tessera.jaxrs.client.ClientFactory 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);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory 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);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory 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);
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class MetricsIT method metrics.
@Test
public void metrics() {
final PartyHelper partyHelper = PartyHelper.create();
Set<ServerConfig> serverConfigs = partyHelper.getParties().map(Party::getConfig).map(Config::getServerConfigs).flatMap(List::stream).collect(Collectors.toUnmodifiableSet());
ClientFactory clientFactory = new ClientFactory();
for (ServerConfig serverConfig : serverConfigs) {
Client c = clientFactory.buildFrom(serverConfig);
Response response = c.target(serverConfig.getServerUri()).path("metrics").request().get();
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(200);
}
}
use of com.quorum.tessera.jaxrs.client.ClientFactory in project tessera by ConsenSys.
the class PeerToPeerIT method benevolentNodeBecomesPossessedAndTriesToSendInvalidUrlAndKeyCombo.
@Test
public void benevolentNodeBecomesPossessedAndTriesToSendInvalidUrlAndKeyCombo() throws Exception {
Party partyB = partyHelper.findByAlias(NodeAlias.B);
ServerConfig serverConfig = partyB.getConfig().getP2PServerConfig();
PublicKey publicKey = Optional.of(partyB).map(Party::getPublicKey).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
Recipient itself = Recipient.of(publicKey, serverConfig.getServerUri().toString());
String validKeyFromOtherNode = partyHelper.findByAlias(NodeAlias.C).getPublicKey();
PublicKey validButIncorrectKey = Optional.of(validKeyFromOtherNode).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
String workingUrlFromSomeOtherNode = partyHelper.findByAlias(NodeAlias.D).getConfig().getP2PServerConfig().getServerAddress();
Recipient badRecipient = Recipient.of(validButIncorrectKey, workingUrlFromSomeOtherNode);
Set<Recipient> recipients = Stream.of(itself, badRecipient).collect(Collectors.toSet());
assertThat(recipients).containsExactlyInAnyOrder(itself, badRecipient);
PartyInfo partyInfo = new PartyInfo(serverConfig.getServerUri().toString(), recipients, Collections.emptySet());
Client client = new ClientFactory().buildFrom(serverConfig);
PartyInfoParser partyInfoParser = PartyInfoParser.create();
byte[] data = partyInfoParser.to(partyInfo);
StreamingOutput output = out -> out.write(data);
Response response = client.target(partyA.getP2PUri()).path("partyinfo").request().post(Entity.entity(output, MediaType.APPLICATION_OCTET_STREAM));
assertThat(response.getStatus()).isEqualTo(200);
}
Aggregations