diff --git a/src/main/resources/REST/json/Presentation.json b/src/main/resources/REST/json/Presentation.json new file mode 100644 index 0000000000000000000000000000000000000000..d4678bd4a90860d58fca50bb6376a65ee3134ddc --- /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 0000000000000000000000000000000000000000..427c92b10631b053145e5da575828e6f60d0c2e0 --- /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 da72e92ff7c96161767e4771482cf3a28fff28c4..c3b2463970862a4bcde5bf0e1c0d70b7960cb2de 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 831a682b3eb43056d2076a766b25f3ae95006626..5e35cf3e2fe852154eda496902871bdddf8f7d1e 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 58d5a1a12c4b87660f1f3c92f4a71ca39545b93d..2ff98c1ac19d76a9c8fa00904693e4fdc6286e39 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 0000000000000000000000000000000000000000..84af1aa993b73986a93ac9815157d77514daaeba --- /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}