From 591d75f9144de4e7bde99fa71ae2ae965b56ad06 Mon Sep 17 00:00:00 2001 From: "georgi.michev" <georgi.michev@vereign.com> Date: Fri, 29 Jul 2022 11:08:19 +0300 Subject: [PATCH] update credential schema After implementing the strict validation all fields has to have schemas. Signed-off-by: georgi.michev <georgi.michev@vereign.com> --- src/main/resources/REST/json/Credential.json | 59 ++++++++++--- .../Signer_CredentialProof_schema.json | 83 ++++++++++++++----- .../signer/v1/credential/proof/POST.feature | 5 +- 3 files changed, 110 insertions(+), 37 deletions(-) diff --git a/src/main/resources/REST/json/Credential.json b/src/main/resources/REST/json/Credential.json index 90acfcfd..2ebfe51b 100644 --- a/src/main/resources/REST/json/Credential.json +++ b/src/main/resources/REST/json/Credential.json @@ -1,15 +1,50 @@ { - "@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, - "hello": "world", - "id": "example/examplePolicy/1.0" + "for_proof":{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://w3id.org/security/suites/jws-2020/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://schema.org" + ], + "credentialSubject": { + "allow": true, + "id": "https://gaiax.vereign.com/tsa/policy/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" + } + ] }, - "issuanceDate": "2022-07-01T13:29:47.578628068Z", - "issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation", - "type": "VerifiableCredential" + "incorrect_id":{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://w3id.org/security/suites/jws-2020/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://schema.org" + ], + "credentialSubject": { + "allow": true, + "id": "ZZZZZZZZZZZZZZZ" + }, + "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_CredentialProof_schema.json b/src/main/resources/REST/schemas/Signer_CredentialProof_schema.json index 50182c1b..23a7e9c2 100644 --- a/src/main/resources/REST/schemas/Signer_CredentialProof_schema.json +++ b/src/main/resources/REST/schemas/Signer_CredentialProof_schema.json @@ -8,34 +8,15 @@ { "type": "string" }, - { - "type": "string" - }, { "type": "string" } ] }, "credentialSubject": { - "type": "object", - "properties": { - "allow": { - "type": "boolean" - }, - "hello": { - "type": "string" - }, - "id": { - "type": "string" - } - }, - "required": [ - "allow", - "hello", - "id" - ] + "type": "null" }, - "issuanceDate": { + "id": { "type": "string" }, "issuer": { @@ -70,14 +51,70 @@ }, "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", "credentialSubject", - "issuanceDate", + "id", "issuer", "proof", - "type" + "type", + "verifiableCredential" ] } \ No newline at end of file diff --git a/src/test/resources/features/tsa/signer/v1/credential/proof/POST.feature b/src/test/resources/features/tsa/signer/v1/credential/proof/POST.feature index 19b959c5..54f282bf 100644 --- a/src/test/resources/features/tsa/signer/v1/credential/proof/POST.feature +++ b/src/test/resources/features/tsa/signer/v1/credential/proof/POST.feature @@ -26,7 +26,7 @@ Feature: API - TSA - Signer credential proof - v1/credential/proof POST Given we are testing the TSA Signer Api Scenario: TSA - create credential proof - Positive - When I load the request from json {/REST/json/Credential.json} + When I load the REST request {Credential.json} with profile {for_proof} When I create credential proof via TSA Signer API And the status code should be {200} And the response is valid according to the {Signer_CredentialProof_schema.json} REST schema @@ -36,4 +36,5 @@ Feature: API - TSA - Signer credential proof - v1/credential/proof POST Scenario: TSA - validate credential proof with empty body - Negative When I set the following request body {{}} When I create credential proof via TSA Signer API - And the status code should be {400} \ No newline at end of file + And the status code should be {400} + And the field {message} has the value {build new credential: fill credential types from raw: credential type of unknown structure} -- GitLab