Search in sources :

Example 46 with Party

use of com.quorum.tessera.test.Party in project tessera by ConsenSys.

the class PrivacyGroupTestUtil method create.

public String create(String... aliases) {
    JsonArrayBuilder members = Json.createArrayBuilder();
    Stream.of(aliases).map(partyHelper::findByAlias).map(Party::getPublicKey).forEach(members::add);
    Party sender = partyHelper.findByAlias(aliases[0]);
    JsonObject json = Json.createObjectBuilder().add("addresses", members).add("from", sender.getPublicKey()).add("name", "Organisation " + Arrays.toString(aliases)).add("description", "Contains members of Organisation " + Arrays.toString(aliases)).build();
    final Response response = sender.getRestClient().target(sender.getQ2TUri()).path("/createPrivacyGroup").request().post(Entity.entity(json, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(200);
    return response.readEntity(String.class);
}
Also used : Response(jakarta.ws.rs.core.Response) Party(com.quorum.tessera.test.Party) JsonObject(jakarta.json.JsonObject) JsonArrayBuilder(jakarta.json.JsonArrayBuilder)

Example 47 with Party

use of com.quorum.tessera.test.Party 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, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(201);
}
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 48 with Party

use of com.quorum.tessera.test.Party in project tessera by ConsenSys.

the class PrivacyIT method enhancedPrivacyTransactionsNotEnabled.

@Test
public void enhancedPrivacyTransactionsNotEnabled() {
    Party legacySender = partyHelper.findByAlias(NodeAlias.D);
    SendRequest sendRequest = new SendRequest();
    sendRequest.setPayload(new RestUtils().createTransactionData());
    sendRequest.setFrom(legacySender.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(new String[0]);
    Response response = legacySender.getRestClientWebTarget().path("send").request().post(Entity.entity(sendRequest, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(403);
}
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 49 with Party

use of com.quorum.tessera.test.Party 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, MediaType.APPLICATION_JSON));
    assertThat(response.getStatus()).isEqualTo(403);
}
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 50 with Party

use of com.quorum.tessera.test.Party in project tessera by ConsenSys.

the class PrivacyIT method targetedNodeDoesNotHaveEnhancedPrivacyEnabled.

@Test
public void targetedNodeDoesNotHaveEnhancedPrivacyEnabled() {
    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.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)

Aggregations

Party (com.quorum.tessera.test.Party)63 Response (jakarta.ws.rs.core.Response)60 Test (org.junit.Test)46 SendResponse (com.quorum.tessera.api.SendResponse)45 SendRequest (com.quorum.tessera.api.SendRequest)43 ReceiveResponse (com.quorum.tessera.api.ReceiveResponse)32 URI (java.net.URI)16 RestUtils (com.quorum.tessera.test.rest.RestUtils)11 JsonObject (jakarta.json.JsonObject)7 PartyHelper (com.quorum.tessera.test.PartyHelper)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 PayloadEncryptResponse (com.quorum.tessera.api.PayloadEncryptResponse)4 Entity (jakarta.ws.rs.client.Entity)4 StringReader (java.io.StringReader)4 ExecutionContext (suite.ExecutionContext)4 ServerConfig (com.quorum.tessera.config.ServerConfig)3 ConfigDescriptor (config.ConfigDescriptor)3 Json (jakarta.json.Json)3 Client (jakarta.ws.rs.client.Client)3 Before (org.junit.Before)3