Search in sources :

Example 56 with SendRequest

use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.

the class PrivacyIT method oneOfTargetedRecipientsDoesNotHaveEnhancedPrivacyEnabled.

@Test
public void oneOfTargetedRecipientsDoesNotHaveEnhancedPrivacyEnabled() {
    Party sender = partyHelper.findByAlias(NodeAlias.A);
    SendRequest sendRequest = new SendRequest();
    sendRequest.setPayload(new RestUtils().createTransactionData());
    sendRequest.setFrom(sender.getPublicKey());
    List<String> recipientList = List.of(partyHelper.findByAlias(NodeAlias.C).getPublicKey(), partyHelper.findByAlias(NodeAlias.D).getPublicKey());
    sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
    sendRequest.setPrivacyFlag(PrivacyMode.PARTY_PROTECTION.getPrivacyFlag());
    sendRequest.setAffectedContractTransactions(new String[0]);
    Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(500);
}
Also used : Response(jakarta.ws.rs.core.Response) SendResponse(com.quorum.tessera.api.SendResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest)

Example 57 with SendRequest

use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.

the class ReceiveRawIT method beforeTest.

// Persist a single transaction that can be used later
@Before
public void beforeTest() {
    this.partyOne = partyHelper.findByAlias(NodeAlias.A);
    this.partyTwo = partyHelper.findByAlias(NodeAlias.B);
    SendRequest sendRequest = new SendRequest();
    sendRequest.setPayload(PAYLOAD);
    sendRequest.setTo(partyTwo.getPublicKey());
    sendRequest.setFrom(partyOne.getPublicKey());
    final Response response = partyOne.getRestClient().target(partyOne.getQ2TUri()).path("/send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    final SendResponse result = response.readEntity(SendResponse.class);
    this.hash = result.getKey();
}
Also used : Response(jakarta.ws.rs.core.Response) SendResponse(com.quorum.tessera.api.SendResponse) SendRequest(com.quorum.tessera.api.SendRequest) SendResponse(com.quorum.tessera.api.SendResponse) Before(org.junit.Before)

Example 58 with SendRequest

use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.

the class SendIT method partyAlwaysSendsToPartyOne.

/**
 * config3.json has party 1's key in always send to list
 */
@Test
public void partyAlwaysSendsToPartyOne() {
    Party sender = partyHelper.findByAlias("C");
    Party recipient = partyHelper.findByAlias("D");
    byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(sender.getPublicKey());
    sendRequest.setTo(recipient.getPublicKey());
    sendRequest.setPayload(transactionData);
    final Response response = sender.getRestClient().target(sender.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    final SendResponse result = response.readEntity(SendResponse.class);
    assertThat(result.getKey()).isNotNull().isNotBlank();
    // Party one recieved by always send to
    utils.findTransaction(result.getKey(), sender, recipient, partyHelper.findByAlias("A")).forEach(r -> {
        assertThat(r.getStatus()).isEqualTo(200);
    });
    // Party 2 is out of the loop
    utils.findTransaction(result.getKey(), partyHelper.findByAlias("B")).forEach(r -> {
        assertThat(r.getStatus()).isEqualTo(404);
    });
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) SendResponse(com.quorum.tessera.api.SendResponse) Test(org.junit.Test)

Example 59 with SendRequest

use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.

the class SendIT method firstPartyForwardsToTwoOtherParties.

/**
 * Quorum sends transaction with multiple public recipient keys
 */
@Test
public void firstPartyForwardsToTwoOtherParties() {
    final Party sendingParty = partyHelper.findByAlias("A");
    final Party secondParty = partyHelper.findByAlias("B");
    final Party thirdParty = partyHelper.findByAlias("D");
    final Party excludedParty = partyHelper.findByAlias("C");
    final byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(sendingParty.getPublicKey());
    sendRequest.setTo(secondParty.getPublicKey(), thirdParty.getPublicKey());
    sendRequest.setPayload(transactionData);
    final Response response = sendingParty.getRestClient().target(sendingParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    // 
    final SendResponse result = response.readEntity(SendResponse.class);
    assertThat(result.getKey()).isNotNull().isNotBlank();
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(201);
    URI location = response.getLocation();
    final Response checkPersistedTxnResponse = secondParty.getRestClient().target(location).request().get();
    assertThat(checkPersistedTxnResponse.getStatus()).isEqualTo(200);
    ReceiveResponse receiveResponse = checkPersistedTxnResponse.readEntity(ReceiveResponse.class);
    assertThat(receiveResponse.getPayload()).isEqualTo(transactionData);
    utils.findTransaction(result.getKey(), sendingParty, secondParty, thirdParty).forEach(r -> {
        assertThat(r.getStatus()).isEqualTo(200);
    });
    utils.findTransaction(result.getKey(), excludedParty).forEach(r -> {
        assertThat(r.getStatus()).isEqualTo(404);
    });
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) SendResponse(com.quorum.tessera.api.SendResponse) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) URI(java.net.URI) Test(org.junit.Test)

Example 60 with SendRequest

use of com.quorum.tessera.api.SendRequest in project tessera by ConsenSys.

the class SendIT method sendTransactionWithoutASender.

@Test
public void sendTransactionWithoutASender() {
    Party recipient = partyHelper.getParties().findAny().get();
    byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setTo(recipient.getPublicKey());
    sendRequest.setPayload(transactionData);
    final Response response = recipient.getRestClient().target(recipient.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    final SendResponse result = response.readEntity(SendResponse.class);
    assertThat(result.getKey()).isNotNull().isNotBlank();
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(201);
    URI location = response.getLocation();
    final Response checkPersistedTxnResponse = recipient.getRestClient().target(location).request().get();
    assertThat(checkPersistedTxnResponse.getStatus()).isEqualTo(200);
    ReceiveResponse receiveResponse = checkPersistedTxnResponse.readEntity(ReceiveResponse.class);
    assertThat(receiveResponse.getPayload()).isEqualTo(transactionData);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) SendResponse(com.quorum.tessera.api.SendResponse) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

SendRequest (com.quorum.tessera.api.SendRequest)64 Response (jakarta.ws.rs.core.Response)60 SendResponse (com.quorum.tessera.api.SendResponse)50 Party (com.quorum.tessera.test.Party)43 Test (org.junit.Test)43 ReceiveResponse (com.quorum.tessera.api.ReceiveResponse)27 MessageHash (com.quorum.tessera.data.MessageHash)13 PublicKey (com.quorum.tessera.encryption.PublicKey)13 URI (java.net.URI)13 RestUtils (com.quorum.tessera.test.rest.RestUtils)11 PayloadEncryptResponse (com.quorum.tessera.api.PayloadEncryptResponse)8 ReceiveResponse (com.quorum.tessera.transaction.ReceiveResponse)8 Stream (java.util.stream.Stream)6 PrivacyGroup (com.quorum.tessera.enclave.PrivacyGroup)5 PrivacyMode (com.quorum.tessera.enclave.PrivacyMode)5 MIME_TYPE_JSON_2_1 (com.quorum.tessera.version.MultiTenancyVersion.MIME_TYPE_JSON_2_1)5 TransactionManager (com.quorum.tessera.transaction.TransactionManager)4 Operation (io.swagger.v3.oas.annotations.Operation)4 PartyHelper (com.quorum.tessera.test.PartyHelper)3 Content (io.swagger.v3.oas.annotations.media.Content)3