diff --git a/src/main/java/api/test/rest/RestSessionContainer.java b/src/main/java/api/test/rest/RestSessionContainer.java index fb5d5b29636967e266b40b43bcb5952a6c4f6131..ce9202eec24b1d3dceb8276e7c4b4d7f4f936f47 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 133733643c5b45b9e342a24f3ef4c80b100b528a..c6840c262db54fe5952b9b73e620c96b3ed99c35 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 73840699f60535f263d85b54938f8b0c0bfd074f..6cbdefebdccf7b4a4b7c392c6ac0ed21c68274c5 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 926774fa16eb241b5e737498f6c044cf9d3a23cf..42bf0143661334cfb695f3edb6ee96b976803bff 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 c96d97c5c0dd59aa34a12f2ea66979201840ad5d..172828cfa7a8045dbe7351212a197090a43e2839 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}