Search in sources :

Example 6 with ReceiveResponse

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

the class ReceiveIT method fetchExistingTransactionUsingOwnKey.

@Test
public void fetchExistingTransactionUsingOwnKey() {
    final Response response = partyOne.getRestClient().target(partyOne.getQ2TUri()).path(RECEIVE_PATH + "/" + this.encodedHash).request().buildGet().property("to", this.encodedSender).invoke();
    // validate result
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(200);
    final ReceiveResponse result = response.readEntity(ReceiveResponse.class);
    assertThat(result.getPayload()).isEqualTo(transactionData);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Test(org.junit.Test)

Example 7 with ReceiveResponse

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

the class ReceiveIT method fetchExistingTransactionNotUsingKey.

@Test
public void fetchExistingTransactionNotUsingKey() throws UnsupportedEncodingException {
    final Response response = partyOne.getRestClient().target(partyOne.getQ2TUri()).path(RECEIVE_PATH).path(encodedHash).request().buildGet().invoke();
    // validate result
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(200);
    final ReceiveResponse result = response.readEntity(ReceiveResponse.class);
    assertThat(result.getPayload()).isEqualTo(transactionData);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Test(org.junit.Test)

Example 8 with ReceiveResponse

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

the class ReceiveIT method fetchExistingTransactionUsingRecipientKey.

@Test
public void fetchExistingTransactionUsingRecipientKey() throws Exception {
    final Response response = partyOne.getRestClient().target(partyOne.getQ2TUri()).path(RECEIVE_PATH).path(encodedHash).request().property("to", this.encodedRecipientOne).get();
    assertThat(response).isNotNull();
    assertThat(response.getStatus()).isEqualTo(200);
    final ReceiveResponse result = response.readEntity(ReceiveResponse.class);
    assertThat(result.getPayload()).isEqualTo(transactionData);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) ReceiveResponse(com.quorum.tessera.api.ReceiveResponse) Test(org.junit.Test)

Example 9 with ReceiveResponse

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

the class SendIT method sendToSingleRecipient.

/**
 * Quorum sends transaction with single public recipient key
 */
@Test
public void sendToSingleRecipient() {
    Party firstParty = partyHelper.findByAlias("A");
    Party secondParty = partyHelper.findByAlias("B");
    byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(firstParty.getPublicKey());
    sendRequest.setTo(secondParty.getPublicKey());
    sendRequest.setPayload(transactionData);
    final Response response = firstParty.getRestClient().target(firstParty.getQ2TUri()).path(SEND_PATH).request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    // validate result
    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()).describedAs("The response payload should be equal to the sent txn data").isEqualTo(transactionData);
    utils.findTransaction(result.getKey(), partyHelper.findByAlias("A"), partyHelper.findByAlias("B")).forEach(r -> {
        assertThat(r.getStatus()).isEqualTo(200);
    });
    utils.findTransaction(result.getKey(), partyHelper.findByAlias("D")).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 10 with ReceiveResponse

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

the class SendIT method sendTransactionWithMissingRecipients.

@Test
public void sendTransactionWithMissingRecipients() {
    final Party sendingParty = partyHelper.getParties().findAny().get();
    final byte[] transactionData = utils.createTransactionData();
    final SendRequest sendRequest = new SendRequest();
    sendRequest.setFrom(sendingParty.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 = sendingParty.getRestClient().target(location).request().get();
    assertThat(checkPersistedTxnResponse.getStatus()).isEqualTo(200);
    ReceiveResponse receiveResponse = checkPersistedTxnResponse.readEntity(ReceiveResponse.class);
    assertThat(receiveResponse.getPayload()).isEqualTo(transactionData);
    if (sendingParty.getConfig().getServerConfigs().stream().allMatch(not(ServerConfig::isUnixSocket))) {
        assertThat(location.getHost()).isEqualTo(sendingParty.getQ2TUri().getHost());
        assertThat(location.getPort()).isEqualTo(sendingParty.getQ2TUri().getPort());
    }
}
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

ReceiveResponse (com.quorum.tessera.api.ReceiveResponse)30 Response (jakarta.ws.rs.core.Response)29 Test (org.junit.Test)26 SendResponse (com.quorum.tessera.api.SendResponse)21 Party (com.quorum.tessera.test.Party)19 SendRequest (com.quorum.tessera.api.SendRequest)16 URI (java.net.URI)15 MIME_TYPE_JSON_2_1 (com.quorum.tessera.version.MultiTenancyVersion.MIME_TYPE_JSON_2_1)4 Stream (java.util.stream.Stream)4 PayloadEncryptResponse (com.quorum.tessera.api.PayloadEncryptResponse)3 MessageHash (com.quorum.tessera.data.MessageHash)3 PublicKey (com.quorum.tessera.encryption.PublicKey)3 PartyHelper (com.quorum.tessera.test.PartyHelper)3 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)3 Json (jakarta.json.Json)3 Entity (jakarta.ws.rs.client.Entity)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 PayloadDecryptRequest (com.quorum.tessera.api.PayloadDecryptRequest)2 EncodedPayload (com.quorum.tessera.enclave.EncodedPayload)2