use of com.quorum.tessera.privacygroup.exception.PrivacyGroupNotSupportedException in project tessera by ConsenSys.
the class PrivacyGroupNotSupportedExceptionMapperTest method handleException.
@Test
public void handleException() {
final String message = ".. all outta gum";
final PrivacyGroupNotSupportedException exception = new PrivacyGroupNotSupportedException(message);
final Response result = mapper.toResponse(exception);
assertThat(result.getStatus()).isEqualTo(403);
assertThat(result.getEntity()).isEqualTo(message);
}
use of com.quorum.tessera.privacygroup.exception.PrivacyGroupNotSupportedException in project tessera by ConsenSys.
the class RestPrivacyGroupPublisher method publishPrivacyGroup.
@Override
public void publishPrivacyGroup(byte[] data, PublicKey recipientKey) {
final NodeInfo remoteNodeInfo = discovery.getRemoteNodeInfo(recipientKey);
if (!remoteNodeInfo.supportedApiVersions().contains(PrivacyGroupVersion.API_VERSION_3)) {
throw new PrivacyGroupNotSupportedException("Transactions with privacy group is not currently supported on recipient " + recipientKey.encodeToBase64());
}
final String targetUrl = remoteNodeInfo.getUrl();
LOGGER.info("Publishing privacy group to {}", targetUrl);
try (Response response = restClient.target(targetUrl).path("/pushPrivacyGroup").request().post(Entity.entity(data, MediaType.APPLICATION_OCTET_STREAM_TYPE))) {
if (Response.Status.OK.getStatusCode() != response.getStatus()) {
throw new PrivacyGroupPublishException("Unable to push privacy group to recipient url " + targetUrl);
}
LOGGER.info("Published privacy group to {}", targetUrl);
} catch (ProcessingException ex) {
LOGGER.debug("", ex);
throw new NodeOfflineException(URI.create(targetUrl));
}
}
use of com.quorum.tessera.privacygroup.exception.PrivacyGroupNotSupportedException in project tessera by ConsenSys.
the class RestPrivacyGroupPublisherTest method remoteNodeDoesNotSupportPrivacyGroup.
@Test
public void remoteNodeDoesNotSupportPrivacyGroup() {
String targetUrl = "url2.com";
final List<String> versions = List.of(MultiTenancyVersion.API_VERSION_2_1);
final NodeInfo oldNode = NodeInfo.Builder.create().withUrl(targetUrl).withRecipients(Collections.emptyList()).withSupportedApiVersions(versions).build();
PublicKey recipient = PublicKey.from("OLD_KEY".getBytes());
when(discovery.getRemoteNodeInfo(recipient)).thenReturn(oldNode);
final byte[] data = new byte[] { 15 };
try {
publisher.publishPrivacyGroup(data, recipient);
} catch (PrivacyGroupNotSupportedException privacyGroupNotSupportedException) {
assertThat(privacyGroupNotSupportedException).isNotNull().hasMessageContaining(recipient.encodeToBase64());
verify(discovery).getRemoteNodeInfo(recipient);
}
}
Aggregations