Search in sources :

Example 1 with Request

use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.

the class FcBlsVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.

@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
    startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.BLS_VALUE, expectedSignature.getSignatureData().toBytesCompressed().toBase64String());
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(network), dataString, filecoinSignature), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
Also used : Response(io.restassured.response.Response) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilecoinSignature(tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature) Test(org.junit.jupiter.api.Test)

Example 2 with Request

use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.

the class FcSecpSigningAcceptanceTest method receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint.

@Test
void receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint() throws URISyntaxException {
    final String keyPath = new File(Resources.getResource("secp256k1/wallet.json").toURI()).getAbsolutePath();
    final Path keyConfigFile = testDirectory.resolve("arbitrary_secp.yaml");
    metadataFileHelpers.createKeyStoreYamlFileAt(keyConfigFile, Path.of(keyPath), "pass", KeyType.SECP256K1);
    setupFilecoinSigner();
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final Map<String, String> metaData = Map.of("type", "unknown");
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.MAINNET), dataString, metaData), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletSign", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    final Map<String, Object> result = response.body().jsonPath().get("result");
    assertThat(result.get("Type")).isEqualTo(1);
    assertThat(result.get("Data")).isEqualTo(expectedBase64Signature);
}
Also used : Path(java.nio.file.Path) Response(io.restassured.response.Response) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 3 with Request

use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.

the class FcBlsSigningAcceptanceTest method receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint.

@Test
void receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint() {
    final String configFilename = publicKey.toString().substring(2);
    final Path keyConfigFile = testDirectory.resolve(configFilename + ".yaml");
    metadataFileHelpers.createUnencryptedYamlFileAt(keyConfigFile, PRIVATE_KEY, KeyType.BLS);
    setupFilecoinSigner();
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final Map<String, String> metaData = Map.of("type", "message", "extra", DATA.toBase64String());
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.MAINNET), CID.toBase64String(), metaData), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletSign", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    final BlsArtifactSignature expectedSignature = signatureGenerator.sign(CID);
    final Map<String, Object> result = response.body().jsonPath().get("result");
    assertThat(result.get("Type")).isEqualTo(2);
    assertThat(result.get("Data")).isEqualTo(expectedSignature.getSignatureData().toBytesCompressed().toBase64String());
}
Also used : Path(java.nio.file.Path) Response(io.restassured.response.Response) BlsArtifactSignature(tech.pegasys.web3signer.signing.BlsArtifactSignature) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 4 with Request

use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.

the class FcSecpVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.

@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
    startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
    final ValueNode id = JsonNodeFactory.instance.numberNode(1);
    final ObjectMapper mapper = JsonMapper.builder().build();
    final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.SECP_VALUE, expectedBase64Signature);
    final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.TESTNET), dataString, filecoinSignature), JsonNode.class);
    final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
    final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
    response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
    assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
Also used : Response(io.restassured.response.Response) SignerConfigurationBuilder(tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) Request(com.github.arteam.simplejsonrpc.core.domain.Request) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilecoinSignature(tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature) Test(org.junit.jupiter.api.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ValueNode (com.fasterxml.jackson.databind.node.ValueNode)4 Request (com.github.arteam.simplejsonrpc.core.domain.Request)4 Response (io.restassured.response.Response)4 Test (org.junit.jupiter.api.Test)4 Path (java.nio.file.Path)2 FilecoinSignature (tech.pegasys.web3signer.core.service.jsonrpc.FilecoinSignature)2 SignerConfigurationBuilder (tech.pegasys.web3signer.dsl.signer.SignerConfigurationBuilder)2 File (java.io.File)1 BlsArtifactSignature (tech.pegasys.web3signer.signing.BlsArtifactSignature)1