Skip to content
Snippets Groups Projects
Unverified Commit 3cb42aa0 authored by Georgi Michev's avatar Georgi Michev
Browse files

add signer verify presentation

parent 767cdfa6
Branches
No related tags found
1 merge request!29Add signer tests for verifying presentation
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/jws-2020/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation",
"proof": {
"created": "2022-07-21T14:28:09.071187173Z",
"jws": "eyJhbGciOiJKc29uV2ViU2lnbmF0dXJlMjAyMCIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..MEQCIFkavr6XpAYbdurBmQXNei-hI8WHAcnEYkZ6J3i4d3FKAiA4BtVCAixsAypaJ5dcBxn96Ju1OGfi7Kw1QRZMlMumhg",
"proofPurpose": "assertionMethod",
"type": "JsonWebSignature2020",
"verificationMethod": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation#key1"
},
"type": "VerifiablePresentation",
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/jws-2020/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"credentialSubject": {
"allow": true,
"id": "example/examplePolicy/1.0"
},
"issuanceDate": "2022-07-21T10:24:36.203848291Z",
"issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation",
"type": "VerifiableCredential"
},
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/jws-2020/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"credentialSubject": {
"allow": true,
"id": "example/ProofRequestResponse/1.0"
},
"issuanceDate": "2023-07-21T10:24:36.203861194Z",
"issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation",
"type": "VerifiableCredential"
}
]
}
\ No newline at end of file
...@@ -1464,4 +1464,8 @@ public class GeneralStepDefinitions extends BaseStepDefinitions { ...@@ -1464,4 +1464,8 @@ public class GeneralStepDefinitions extends BaseStepDefinitions {
assertEquals("Expected values doesn't match actual: ", expectedResultAsList, actualResultAsString); assertEquals("Expected values doesn't match actual: ", expectedResultAsList, actualResultAsString);
} }
@Then("I get the last response body and load it to the current request body")
public void iGetTheLastResponseBodyAndLoadItToTheCurrentRequestBody() {
currentRequest.setBody(getLastResponse().getBody());
}
} }
\ No newline at end of file
...@@ -3,16 +3,25 @@ package api.test.rest.tsa.signer; ...@@ -3,16 +3,25 @@ package api.test.rest.tsa.signer;
import api.test.core.BaseStepDefinitions; import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions; import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer; import api.test.rest.RestSessionContainer;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import core.*; import core.*;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given; import cucumber.api.java.en.Given;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import cucumber.api.java.zh_cn.假如;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.util.HashMap;
import java.util.Map;
public class SignerStepDefinitions extends BaseStepDefinitions { public class SignerStepDefinitions extends BaseStepDefinitions {
private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName()); private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer; RestSessionContainer restSessionContainer;
Request currentRequest; Request currentRequest;
private String body;
public SignerStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) { public SignerStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) {
super(dataContainer); super(dataContainer);
...@@ -59,4 +68,12 @@ public class SignerStepDefinitions extends BaseStepDefinitions { ...@@ -59,4 +68,12 @@ public class SignerStepDefinitions extends BaseStepDefinitions {
addRequest(currentRequest); addRequest(currentRequest);
addResponse(response); addResponse(response);
} }
@When("I verify presentation proof via TSA Signer API")
public void iVerifyPresentationProofViaTSASignerAPI() {
currentRequest.setPath("/v1/presentation/verify");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
} }
#Copyright (c) 2018 Vereign AG [https://www.vereign.com]
#
#This is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as
#published by the Free Software Foundation, either version 3 of the
#License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#https://gaiax.vereign.com/tsa/signer/v1/presentation/verify
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @signer
Feature: API - TSA - Signer presentation verify - v1/presentation/verify POST
As user
I want to verify a presentation
So I know it is valid
Background:
Given we are testing the TSA Signer Api
Scenario: TSA - verify presentation proof - Positive
When I load the request from json {/REST/json/Presentation.json}
When I create presentation proof via TSA Signer API
And the status code should be {200}
And the response is valid according to the {Signer_PresentationProof_schema.json} REST schema
And the field {proof.verificationMethod} has the value {did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation#key1}
Then I get the last response body and load it to the current request body
And I verify presentation proof via TSA Signer API
And the status code should be {200}
And the field {valid} has the value {true}
@negative
Scenario: TSA - verify presentation proof with modified field - Negative
When I load the request from json {/REST/json/Presentation.json}
When I create presentation proof via TSA Signer API
And the status code should be {200}
And the response is valid according to the {Signer_PresentationProof_schema.json} REST schema
And the field {proof.verificationMethod} has the value {did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation#key1}
Then I get the last response body and load it to the current request body
When I load the request from json {/REST/json/PresentationModifiedField.json}
And I verify presentation proof via TSA Signer API
And the status code should be {400}
And the field {message} has the value {check embedded proof: check linked data proof: ecdsa: invalid signature}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment