use of com.quorum.tessera.config.Config 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.config.Config in project tessera by ConsenSys.
the class PeerToPeerIT method validatePartyInfoContentsOnNodeA.
/*
Assume that not of the tests should have managed to change the initial party info
*/
private void validatePartyInfoContentsOnNodeA() {
Party someParty = partyHelper.getParties().filter(p -> !p.getAlias().equals("A")).findAny().get();
ServerConfig serverContext = someParty.getConfig().getP2PServerConfig();
Client client = clientFactory.buildFrom(serverContext);
Response response = client.target(partyA.getP2PUri()).path("partyinfo").request().get();
assertThat(response.getStatus()).isEqualTo(200);
JsonObject result = response.readEntity(JsonObject.class);
Map<String, String> actual = result.getJsonArray("keys").stream().map(o -> o.asJsonObject()).collect(Collectors.toMap(o -> o.getString("key"), o -> removeTrailingSlash(o.getString("url"))));
EncryptorConfig encryptorConfig = partyHelper.getParties().findFirst().map(Party::getConfig).map(Config::getEncryptor).get();
KeyEncryptor keyEncryptor = KeyEncryptorFactory.newFactory().create(encryptorConfig);
List<String> keyz = partyHelper.getParties().map(Party::getConfig).map(Config::getKeys).flatMap(k -> k.getKeyData().stream()).map(kd -> KeyDataUtil.unmarshal(kd, keyEncryptor)).map(ConfigKeyPair::getPublicKey).collect(Collectors.toList());
List<String> urls = partyHelper.getParties().map(Party::getConfig).map(Config::getP2PServerConfig).map(ServerConfig::getServerAddress).map(s -> removeTrailingSlash(s)).collect(Collectors.toList());
assertThat(actual).containsKeys(keyz.toArray(new String[0]));
assertThat(actual).containsValues(urls.toArray(new String[0]));
}
use of com.quorum.tessera.config.Config in project tessera by ConsenSys.
the class PeerToPeerIT method happyCase.
/*
* Send a valid party info from B to A
*/
@Test
public void happyCase() {
Party partyB = partyHelper.findByAlias(NodeAlias.B);
ServerConfig serverContext = Optional.of(partyB.getConfig()).map(Config::getP2PServerConfig).get();
Client client = clientFactory.buildFrom(serverContext);
PublicKey partyBKey = Optional.of(partyB).map(Party::getPublicKey).map(Base64.getDecoder()::decode).map(PublicKey::from).get();
String partyBServerAddress = partyB.getConfig().getP2PServerConfig().getServerAddress();
Recipient recipient = Recipient.of(partyBKey, partyBServerAddress);
PartyInfo partyInfo = new PartyInfo(partyBServerAddress, Collections.singleton(recipient), Collections.emptySet());
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