From 81dd847c911eb0a4a2754e57236683755e6968f3 Mon Sep 17 00:00:00 2001 From: rosengeorgiev <rosen.georgiev@vereign.com> Date: Fri, 1 Jul 2022 11:00:41 +0300 Subject: [PATCH] added build folder for reports --- .../api/test/rest/RestSessionContainer.java | 244 +----------------- .../rest/tsa/task/TaskStepDefinitions.java | 39 +-- .../features/tsa/cache/v1/cache/GET.feature | 16 ++ .../tsa/task/v1/task/{taskName}/GET.feature | 18 +- .../tsa/task/v1/task/{taskName}/POST.feature | 2 +- 5 files changed, 49 insertions(+), 270 deletions(-) diff --git a/src/main/java/api/test/rest/RestSessionContainer.java b/src/main/java/api/test/rest/RestSessionContainer.java index fb5d5b29..ce9202ee 100644 --- a/src/main/java/api/test/rest/RestSessionContainer.java +++ b/src/main/java/api/test/rest/RestSessionContainer.java @@ -20,248 +20,14 @@ package api.test.rest; import api.test.rest.pojo.Member; 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; - public String getIdentificator() { - return identificator; + public String getTaskID() { + return taskID; } - public void setIdentificator(String identificator) { - this.identificator = identificator; - } - - public Member getCurrentMember() { - return member; - } - - public void setCurrentMember(Member member) { - this.member = member; - } - - public String getOauthToken() { - return oauthToken; - } - - public void setOauthToken(String oauthToken) { - this.oauthToken = oauthToken; - } - - 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; + public void setTaskID(String taskID) { + this.taskID = taskID; } } diff --git a/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java b/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java index 13373364..c6840c26 100644 --- a/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java @@ -3,6 +3,7 @@ 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.JsonPath; import core.*; import cucumber.api.java.en.And; import cucumber.api.java.en.Given; @@ -40,35 +41,37 @@ public class TaskStepDefinitions extends BaseStepDefinitions{ addResponse(response); } - @Given("^I load the body of my Task request with \\{(.*)\\} from \\{(.*)\\}$") - public void iLoadTheBodyOfMyPolicyRequestWithDataFromFile(String profileName, String jsonName) throws Throwable { - logger.info("Loading REST json into current request body. Json file= [{}] , profile= [{}]", jsonName, profileName); - String loadedProfileData = JsonUtils.getProfileFromJson("/REST/json/" + jsonName, profileName); - if (!loadedProfileData.equals("null")) { - currentRequest.setBody(loadedProfileData); - logger.info("SUCCESS - profile loaded."); - } else { - throw new RAFException(String.format("Profile loading FAILED. Value is \"null\". File= [%s] , profile= [%s]", - jsonName, - profileName) - , RestGeneralStepDefinitions.class); - } - } - - @And("^I execute the Task \\{(.*)\\}$") - public void iExecuteThePolicy(String path) throws Throwable { + @And("^I execute the Task \\{(.*)\\} via TSA Task API$") + public void iExecuteTheTask(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(); + System.out.printf("TESTtt" + restSessionContainer.getTaskID()); + + restSessionContainer.setTaskID(taskId); + + } } @And("^I get the Task result with key \\{(.*)\\}$") public void iGetTheTaskResultWithKey(String suffix) { - currentRequest.setPath("v1/taskResult/"+ getDataContainer().getObject(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); + } } diff --git a/src/test/resources/features/tsa/cache/v1/cache/GET.feature b/src/test/resources/features/tsa/cache/v1/cache/GET.feature index 73840699..6cbdefeb 100644 --- a/src/test/resources/features/tsa/cache/v1/cache/GET.feature +++ b/src/test/resources/features/tsa/cache/v1/cache/GET.feature @@ -54,3 +54,19 @@ Feature: API -TSA - Cache - v1/cache GET 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 + When I load the REST request {Policy.json} with profile {did_key} + And I execute the Task {didResolve} via TSA Task API + Then the status code should be {200} + # Test the Task Result + Then I clear the request body + And I wait for {2000} mseconds + And I get the current Task Result via TSA Task API + Then the status code should be {200} + # Test the Cache Service + Then I load object with key {taskID} from DataContainer into currentRequest HEADER {x-cache-key} + And I send the current request as GET to endpoint {https://gaiax.vereign.com/tsa/cache/v1/cache} + And 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 diff --git a/src/test/resources/features/tsa/task/v1/task/{taskName}/GET.feature b/src/test/resources/features/tsa/task/v1/task/{taskName}/GET.feature index 926774fa..42bf0143 100644 --- a/src/test/resources/features/tsa/task/v1/task/{taskName}/GET.feature +++ b/src/test/resources/features/tsa/task/v1/task/{taskName}/GET.feature @@ -30,22 +30,16 @@ Feature: API -TSA - Task - v1/task GET Background: Given we are testing the TSA Task Api - Scenario: TSA - Executing Task with DID resolver and Evaluate the Cache - Positive - When I load the body of my Task request with {did_key} from {Policy.json} - And I execute the Task {didResolve} + Scenario: TSA - Executing Task with DID resolver and checking the Task Results - Positive + #Execute Task + When I load the REST request {Policy.json} with profile {did_key} + And I execute the Task {didResolve} via TSA Task API Then the status code should be {200} And the response is valid according to the {Task_Execute_schema.json} REST schema - # Test the Task Result - Then I get the value of {taskID} from the last response and store it in the DataContainer with key {taskID} + #GET Task Result Then I clear the request body And I wait for {2000} mseconds - And I get the Task result with key {taskID} + And I get the current Task Result via TSA Task 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} - # Test the Cache Service - Then I load object with key {taskID} from DataContainer into currentRequest HEADER {x-cache-key} - And I send the current request as GET to endpoint {https://gaiax.vereign.com/tsa/cache/v1/cache} - And 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 diff --git a/src/test/resources/features/tsa/task/v1/task/{taskName}/POST.feature b/src/test/resources/features/tsa/task/v1/task/{taskName}/POST.feature index c96d97c5..172828cf 100644 --- a/src/test/resources/features/tsa/task/v1/task/{taskName}/POST.feature +++ b/src/test/resources/features/tsa/task/v1/task/{taskName}/POST.feature @@ -43,7 +43,7 @@ Feature: API -TSA - Task - v1/task POST 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} - @negative + @negative @test Scenario: TSA - Executing Task with non existing task template - Negative When I load the body of my Task request with {did_key} from {Policy.json} And I execute the Task {non_existing} -- GitLab