Skip to content
Snippets Groups Projects
Commit 1c715ae5 authored by Georgi Michev's avatar Georgi Michev
Browse files

Merge branch 'create-presentation-from-json' into 'main'

Add test for Signer presentation

See merge request !33
parents 6f53a65a 6fc13a12
No related branches found
No related tags found
1 merge request!33Add test for Signer presentation
Pipeline #53546 passed with stage
in 4 minutes and 54 seconds
{
"single": {
"data": [
{
"age": 21,
"over18": true
}
]
},
"multi": {
"data": [
{
"dataOfBirth": "-0571-01-01T07:53:06.234142119Z",
"age": 2592,
"over18": true
},
{
"fName": "Pythagoras",
"lName": "of Samos"
}
]
},
"context": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/jws-2020/v1",
"https://schema.org"
],
"data": [
{
"dataOfBirth": "-0571-01-01T07:53:06.234142119Z",
"age": 2592,
"over18": true
},
{
"fName": "Pythagoras",
"lName": "of Samos"
}
]
},
"blank": {
},
"missing_data": {
"not_data": [
{
"age": 21,
"over18": true
}
]
},
"blank_data": {
"data": []
},
"data_format": {
"data": "different format"
}
}
\ No newline at end of file
{
"$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": {
"age": {
"type": "integer"
},
"dataOfBirth": {
"type": "string"
},
"over18": {
"type": "boolean"
}
},
"required": [
"age",
"dataOfBirth",
"over18"
]
},
"issuanceDate": {
"type": "string"
},
"issuer": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"@context",
"credentialSubject",
"issuanceDate",
"issuer",
"type"
]
},
{
"type": "object",
"properties": {
"@context": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
},
{
"type": "string"
}
]
},
"credentialSubject": {
"type": "object",
"properties": {
"fName": {
"type": "string"
},
"lName": {
"type": "string"
}
},
"required": [
"fName",
"lName"
]
},
"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
{
"$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": {
"age": {
"type": "integer"
},
"dataOfBirth": {
"type": "string"
},
"over18": {
"type": "boolean"
}
},
"required": [
"age",
"dataOfBirth",
"over18"
]
},
"issuanceDate": {
"type": "string"
},
"issuer": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"@context",
"credentialSubject",
"issuanceDate",
"issuer",
"type"
]
},
{
"type": "object",
"properties": {
"@context": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
},
{
"type": "string"
}
]
},
"credentialSubject": {
"type": "object",
"properties": {
"fName": {
"type": "string"
},
"lName": {
"type": "string"
}
},
"required": [
"fName",
"lName"
]
},
"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
{
"$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": {
"age": {
"type": "integer"
},
"over18": {
"type": "boolean"
}
},
"required": [
"age",
"over18"
]
},
"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
......@@ -44,6 +44,14 @@ public class SignerStepDefinitions extends BaseStepDefinitions {
addResponse(response);
}
@When("I create presentation from JSON via TSA Signer API")
public void iCreatePresentationFromJSONViaTSASignerAPI() {
currentRequest.setPath("/v1/presentation");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("I create presentation proof via TSA Signer API")
public void iCreatePresentationProofViaTSASignerAPI() {
currentRequest.setPath("/v1/presentation/proof");
......
#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
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @signer
Feature: API - TSA - Signer create presentation from JSON - v1/presentation POST
As user
I want to create verifiable presentation from JSON
So the presentation can be verified
Background:
Given we are testing the TSA Signer Api
Scenario Outline: TSA - create presentation from JSON <labelSuffix> - Positive
When I load the REST request {Data.json} with profile {<profileOption>}
And I create presentation from JSON via TSA Signer API
Then the status code should be {200}
And the response is valid according to the {<schema>} REST schema
And the field {proof.verificationMethod} has the value {did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation#key1}
Examples:
| labelSuffix | profileOption | schema |
| single data | single | Signer_JSON_single_schema.json |
| multi data | multi | Signer_JSON_multi_schema.json |
| with context | context | Signer_JSON_context_schema.json |
@negative
Scenario Outline: TSA - create presentation from JSON <labelSuffix> - Negative
When I load the REST request {Data.json} with profile {<profileOption>}
And I create presentation from JSON via TSA Signer API
Then the status code should be {400}
And the response is valid according to the {Signer_GetKey_negative_schema.json} REST schema
And the field {message} contains the value {<errMessage>}
Examples:
| labelSuffix | profileOption | errMessage |
| blank | blank | "data" is missing from body |
| missing data field | missing_data | "data" is missing from body |
| blank data | blank_data | invalid or missing credentials data |
| wrong format | data_format | json: cannot unmarshal string into Go struct field |
@negative
Scenario: TSA - create presentation from JSON with invalid body - Negative
When I set the following request body {{"data":[{"text": "some text"}}}
And I create presentation from JSON via TSA Signer API
Then the status code should be {400}
And the response is valid according to the {Signer_GetKey_negative_schema.json} REST schema
And the field {message} contains the value {invalid character}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment