Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2893] Rename privacyGroupId to createPrivacyGroupId #1654

Merged
merged 3 commits into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public ReceiveResponse receive(final ReceiveRequest content) throws Exception {
}

public PrivacyGroup createPrivacyGroup(final CreatePrivacyGroupRequest content) throws Exception {
return executePost(buildPostRequest(JSON, content, "/privacyGroupId"), PrivacyGroup.class);
return executePost(buildPostRequest(JSON, content, "/createPrivacyGroup"), PrivacyGroup.class);
}

public String deletePrivacyGroup(final DeletePrivacyGroupRequest content) throws Exception {
return executePost(buildPostRequest(JSON, content, "/deletePrivacyGroupId"), String.class);
return executePost(buildPostRequest(JSON, content, "/deletePrivacyGroup"), String.class);
}

private Request buildPostRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public enum JsonRpcError {
ENCLAVE_NOT_PAYLOAD_OWNER(-50200, "EnclaveNotPayloadOwner"),
ENCLAVE_UNSUPPORTED_PRIVATE_KEY_TYPE(-50200, "EnclaveUnsupportedPrivateKeyType"),
ENCLAVE_STORAGE_DECRYPT(-50200, "EnclaveStorageDecrypt"),
ENCLAVE_PRIVACY_GROUP_CREATION(-50200, "EnclavePrivacyGroupIdCreation");
ENCLAVE_PRIVACY_GROUP_CREATION(-50200, "EnclavePrivacyGroupIdCreation"),
CREATE_GROUP_INCLUDE_SELF(-50200, "CreatePrivacyGroupShouldIncludeSelf");

private final int code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.privacy;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import tech.pegasys.pantheon.enclave.Enclave;
import tech.pegasys.pantheon.enclave.types.PrivacyGroup;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.JsonRpcParameter;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.response.JsonRpcSuccessResponse;

import org.junit.Test;

public class EeaCreatePrivacyGroupTest {

private final Enclave enclave = mock(Enclave.class);
private final JsonRpcParameter parameters = new JsonRpcParameter();

private final String from = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=";
private final String name = "testName";
private final String description = "testDesc";
private final String[] addresses =
new String[] {
"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
"Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="
};
private final String privacyGroupId =
"68/Cq0mVjB8FbXDLE1tbDRAvD/srluIok137uFOaClPU/dLFW34ovZebW+PTzy9wUawTXw==";

@Test
public void verifyCreatePrivacyGroup() throws Exception {
PrivacyGroup privacyGroup =
new PrivacyGroup(privacyGroupId, PrivacyGroup.Type.PANTHEON, name, description);
when(enclave.createPrivacyGroup(any())).thenReturn(privacyGroup);

final EeaCreatePrivacyGroup eeaCreatePrivacyGroup =
new EeaCreatePrivacyGroup(enclave, parameters);

Object[] params = new Object[] {from, name, description, addresses};
final JsonRpcRequest request = new JsonRpcRequest("1", "eea_createPrivacyGroup", params);

final JsonRpcSuccessResponse response =
(JsonRpcSuccessResponse) eeaCreatePrivacyGroup.response(request);

final String result = (String) response.getResult();

assertEquals(privacyGroupId, result);
}
}
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencyManagement {

dependency 'net.consensys.cava:cava-toml:0.5.0'

dependency 'net.consensys:orion:1.1.0'
dependency 'net.consensys:orion:1.2.0'

dependency 'org.apache.commons:commons-text:1.6'

Expand Down