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

add export and import for Infohub

parent b58e1045
Branches
No related tags found
1 merge request!25add export and import for Infohub
Showing
with 561 additions and 68 deletions
As user
I want to execute the list of tasks
So I am able to bring the consistensy to running multiple asyncronous tasks
Scenario: Sequential task list processing
Given long running policy is uploaded to the system
And the list of tasks is defined
And the list of tasks contains the group of tasks
And the group of tasks contains task A and task B
When I evaluate a policy
And the task list specified as an input
Then I get successful response with waiting status
And the response contains the taskListObject
And the taskListObject contains the taskList id
And the taskListObject contains the taskIDs of all the tasks
Scenario: Handling the error for the sequential task list execution
Given task list is configured
And the list of tasks contains the group of tasks
And the group of tasks contains task A, task B and task C
And the group of tasks is configured for running one by one
And the task list has executed
And task B failed
When I request the result of task list execution
Then I get the failure response
And the status of task list execution marked as failed
And the status of task A is marked as successful
And the status of task B is marked as failed
And the status of task C is marked as failed
Scenario: Handling the error for the parallel task list execution
Given task list is configured
And the list of tasks contains the group of tasks
And the group of tasks contains task A, task B and task C
And the group of tasks is configured for running in parallel
And the task list has executed
And task B failed
When I request the result of task list execution
Then I get the failure response
And the status of task list execution marked as failed
And the status of task A is marked as successful
And the status of task B is marked as failed
And the status of task C is marked as successful
Scenario: Handling the error for the mixed task list execution
Given task list is configured
And the list of tasks contains the group A and group B
And the group A configured for running sequentially
And the group B configured for running in parallel
And the task list has executed
And one of the tasks in a group B failed
When I request the result of the task list execution
Then I get the failure response
And the status of task list execution marked as failed
...@@ -23,6 +23,15 @@ public class RestSessionContainer { ...@@ -23,6 +23,15 @@ public class RestSessionContainer {
private String taskID; private String taskID;
private String taskListID; private String taskListID;
private List<String> groupTaskIDs; private List<String> groupTaskIDs;
private List<String> importIDs;
public List<String> getImportIDs() {
return importIDs;
}
public void setImportIDs(List<String> importIDs) {
this.importIDs = importIDs;
}
public List<String> getGroupTaskIDs() { public List<String> getGroupTaskIDs() {
return groupTaskIDs; return groupTaskIDs;
......
...@@ -244,6 +244,14 @@ public class JsonUtils { ...@@ -244,6 +244,14 @@ public class JsonUtils {
return System.getProperty("baseUrl") + "/cache"; return System.getProperty("baseUrl") + "/cache";
} }
/**
* Get the url for "TSA Infohub"
* @return the uri
*/
public static String getTSAInfohub() {
return System.getProperty("baseUrl") + "/infohub";
}
/** /**
* Get the url for "TSA Signer" * Get the url for "TSA Signer"
* @return the uri * @return the uri
......
{
"@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"
},
"issuanceDate": "2022-07-01T13:29:47.578628068Z",
"issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation",
"type": "VerifiableCredential"
}
\ No newline at end of file
{
"successful_import": {
"@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-08T09:23:43.073435032Z",
"jws": "eyJhbGciOiJKc29uV2ViU2lnbmF0dXJlMjAyMCIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..MEYCIQCSmaYCbM8RweOXO1Vauz7F5taH9xnRKtcmkTkrhxw9DQIhAMhLuFBqk5JvYstemhdBGc81Ie3zOl00m_5CmfUd7OtO",
"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-08T09:23:43.006994232Z",
"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": "2022-07-08T09:23:43.006998385Z",
"issuer": "did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation",
"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": {
"allow": {
"type": "boolean"
},
"id": {
"type": "string"
}
},
"required": [
"allow",
"id"
]
},
"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": {
"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
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"importIds": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
}
]
}
},
"required": [
"importIds"
]
}
\ 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"
}
]
},
"credentialSubject": {
"type": "object",
"properties": {
"allow": {
"type": "boolean"
},
"hello": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"allow",
"hello",
"id"
]
},
"issuanceDate": {
"type": "string"
},
"issuer": {
"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"
}
},
"required": [
"@context",
"credentialSubject",
"issuanceDate",
"issuer",
"proof",
"type"
]
}
\ No newline at end of file
...@@ -66,6 +66,16 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions { ...@@ -66,6 +66,16 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
currentRequest.setContentType("application/json"); currentRequest.setContentType("application/json");
} }
@Given("we are testing the TSA Infohub Api")
public void weAreTestingTheTSAInfohubApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSAInfohub());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
}
@Given("^we are testing the TSA Policy Api") @Given("^we are testing the TSA Policy Api")
public void we_are_testing_the_Policy_api() throws Throwable { public void we_are_testing_the_Policy_api() throws Throwable {
RestClient.setDefaultEncoding("UTF8"); RestClient.setDefaultEncoding("UTF8");
...@@ -224,5 +234,4 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions { ...@@ -224,5 +234,4 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
public void iLoadValueIntoCurrentRequestHEADER(String value, String headerName) throws Throwable { public void iLoadValueIntoCurrentRequestHEADER(String value, String headerName) throws Throwable {
currentRequest.getHeaders().put(headerName, value); currentRequest.getHeaders().put(headerName, value);
} }
} }
...@@ -5,7 +5,6 @@ import api.test.rest.RestGeneralStepDefinitions; ...@@ -5,7 +5,6 @@ import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer; import api.test.rest.RestSessionContainer;
import core.*; import core.*;
import cucumber.api.java.en.And; import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -34,4 +33,15 @@ public class CacheStepDefinitions extends BaseStepDefinitions { ...@@ -34,4 +33,15 @@ public class CacheStepDefinitions extends BaseStepDefinitions {
addResponse(response); addResponse(response);
} }
} }
@And("^I get the result \\{(\\d+)\\} from Import IDs $")
public void iGetTheResultOfTask(int id) {
iSendTheCachePOSTRequest( restSessionContainer.getImportIDs().get(id));
}
@And("I load element \\{(\\d+)\\} from Info SessionContainer into currentRequest HEADER \\{(.*?)\\}$")
public void load_element_from_Info_SessionContainer_into_currentRequest_Header_(int id, String headerName) throws Throwable {
currentRequest.getHeaders().put(headerName, restSessionContainer.getImportIDs().get(id));
}
} }
package api.test.rest.tsa.infohub;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer;
import com.jayway.jsonpath.JsonPath;
import core.DataContainer;
import core.Request;
import core.Response;
import core.RestClient;
import cucumber.api.java.en.And;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
public class InfohubStepDefinitions extends BaseStepDefinitions {
private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer;
Request currentRequest;
public InfohubStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) {
super(dataContainer);
this.restSessionContainer = restSessionContainer;
this.currentRequest = currentRequest;
}
@And("^I export the \\{(.*)\\} via TSA Infohub API$")
public void iExportTheData(String configuration) {
currentRequest.setPath("/v1/export/" + configuration);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@And("I import data via TSA Infohub API")
public void iImportData() {
currentRequest.setPath("/v1/import");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse().getStatusCode() == 200) {
String responseBody = getLastResponse().getBody();
List<String> importResult = JsonPath.read(responseBody, "$.importIds");
restSessionContainer.setImportIDs(importResult);
}
}
}
...@@ -22,9 +22,7 @@ import api.test.rest.RestGeneralStepDefinitions; ...@@ -22,9 +22,7 @@ import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer; import api.test.rest.RestSessionContainer;
import core.*; import core.*;
import cucumber.api.java.en.And; import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import exceptions.RAFException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
......
...@@ -44,11 +44,19 @@ public class SignerStepDefinitions extends BaseStepDefinitions { ...@@ -44,11 +44,19 @@ public class SignerStepDefinitions extends BaseStepDefinitions {
addResponse(response); addResponse(response);
} }
@When("I validate presentation proof via TSA Signer API") @When("I create presentation proof via TSA Signer API")
public void iValidatePresentationProofViaTSASignerAPI() { public void iCreatePresentationProofViaTSASignerAPI() {
currentRequest.setPath("/v1/presentation/proof"); currentRequest.setPath("/v1/presentation/proof");
Response response = RestClient.post(currentRequest); Response response = RestClient.post(currentRequest);
addRequest(currentRequest); addRequest(currentRequest);
addResponse(response); addResponse(response);
} }
@When("I create credential proof via TSA Signer API")
public void iCreateCredentialProofViaTSASignerAPI() {
currentRequest.setPath("/v1/credential/proof");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
} }
...@@ -100,4 +100,5 @@ public class TaskStepDefinitions extends BaseStepDefinitions{ ...@@ -100,4 +100,5 @@ public class TaskStepDefinitions extends BaseStepDefinitions{
public void iGetTheResultOfTask(int id) { public void iGetTheResultOfTask(int id) {
iGetTheTaskResultWithKey( restSessionContainer.getGroupTaskIDs().get(id)); iGetTheTaskResultWithKey( restSessionContainer.getGroupTaskIDs().get(id));
} }
} }
\ No newline at end of file
...@@ -67,4 +67,20 @@ Feature: API -TSA - Cache - v1/cache GET ...@@ -67,4 +67,20 @@ Feature: API -TSA - Cache - v1/cache GET
When I send the Cache GET request via TSA Cache API When I send the Cache GET request via TSA Cache API
Then the status code should be {200} Then the status code should be {200}
And the response is valid according to the {Task_ExecuteDID_schema.json} REST schema And the response is valid according to the {Task_ExecuteDID_schema.json} REST schema
And the field {data.didDocument.id} has the value {did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6} And the field {data.didDocument.id} has the value {did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6}
\ No newline at end of file
Scenario: TSA - Check the Cache after importing data to Infohub - Positive
Given we are testing the TSA Infohub Api
When I load the REST request {Infohub.json} with profile {successful_import}
And I import data via TSA Infohub API
Then the status code should be {200}
## Checking the cache service with Import IDs
Given we are testing the TSA Cache Api
Then I load element {0} from Info SessionContainer into currentRequest HEADER {x-cache-key}
When I send the Cache GET request via TSA Cache API
And the field {allow} has the value {true}
And the field {id} has the value {example/examplePolicy/1.0}
Then I load element {1} from Info SessionContainer into currentRequest HEADER {x-cache-key}
When I send the Cache GET request via TSA Cache API
And the field {allow} has the value {true}
And the field {id} has the value {example/ProofRequestResponse/1.0}
#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/infohub/v1/export
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @infohub
Feature: API - TSA - Infohub - v1/export GET
As user
I want to export data wrapped as Verifiable Credential or Presentation
So I can have the data with proof
Background:
Given we are testing the TSA Infohub Api
Scenario: TSA - Export through Infohub - Positive
When I export the {testexport} via TSA Infohub API
Then the status code should be {200}
When I export the {testexport} via TSA Infohub API
Then the status code should be {200}
And the response is valid according to the {Infohub_Export_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}
And the field {proof.type} has the value {JsonWebSignature2020}
#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/infohub/v1/import
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @infohub
Feature: API - TSA - Infohub - v1/export POST
As user
I want to import data in to Infohub
So I can export it later
Background:
Given we are testing the TSA Infohub Api
Scenario: TSA - Import data to Infohub - Positive
When I load the REST request {Infohub.json} with profile {successful_import}
And I import data via TSA Infohub API
Then the status code should be {200}
And the response is valid according to the {Infohub_Import_schema.json} REST schema
\ No newline at end of file
#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/credential/proof
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @signer
Feature: API - TSA - Signer credential proof - v1/credential/proof POST
As user
I want to create a credential proof
So the credential can be verified
Background:
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 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
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 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}
And the field {message} has the value {missing required payload}
...@@ -19,15 +19,15 @@ ...@@ -19,15 +19,15 @@
@rest @all @tsa @signer @rest @all @tsa @signer
Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST
As user As user
I want to check a presentation proof I want to create a presentation proof
So I am sure it is valid So the presentation can be verified
Background: Background:
Given we are testing the TSA Signer Api Given we are testing the TSA Signer Api
Scenario: TSA - validate presentation proof - Positive Scenario: TSA - create presentation proof - Positive
When I load the request from json {/REST/json/Presentation.json} When I load the request from json {/REST/json/Presentation.json}
When I validate presentation proof via TSA Signer API When I create presentation proof via TSA Signer API
And the status code should be {200} And the status code should be {200}
And the response is valid according to the {Signer_PresentationProof_schema.json} REST schema 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} And the field {proof.verificationMethod} has the value {did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation#key1}
...@@ -35,6 +35,6 @@ Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST ...@@ -35,6 +35,6 @@ Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST
@wip @bug-signer-#13 @wip @bug-signer-#13
Scenario: TSA - validate presentation proof with empty body - Negative Scenario: TSA - validate presentation proof with empty body - Negative
When I set the following request body {{}} When I set the following request body {{}}
When I validate presentation proof via TSA Signer API When I create presentation proof via TSA Signer API
And the status code should be {400} And the status code should be {400}
And the field {message} has the value {missing required payload} And the field {message} has the value {missing required payload}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment