Search in sources :

Example 46 with PublicKey

use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.

the class ActiveNodeTest method createWithEverything.

@Test
public void createWithEverything() {
    final NodeUri nodeUri = NodeUri.create(URI);
    final PublicKey publicKey = mock(PublicKey.class);
    final List<String> supportedVersions = List.of("One", "Two");
    final List<PublicKey> keys = List.of(publicKey);
    final ActiveNode activeNode = ActiveNode.Builder.create().withUri(nodeUri).withKeys(keys).withSupportedVersions(supportedVersions).build();
    assertThat(activeNode).isNotNull();
    assertThat(activeNode.getKeys()).containsExactly(publicKey);
    assertThat(activeNode.getSupportedVersions()).containsExactlyInAnyOrderElementsOf(supportedVersions);
    assertThat(activeNode.getUri()).isSameAs(nodeUri);
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) Test(org.junit.Test)

Example 47 with PublicKey

use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.

the class ActiveNodeTest method createOnlyWithKeys.

@Test
public void createOnlyWithKeys() {
    final NodeUri nodeUri = NodeUri.create(URI);
    final PublicKey publicKey = mock(PublicKey.class);
    final List<PublicKey> keys = List.of(publicKey);
    final ActiveNode activeNode = ActiveNode.Builder.create().withUri(nodeUri).withKeys(keys).build();
    assertThat(activeNode).isNotNull();
    assertThat(activeNode.getKeys()).containsExactly(publicKey);
    assertThat(activeNode.getSupportedVersions()).isEmpty();
    assertThat(activeNode.getUri()).isSameAs(nodeUri);
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) Test(org.junit.Test)

Example 48 with PublicKey

use of com.quorum.tessera.encryption.PublicKey in project tessera by ConsenSys.

the class DiscoveryTest method getRemoteNodeInfo.

@Test
public void getRemoteNodeInfo() {
    PublicKey publicKey = mock(PublicKey.class);
    discovery.getRemoteNodeInfo(publicKey);
    verify(discoveryHelper).buildRemoteNodeInfo(publicKey);
    mockedStaticDiscoveryHelper.verify(DiscoveryHelper::create);
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) Test(org.junit.Test)

Example 49 with PublicKey

use of com.quorum.tessera.encryption.PublicKey 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));
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) NodeInfo(com.quorum.tessera.partyinfo.node.NodeInfo) ArrayList(java.util.ArrayList) Recipient(com.quorum.tessera.partyinfo.node.Recipient) ActiveNode(com.quorum.tessera.discovery.ActiveNode) Test(org.junit.Test)

Example 50 with PublicKey

use of com.quorum.tessera.encryption.PublicKey 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));
}
Also used : PublicKey(com.quorum.tessera.encryption.PublicKey) NodeInfo(com.quorum.tessera.partyinfo.node.NodeInfo) ArrayList(java.util.ArrayList) Recipient(com.quorum.tessera.partyinfo.node.Recipient) ActiveNode(com.quorum.tessera.discovery.ActiveNode) Test(org.junit.Test)

Aggregations

PublicKey (com.quorum.tessera.encryption.PublicKey)281 Test (org.junit.Test)213 Response (jakarta.ws.rs.core.Response)59 MessageHash (com.quorum.tessera.data.MessageHash)57 EncodedPayload (com.quorum.tessera.enclave.EncodedPayload)48 Collectors (java.util.stream.Collectors)32 PrivacyGroup (com.quorum.tessera.enclave.PrivacyGroup)28 NodeInfo (com.quorum.tessera.partyinfo.node.NodeInfo)25 java.util (java.util)23 SendResponse (com.quorum.tessera.api.SendResponse)21 Nonce (com.quorum.tessera.encryption.Nonce)20 Recipient (com.quorum.tessera.partyinfo.node.Recipient)20 Operation (io.swagger.v3.oas.annotations.Operation)20 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)20 Stream (java.util.stream.Stream)19 ReceiveResponse (com.quorum.tessera.transaction.ReceiveResponse)18 EncryptedTransaction (com.quorum.tessera.data.EncryptedTransaction)17 PrivacyMode (com.quorum.tessera.enclave.PrivacyMode)17 URI (java.net.URI)17 SendRequest (com.quorum.tessera.api.SendRequest)15