From 1f79d7975c90d3a54c0351cdf23192cf861dac67 Mon Sep 17 00:00:00 2001 From: "georgi.michev" <georgi.michev@vereign.com> Date: Mon, 4 Jul 2022 15:13:01 +0300 Subject: [PATCH] add signer presentation proof tests Signed-off-by: georgi.michev <georgi.michev@vereign.com> --- .../resources/REST/json/Presentation.json | 25 ++++ .../Signer_PresentationProof_schema.json | 115 ++++++++++++++++++ .../tsa/signer/SignerStepDefinitions.java | 10 +- .../tsa/signer/v1/issuerDID/GET.feature | 6 +- .../features/tsa/signer/v1/keys/GET.feature | 2 +- .../signer/v1/presentation/proof/POST.feature | 40 ++++++ 6 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/REST/json/Presentation.json create mode 100644 src/main/resources/REST/schemas/Signer_PresentationProof_schema.json create mode 100644 src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature diff --git a/src/main/resources/REST/json/Presentation.json b/src/main/resources/REST/json/Presentation.json new file mode 100644 index 00000000..d4678bd4 --- /dev/null +++ b/src/main/resources/REST/json/Presentation.json @@ -0,0 +1,25 @@ +{ + "@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", + "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-01T11:07:57.975459274Z", + "issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation", + "type": "VerifiableCredential" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json b/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json new file mode 100644 index 00000000..427c92b1 --- /dev/null +++ b/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json @@ -0,0 +1,115 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "@context": { + "type": "array", + "items": [ + { + "type": "string" + }, + { + "type": "string" + }, + { + "type": "string" + } + ] + }, + "id": { + "type": "string" + }, + "proof": { + "type": "object", + "properties": { + "created": { + "type": "string" + }, + "jws": { + "type": "string" + }, + "proofPurpose": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verificationMethod": { + "type": "string" + } + }, + "required": [ + "created", + "jws", + "proofPurpose", + "type", + "verificationMethod" + ] + }, + "type": { + "type": "string" + }, + "verifiableCredential": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "@context": { + "type": "array", + "items": [ + { + "type": "string" + }, + { + "type": "string" + }, + { + "type": "string" + } + ] + }, + "credentialSubject": { + "type": "object", + "properties": { + "allow": { + "type": "boolean" + }, + "id": { + "type": "string" + } + }, + "required": [ + "allow", + "id" + ] + }, + "issuanceDate": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "@context", + "credentialSubject", + "issuanceDate", + "issuer", + "type" + ] + } + ] + } + }, + "required": [ + "@context", + "id", + "proof", + "type", + "verifiableCredential" + ] +} \ No newline at end of file diff --git a/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java b/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java index da72e92f..c3b24639 100644 --- a/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java @@ -47,10 +47,18 @@ public class SignerStepDefinitions extends BaseStepDefinitions { } @When("I get issuer DID via TSA Signer API") - public void iGetSignerDIDViaTSASignerAPI() { + public void iGetIssuerDIDViaTSASignerAPI() { currentRequest.setPath("/v1/issuerDID"); Response response = RestClient.get(currentRequest); addRequest(currentRequest); addResponse(response); } + + @When("I validate presentation proof via TSA Signer API") + public void iValidatePresentationProofViaTSASignerAPI() { + currentRequest.setPath("/v1/presentation/proof"); + Response response = RestClient.post(currentRequest); + addRequest(currentRequest); + addResponse(response); + } } diff --git a/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature b/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature index 831a682b..5e35cf3e 100644 --- a/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature +++ b/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature @@ -17,10 +17,10 @@ #Author: Georgi Michev georgi.michev@vereign.com @rest @all @tsa @signer -Feature: API -TSA - Signer Issuer DID - v1/keys POST +Feature: API - TSA - Signer Issuer DID - v1/keys GET As user - I want to see what keys are available - So I am able to use them the future + I want to see who is the issuer of the keys + So I am better informed Background: Given we are testing the TSA Signer Api diff --git a/src/test/resources/features/tsa/signer/v1/keys/GET.feature b/src/test/resources/features/tsa/signer/v1/keys/GET.feature index 58d5a1a1..2ff98c1a 100644 --- a/src/test/resources/features/tsa/signer/v1/keys/GET.feature +++ b/src/test/resources/features/tsa/signer/v1/keys/GET.feature @@ -17,7 +17,7 @@ #Author: Georgi Michev georgi.michev@vereign.com @rest @all @tsa @signer -Feature: API -TSA - Signer keys - v1/keys POST +Feature: API - TSA - Signer keys - v1/keys GET As user I want to see what keys are available So I am able to use them the future diff --git a/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature b/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature new file mode 100644 index 00000000..84af1aa9 --- /dev/null +++ b/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature @@ -0,0 +1,40 @@ +#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/proof +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @signer +Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST + As user + I want to check a presentation proof + So I am sure it is valid + + Background: + Given we are testing the TSA Signer Api + + Scenario: TSA - validate presentation proof - Positive + When I load the request from json {/REST/json/Presentation.json} + When I validate 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} + + @wip @bug-signer-#13 + Scenario: TSA - validate presentation proof with empty body - Negative + When I set the following request body {{}} + When I validate presentation proof via TSA Signer API + And the status code should be {400} + And the field {message} has the value {missing required payload} -- GitLab