Search in sources :

Example 6 with RestUtils

use of com.quorum.tessera.test.rest.RestUtils in project tessera by ConsenSys.

the class PrivacyIT method updateExistingContractByParticipant.

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

Example 7 with RestUtils

use of com.quorum.tessera.test.rest.RestUtils in project tessera by ConsenSys.

the class PrivacyIT method sendPSVTransactionWithoutExecHashWillBeRejected.

@Test
public void sendPSVTransactionWithoutExecHashWillBeRejected() {
    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.B).getPublicKey());
    sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
    sendRequest.setPrivacyFlag(PrivacyMode.PRIVATE_STATE_VALIDATION.getPrivacyFlag());
    sendRequest.setAffectedContractTransactions(new String[0]);
    Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MIME_TYPE_JSON_2_1));
    assertThat(response.getStatus()).isEqualTo(400);
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) RestUtils(com.quorum.tessera.test.rest.RestUtils) Test(org.junit.Test)

Example 8 with RestUtils

use of com.quorum.tessera.test.rest.RestUtils in project tessera by ConsenSys.

the class PrivacyIT method updateExistingContractByNonParticipant.

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

Example 9 with RestUtils

use of com.quorum.tessera.test.rest.RestUtils in project tessera by ConsenSys.

the class PrivacyIT method sendContractCreationTransaction.

private String sendContractCreationTransaction(PrivacyMode privacyMode) {
    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.B).getPublicKey());
    sendRequest.setTo(recipientList.toArray(new String[recipientList.size()]));
    sendRequest.setPrivacyFlag(privacyMode.getPrivacyFlag());
    sendRequest.setAffectedContractTransactions(new String[0]);
    if (privacyMode == PrivacyMode.PRIVATE_STATE_VALIDATION) {
        sendRequest.setExecHash("execHash");
    }
    Response response = sender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MIME_TYPE_JSON_2_1));
    assertThat(response.getStatus()).isEqualTo(201);
    final SendResponse result = response.readEntity(SendResponse.class);
    return result.getKey();
}
Also used : SendResponse(com.quorum.tessera.api.SendResponse) Response(jakarta.ws.rs.core.Response) Party(com.quorum.tessera.test.Party) SendRequest(com.quorum.tessera.api.SendRequest) SendResponse(com.quorum.tessera.api.SendResponse) RestUtils(com.quorum.tessera.test.rest.RestUtils)

Aggregations

SendRequest (com.quorum.tessera.api.SendRequest)9 SendResponse (com.quorum.tessera.api.SendResponse)9 Party (com.quorum.tessera.test.Party)9 RestUtils (com.quorum.tessera.test.rest.RestUtils)9 Response (jakarta.ws.rs.core.Response)9 Test (org.junit.Test)8