use of com.quorum.tessera.partyinfo.node.NodeInfo 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);
}
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class AutoDiscoveryTest method onUpdateSendHasTwoKeys.
@Test
public void onUpdateSendHasTwoKeys() {
String uri = "http://mynode.com";
PublicKey key = mock(PublicKey.class);
Recipient recipient = Recipient.of(key, uri);
PublicKey otherKey = mock(PublicKey.class);
Recipient other = Recipient.of(otherKey, uri);
List<Recipient> recipients = List.of(recipient, other);
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(uri).withRecipients(recipients).build();
List<ActiveNode> storedNodes = new ArrayList<>();
doAnswer(invocation -> {
storedNodes.add(invocation.getArgument(0));
return null;
}).when(networkStore).store(any(ActiveNode.class));
discovery.onUpdate(nodeInfo);
assertThat(storedNodes).hasSize(1);
ActiveNode result = storedNodes.iterator().next();
assertThat(result.getUri()).isEqualTo(NodeUri.create(uri));
assertThat(result.getKeys()).containsExactlyInAnyOrder(key, otherKey);
verify(networkStore).store(any(ActiveNode.class));
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class DisabledAutoDiscoveryTest method onUpdateIgnoreKeysNotOwnedBySender.
@Test
public void onUpdateIgnoreKeysNotOwnedBySender() {
String uri = "http://renoraynes.com";
PublicKey key = mock(PublicKey.class);
PublicKey key2 = mock(PublicKey.class);
Recipient recipient = Recipient.of(key, uri);
Recipient other = Recipient.of(key2, "http://othernode.com");
List<Recipient> recipients = List.of(recipient, other);
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(uri).withRecipients(recipients).withSupportedApiVersions(List.of("Two", "Fifty")).build();
List<ActiveNode> storedNodes = new ArrayList<>();
doAnswer(invocation -> {
storedNodes.add(invocation.getArgument(0));
return null;
}).when(networkStore).store(any(ActiveNode.class));
discovery.onUpdate(nodeInfo);
assertThat(storedNodes).hasSize(1);
ActiveNode result = storedNodes.iterator().next();
assertThat(result.getUri()).isEqualTo(NodeUri.create(uri));
assertThat(result.getKeys()).containsExactly(key);
assertThat(result.getSupportedVersions()).containsExactlyInAnyOrder("Two", "Fifty");
verify(networkStore).store(any(ActiveNode.class));
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class DisabledAutoDiscoveryTest method onUpdateNodeSendsNewKey.
@Test
public void onUpdateNodeSendsNewKey() {
String url = knownPeers.iterator().next().asString();
PublicKey key = mock(PublicKey.class);
List<Recipient> recipients = List.of(Recipient.of(key, url));
List<ActiveNode> storedNodes = new ArrayList<>();
doAnswer(invocation -> {
storedNodes.add(invocation.getArgument(0));
return null;
}).when(networkStore).store(any(ActiveNode.class));
NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl(url).withRecipients(recipients).build();
discovery.onUpdate(nodeInfo);
assertThat(storedNodes).hasSize(1);
ActiveNode savedNode = storedNodes.get(0);
assertThat(savedNode.getKeys()).containsExactly(key);
assertThat(savedNode.getUri()).isEqualTo(NodeUri.create(url));
verify(networkStore).store(any(ActiveNode.class));
}
use of com.quorum.tessera.partyinfo.node.NodeInfo in project tessera by ConsenSys.
the class DiscoveryHelperTest method getCurrentWithUriOnly.
@Test
public void getCurrentWithUriOnly() {
final URI uri = URI.create("http://somedomain.com");
when(runtimeContext.getP2pServerUri()).thenReturn(uri);
NodeInfo result = discoveryHelper.buildCurrent();
assertThat(result).isNotNull();
verify(runtimeContext).getP2pServerUri();
assertThat(result.getUrl()).isEqualTo("http://somedomain.com/");
assertThat(result.getRecipients()).isEmpty();
verify(networkStore).getActiveNodes();
mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
Aggregations