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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations