Skip to content
Snippets Groups Projects
Commit b58e1045 authored by Rosen Georgiev's avatar Rosen Georgiev
Browse files

Merge branch 'enhance-step-definitions' into 'main'

refactor step definitions

See merge request !22
parents 1c24140a 8bbe3ef6
No related branches found
No related tags found
1 merge request!22refactor step definitions
Pipeline #52491 passed
Showing
with 611 additions and 319 deletions
As user
I want to evaluate the policy asynchronously
So I am able to execute the developed Rego code in the future non-blocking
Scenario: Execute the task during evaluating policy
Given long running policy is uploaded to the system
And the task template is uploaded to the system
When I evaluate the policy asynchronously
And the task template is specified as an input
When I get successful response
And the response contains taskId
Scenario: Getting the result for the executed task
Given long running policy is executed
When I request the result of execution
And request contains the taskId
And the task has finished
Then I get successful response
And response contains the result of execution of the policy
Acceptance criteria:
- HTTP endpoints to evaluate the policy asynchronously and get the result
- example of long-running policy committed to Git repo
- Green test based on example committed to the system
......@@ -17,251 +17,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package api.test.rest;
import api.test.rest.pojo.Member;
import java.util.List;
public class RestSessionContainer {
private Member member;
private String oauthToken;
private String oauthUUID;
private String personEntityUUID;
private String organizationEntityUUID;
private String assetEntityUUID;
private String passportEntityUUID;
private String documentEntityUUID;
private String conversationEntityUUID;
private String vcardURL;
private String wopiAccessToken;
private String qrCode;
private String actionID;
private String publicKey;
private String carddavUsername;
private String carddavPassword;
private String identificator;
private String newDevicePublicKey;
private String deviceID;
private String phoneNumber;
private String currentCompany;
private String recipientEmail;
private String messegeId;
private String subject;
private String batchKey;
private String batchKey2;
private String batchValue;
private String taskID;
private String taskListID;
private List<String> groupTaskIDs;
public String getIdentificator() {
return identificator;
public List<String> getGroupTaskIDs() {
return groupTaskIDs;
}
public void setIdentificator(String identificator) {
this.identificator = identificator;
public void setGroupTaskIDs(List<String> groupTaskIDs) {
this.groupTaskIDs = groupTaskIDs;
}
public Member getCurrentMember() {
return member;
public String getTaskID() {
return taskID;
}
public void setCurrentMember(Member member) {
this.member = member;
public String getTaskListID() {
return taskListID;
}
public String getOauthToken() {
return oauthToken;
public void setTaskID(String taskID) {
this.taskID = taskID;
}
public void setOauthToken(String oauthToken) {
this.oauthToken = oauthToken;
public void setTaskListID(String taskListID) {
this.taskListID= taskListID;
}
public String getOauthUUID() {
return oauthUUID;
}
public void setOauthUUID(String oauthUUID) {
this.oauthUUID = oauthUUID;
}
public String getPersonEntityUUID() {
return personEntityUUID;
}
public void setPersonEntityUUID(String personEntityUUID) {
this.personEntityUUID = personEntityUUID;
}
public String getOrganizationEntityUUID() {
return organizationEntityUUID;
}
public void setOrganizationEntityUUID(String organizationEntityUUID) {
this.organizationEntityUUID = organizationEntityUUID;
}
public String getAssetEntityUUID() {
return assetEntityUUID;
}
public void setAssetEntityUUID(String assetEntityUUID) {
this.assetEntityUUID = assetEntityUUID;
}
public String getPassportEntityUUID() {
return passportEntityUUID;
}
public void setPassportEntityUUID(String passportEntityUUID) {
this.passportEntityUUID = passportEntityUUID;
}
public String getDocumentEntityUUID() {
return documentEntityUUID;
}
public void setDocumentEntityUUID(String documentEntityUUID) {
this.documentEntityUUID = documentEntityUUID;
}
public String getConversationEntityUUID() {
return conversationEntityUUID;
}
public void setConversationEntityUUID(String conversationEntityUUID) {
this.conversationEntityUUID = conversationEntityUUID;
}
public String getVcardURL() {
return vcardURL;
}
public void setVcardURL(String vcardURL) {
this.vcardURL = vcardURL;
}
public String getWopiAccessToken() {
return wopiAccessToken;
}
public void setWopiAccessToken(String wopiAccessToken) {
this.wopiAccessToken = wopiAccessToken;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getActionID() {
return actionID;
}
public void setActionID(String actionID) {
this.actionID = actionID;
}
public String getPublicKey() {
return publicKey;
}
public void setPublicKey(String publicKey) {
this.publicKey = publicKey;
}
public String getCarddavUsername() {
return carddavUsername;
}
public void setCarddavUsername(String carddavUsername) {
this.carddavUsername = carddavUsername;
}
public String getCarddavPassword() {
return carddavPassword;
}
public void setCarddavPassword(String carddavPassword) {
this.carddavPassword = carddavPassword;
}
public String getNewDevicePublicKey() {
return newDevicePublicKey;
}
public void setNewDevicePublicKey(String newDevicePublicKey) {
this.newDevicePublicKey = newDevicePublicKey;
}
public String getDeviceID() {
return deviceID;
}
public void setDeviceID(String deviceID) {
this.deviceID = deviceID;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getCurrentCompany() {
return currentCompany;
}
public void setCurrentCompany(String currentCompany) {
this.currentCompany = currentCompany;
}
public String getRecipientEmail() {
return recipientEmail;
}
public void setRecipientEmail(String recipientEmail) {
this.recipientEmail = recipientEmail;
}
public String getMessegeId() {
return messegeId;
}
public void setMessegeId(String messegeId) {
this.messegeId = messegeId;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getBatchKey() {
return batchKey;
}
public void setBatchKey(String batchKey) {
this.batchKey = batchKey;
}
public String getBatchValue() {
return batchValue;
}
public void setBatchValue(String batchValue) {
this.batchValue = batchValue;
}
public String getBatchKey2() {
return batchKey2;
}
public void setBatchKey2(String batchKey2) {
this.batchKey2 = batchKey2;
}
}
}
\ No newline at end of file
......@@ -244,6 +244,14 @@ public class JsonUtils {
return System.getProperty("baseUrl") + "/cache";
}
/**
* Get the url for "TSA Signer"
* @return the uri
*/
public static String getTSASigner() {
return System.getProperty("baseUrl") + "/signer";
}
/**
* Get the url for "TSA Task"
* @return the uri
......
{
"successful_evaluate": {
"successful_message": {
"message": "hello world"
},
"unsuccessful_evaluate": {
"incorrect_message": {
"message": "wrong value!"
},
"didResolve_indy_evaluate": {
"did_indy": {
"did":"did:indy:idunion:BDrEcHc8Tb4Lb2VyQZWEDE"
},
"didResolve_evaluate": {
"did_key": {
"did":"did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6"
},
"didResolve_missing_method": {
"did_missing_method": {
"did":"did:idunion:BDrEcHc8Tb4Lb2VyQZWEDE"
}
}
\ No newline at end of file
{
"@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
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"items": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"controller": {
"type": "string"
},
"publicKeyJwk": {
"type": "object",
"properties": {
"kty": {
"type": "string"
},
"kid": {
"type": "string"
},
"crv": {
"type": "string"
},
"x": {
"type": "string"
},
"y": {
"type": "string"
}
},
"required": [
"kty",
"kid",
"crv",
"x",
"y"
]
}
},
"required": [
"id",
"type",
"controller",
"publicKeyJwk"
]
}
]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"kind": {
"type": "integer"
}
},
"required": [
"id",
"kind"
]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"controller": {
"type": "string"
},
"publicKeyJwk": {
"type": "object",
"properties": {
"kty": {
"type": "string"
},
"kid": {
"type": "string"
},
"crv": {
"type": "string"
},
"x": {
"type": "string"
},
"y": {
"type": "string"
}
},
"required": [
"kty",
"kid",
"crv",
"x",
"y"
]
}
},
"required": [
"id",
"type",
"controller",
"publicKeyJwk"
]
}
\ 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"
]
}
]
}
},
"required": [
"@context",
"id",
"proof",
"type",
"verifiableCredential"
]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"taskListID": {
"type": "string"
}
},
"required": [
"taskListID"
]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"groups": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"tasks": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"id",
"status"
]
},
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"id",
"status"
]
}
]
}
},
"required": [
"id",
"status",
"tasks"
]
}
]
}
},
"required": [
"id",
"status",
"groups"
]
}
\ No newline at end of file
......@@ -1446,4 +1446,22 @@ public class GeneralStepDefinitions extends BaseStepDefinitions {
currentRequest.setBody(new Gson().toJson(jsonObject));
}
@And("^the field \\{(.*?)\\} has one of the values$")
public static void theFieldHasOneOfTheValues(String jsonPath, List<String> expectedResultAsList) throws Throwable {
Configuration conf = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();
ReadContext responseContext = JsonPath.using(conf).parse(getLastResponse().getBody());
Object parsedResult = responseContext.read(jsonPath);
String actualResultAsString = String.valueOf(parsedResult);
for(String x: expectedResultAsList) {
if (x.equals(actualResultAsString)){
return;
}
}
assertEquals("Expected values doesn't match actual: ", expectedResultAsList, actualResultAsString);
}
}
\ No newline at end of file
......@@ -56,6 +56,16 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
}
@Given("we are testing the TSA Cache Api")
public void weAreTestingTheTSACacheApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSACache());
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")
public void we_are_testing_the_Policy_api() throws Throwable {
RestClient.setDefaultEncoding("UTF8");
......@@ -66,6 +76,26 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
currentRequest.setContentType("application/json");
}
@Given("we are testing the TSA Signer Api")
public void weAreTestingTheTSASignerApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSASigner());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
}
@Given("we are testing the TSA Task Api")
public void weAreTestingTheTSATaskApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSATask());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
}
@Given("^I load the REST request \\{(.*)\\} with profile \\{(.*)\\}$")
public void I_load_the_REST_request__with_profile_(String jsonName, String profileName) throws Throwable {
logger.info("Loading REST json into current request body. Json file= [{}] , profile= [{}]", jsonName, profileName);
......@@ -189,4 +219,10 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
String cipherText = encrypt(message, pair.getPublic());
currentRequest.getHeaders().put("publicKey", cipherText);
}
@And("^I load value \\{(.*)\\} into current request HEADER \\{(.*)\\}$")
public void iLoadValueIntoCurrentRequestHEADER(String value, String headerName) throws Throwable {
currentRequest.getHeaders().put(headerName, value);
}
}
......@@ -3,10 +3,8 @@ package api.test.rest.tsa.cache;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer;
import core.DataContainer;
import core.JsonUtils;
import core.Request;
import core.RestClient;
import core.*;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -22,13 +20,18 @@ public class CacheStepDefinitions extends BaseStepDefinitions {
this.currentRequest = currentRequest;
}
@Given("we are testing the TSA Cache Api")
public void weAreTestingTheTSACacheApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSACache());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
@And("^I send the Cache (POST|GET) request via TSA Cache API$")
public void iSendTheCachePOSTRequest(String method) {
currentRequest.setPath("/v1/cache");
if (method.equals("POST")) {
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
} else if (method.equals("GET")) {
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
}
}
......@@ -20,12 +20,11 @@ package api.test.rest.tsa.policy;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer;
import core.DataContainer;
import core.Request;
import core.Response;
import core.RestClient;
import core.*;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import exceptions.RAFException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -41,25 +40,25 @@ public class PolicyStepDefinitions extends BaseStepDefinitions {
this.currentRequest = currentRequest;
}
@And("^I execute the policy \\{(.*)\\}$")
public void iExecuteThePolicy(String path) throws Throwable {
currentRequest.setPath(path);
@And("^I execute the Policy group \\{(.*)\\} name \\{(.*)\\} version \\{(.*)\\} via TSA Policy API$")
public void iExecuteThePolicyGroupNameVersionTSAPolicyAPI(String group, String name, String version) throws Throwable {
currentRequest.setPath("/policy/" + group + "/" + name + "/" + version + "/evaluation");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("^I lock the policy \\{(.*)\\}$")
public void iLockThePolicy(String path) throws Throwable {
currentRequest.setPath(path);
@When("^I lock the Policy group \\{(.*)\\} name \\{(.*)\\} version \\{(.*)\\}$")
public void iLockThePolicyGroupNameVersion(String group, String name, String version) throws Throwable {
currentRequest.setPath("/policy/" + group + "/" + name + "/" + version + "/lock");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("^I unlock the policy \\{(.*)\\}$")
public void iUnlockThePolicy(String path) throws Throwable {
currentRequest.setPath(path);
@When("^I unlock the policy group \\{(.*)\\} name \\{(.*)\\} version \\{(.*)\\}$")
public void iUnlockThePolicy(String group, String name, String version) throws Throwable {
currentRequest.setPath("/policy/" + group + "/" + name + "/" + version + "/lock");
Response response = RestClient.delete(currentRequest);
addRequest(currentRequest);
addResponse(response);
......
package api.test.rest.tsa.signer;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer;
import core.*;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class SignerStepDefinitions extends BaseStepDefinitions {
private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer;
Request currentRequest;
public SignerStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) {
super(dataContainer);
this.restSessionContainer = restSessionContainer;
this.currentRequest = currentRequest;
}
@When("I get all keys via TSA Signer API")
public void iGetAllKeysViaTSASignerAPI() {
currentRequest.setPath("/v1/keys");
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("^I get key \\{(.*)\\} via TSA Signer API$")
public void iGetKeyViaTSASignerAPI(String key) {
currentRequest.setPath("/v1/keys/" + key);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("I get issuer DID via TSA Signer API")
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);
}
}
......@@ -3,12 +3,21 @@ package api.test.rest.tsa.task;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestGeneralStepDefinitions;
import api.test.rest.RestSessionContainer;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.ReadContext;
import core.*;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class TaskStepDefinitions extends BaseStepDefinitions{
private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer;
......@@ -20,22 +29,75 @@ public class TaskStepDefinitions extends BaseStepDefinitions{
this.currentRequest = currentRequest;
}
@Given("we are testing the TSA Task Api")
public void weAreTestingTheTSATaskApi() {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getTSATask());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
@And("^I execute the Task \\{(.*)\\} via TSA Task API$")
public void iExecuteTheTaskTSATaskAPI(String path) throws Throwable {
currentRequest.setPath("/v1/task/" + path);
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse().getStatusCode() == 200) {
String responseBody = getLastResponse().getBody();
Object result = JsonPath.read(responseBody, "$.taskID");
String taskId = result.toString();
restSessionContainer.setTaskID(taskId);
}
}
@And("^I execute the taskList \\{(.*)\\} via TSA Task API$")
public void iExecuteTheTaskListTSATaskAPI(String path) throws Throwable {
currentRequest.setPath("/v1/taskList/" + path);
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse().getStatusCode() == 200) {
String responseBody = getLastResponse().getBody();
Object result = JsonPath.read(responseBody, "$.taskListID");
String taskListId = result.toString();
restSessionContainer.setTaskListID(taskListId);
}
}
@And("^I get the Task result with key \\{(.*)\\}$")
public void iGetTheTaskResultWithKey(String suffix) {
currentRequest.setPath("v1/taskResult/"+ suffix);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@And("^I get the current Task Result via TSA Task API$")
public void iGetTheCurrentTaskResultTSATaskAPI() {
String currentTask = restSessionContainer.getTaskID();
iGetTheTaskResultWithKey(currentTask);
}
@And("^I send the current request to endpoint \\{(.*?)\\} with container value\\{(.*?)\\}$")
public void I_send_the_current_request_to_endpoint_with_container_value(String endpoint, String suffix) throws Throwable {
currentRequest.setPath(endpoint +"/"+ getDataContainer().getObject(suffix));
@And("^I get the current taskList Status via TSA Task API$")
public void iGetTheCurrentTaskListStatusTSATaskAPI() {
String currentTask = restSessionContainer.getTaskListID();
currentRequest.setPath("v1/taskListStatus/"+ currentTask);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse().getStatusCode() == 200) {
String responseBody = getLastResponse().getBody();
List<String> taskResult = JsonPath.read(responseBody, "$..tasks..id");
restSessionContainer.setGroupTaskIDs(taskResult);
}
}
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
@And("^I get the result of Task \\{(\\d+)\\}$")
public void iGetTheResultOfTask(int id) {
iGetTheTaskResultWithKey( restSessionContainer.getGroupTaskIDs().get(id));
}
}
}
\ No newline at end of file
......@@ -31,28 +31,40 @@ Feature: API -TSA - Cache - v1/cache GET
Given we are testing the TSA Cache Api
Scenario: TSA - Working with Cache - Positive
Given I load the REST request {Cache.json} with profile {successful_set}
And I store key {key_positive} with value {test} in the data container
And I load object with key {key_positive} from DataContainer into currentRequest HEADER {x-cache-key}
And I send the current request as POST to endpoint {/v1/cache}
When I load the REST request {Cache.json} with profile {successful_set}
And I load value {test} into current request HEADER {x-cache-key}
And I send the Cache POST request via TSA Cache API
And the status code should be {201}
Then I clear the request body
And I send the current request as GET to endpoint {/v1/cache}
And I send the Cache GET request via TSA Cache API
Then the status code should be {200}
And the field {msg} has the value {successful setting the cache}
@negative
Scenario: TSA - Access non existing Cache - Negative
And I store key {key_negative} with value {NEGATIVE} in the data container
And I load object with key {key_negative} from DataContainer into currentRequest HEADER {x-cache-key}
Given I send the current request as GET to endpoint {/v1/cache}
Given I load value {NEGATIVE} into current request HEADER {x-cache-key}
And I send the Cache GET request via TSA Cache API
Then the status code should be {404}
And the response is valid according to the {Cache_negative_schema.json} REST schema
And the field {message} has the value {key not found in cache}
@negative
Scenario: TSA - Access Cache without header x-cache-key - Negative
Given I send the current request as GET to endpoint {/v1/cache}
Given I send the Cache GET request via TSA Cache API
Then the status code should be {400}
And the response is valid according to the {Cache_negative_schema.json} REST schema
And the field {message} has the value {"x-cache-key" is missing from header}
Scenario: TSA - Executing Task with DID resolver and Evaluate the Cache - Positive
Given we are testing the TSA Task Api
When I load the REST request {Policy.json} with profile {did_key}
Then I execute the Task {didResolve} via TSA Task API
Then the status code should be {200}
And I wait for {2000} mseconds
Given we are testing the TSA Cache Api
And I get the value of {taskID} from the last response and store it in the DataContainer with key {taskID}
Then I load object with key {taskID} from DataContainer into currentRequest HEADER {x-cache-key}
When I send the Cache GET request via TSA Cache API
Then the status code should be {200}
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}
\ No newline at end of file
......@@ -31,23 +31,22 @@ Feature: API -TSA - Cache - v1/cache POST
Given we are testing the TSA Cache Api
Scenario: TSA - Setting Cache - Positive
Given I load the REST request {Cache.json} with profile {successful_set}
And I store key {key_positive} with value {test} in the data container
And I load object with key {key_positive} from DataContainer into currentRequest HEADER {x-cache-key}
And I send the current request as POST to endpoint {/v1/cache}
When I load the REST request {Cache.json} with profile {successful_set}
And I load value {test} into current request HEADER {x-cache-key}
And I send the Cache POST request via TSA Cache API
And the status code should be {201}
@negative
Scenario: TSA - Setting Cache with missing header - x-cache-key - Negative
Given I load the REST request {Cache.json} with profile {missing_body}
And I send the current request as POST to endpoint {/v1/cache}
When I load the REST request {Cache.json} with profile {missing_body}
And I send the Cache POST request via TSA Cache API
Then the status code should be {400}
And the response is valid according to the {Cache_negative_schema.json} REST schema
And the field {message} has the value {"x-cache-key" is missing from header}
@negative
Scenario: TSA - Setting Cache with missing body - Negative
And I send the current request as POST to endpoint {/v1/cache}
When I send the Cache POST request via TSA Cache API
Then the status code should be {400}
And the response is valid according to the {Cache_negative_schema.json} REST schema
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