diff --git a/features/evaluatePolicyGroups.feature b/features/evaluatePolicyGroups.feature deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/features/executeTask.feature b/features/executeTask.feature deleted file mode 100644 index 933802a754cc5b519916eaafb38ae98456faedfa..0000000000000000000000000000000000000000 --- a/features/executeTask.feature +++ /dev/null @@ -1,24 +0,0 @@ -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 diff --git a/src/main/java/api/test/rest/RestSessionContainer.java b/src/main/java/api/test/rest/RestSessionContainer.java index fb5d5b29636967e266b40b43bcb5952a6c4f6131..b5e5261a2a684a1a7bc08dbcf3b3a596b1a33d6f 100644 --- a/src/main/java/api/test/rest/RestSessionContainer.java +++ b/src/main/java/api/test/rest/RestSessionContainer.java @@ -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 diff --git a/src/main/java/core/JsonUtils.java b/src/main/java/core/JsonUtils.java index 2c6828a91eebfe9f026bf24309c7f392ef84e7d6..3a5809bf7402a3a820c3ed7b9304818de2dfdaa7 100644 --- a/src/main/java/core/JsonUtils.java +++ b/src/main/java/core/JsonUtils.java @@ -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 diff --git a/src/main/resources/REST/json/Policy.json b/src/main/resources/REST/json/Policy.json index d7a8debb80dd680e0e10894c5eed8a2e8a5a058d..e1f37e85c589de4b458f6b1a55986a178cfa487a 100644 --- a/src/main/resources/REST/json/Policy.json +++ b/src/main/resources/REST/json/Policy.json @@ -1,17 +1,17 @@ { - "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 diff --git a/src/main/resources/REST/json/Presentation.json b/src/main/resources/REST/json/Presentation.json new file mode 100644 index 0000000000000000000000000000000000000000..d4678bd4a90860d58fca50bb6376a65ee3134ddc --- /dev/null +++ b/src/main/resources/REST/json/Presentation.json @@ -0,0 +1,25 @@ +{ + "@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 diff --git a/src/main/resources/REST/schemas/Signer_GetAllKeys_schema.json b/src/main/resources/REST/schemas/Signer_GetAllKeys_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..3461756d06da316517c27c2c6ad3328b2da7a4ac --- /dev/null +++ b/src/main/resources/REST/schemas/Signer_GetAllKeys_schema.json @@ -0,0 +1,53 @@ +{ + "$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 diff --git a/src/main/resources/REST/schemas/Signer_GetKey_negative_schema.json b/src/main/resources/REST/schemas/Signer_GetKey_negative_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..93ff0d60e9995f883a841950685115a5c15a563a --- /dev/null +++ b/src/main/resources/REST/schemas/Signer_GetKey_negative_schema.json @@ -0,0 +1,16 @@ +{ + "$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 diff --git a/src/main/resources/REST/schemas/Signer_GetKey_schema.json b/src/main/resources/REST/schemas/Signer_GetKey_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..214a754be4af28dd124f54684fe88ecfaea7d0da --- /dev/null +++ b/src/main/resources/REST/schemas/Signer_GetKey_schema.json @@ -0,0 +1,48 @@ +{ + "$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 diff --git a/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json b/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..427c92b10631b053145e5da575828e6f60d0c2e0 --- /dev/null +++ b/src/main/resources/REST/schemas/Signer_PresentationProof_schema.json @@ -0,0 +1,115 @@ +{ + "$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 diff --git a/src/main/resources/REST/schemas/TaskList_Execute_schema.json b/src/main/resources/REST/schemas/TaskList_Execute_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..650a76d5d1db43da9c91706d7395d39ddf74dcdb --- /dev/null +++ b/src/main/resources/REST/schemas/TaskList_Execute_schema.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "taskListID": { + "type": "string" + } + }, + "required": [ + "taskListID" + ] +} \ No newline at end of file diff --git a/src/main/resources/REST/schemas/TaskList_Status_schema.json b/src/main/resources/REST/schemas/TaskList_Status_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..a21feb97fe1b03f94144ae8700e64a7c99862c69 --- /dev/null +++ b/src/main/resources/REST/schemas/TaskList_Status_schema.json @@ -0,0 +1,73 @@ +{ + "$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 diff --git a/src/test/java/api/test/core/GeneralStepDefinitions.java b/src/test/java/api/test/core/GeneralStepDefinitions.java index 884f3822cac104194fbf185240d9c1ab8d734365..3ace023c3f4bf6e4ab37c670de6b61fa3e5eaa10 100644 --- a/src/test/java/api/test/core/GeneralStepDefinitions.java +++ b/src/test/java/api/test/core/GeneralStepDefinitions.java @@ -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 diff --git a/src/test/java/api/test/rest/RestGeneralStepDefinitions.java b/src/test/java/api/test/rest/RestGeneralStepDefinitions.java index ee4e6adab8500f2194012ca867ac2c1a1dc98723..961c5ee48e828be53698f10235080684a7eb0e0c 100644 --- a/src/test/java/api/test/rest/RestGeneralStepDefinitions.java +++ b/src/test/java/api/test/rest/RestGeneralStepDefinitions.java @@ -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); + } + } diff --git a/src/test/java/api/test/rest/tsa/cache/CacheStepDefinitions.java b/src/test/java/api/test/rest/tsa/cache/CacheStepDefinitions.java index 7f854a018d177aa6331668d1bec26f2f575b680f..352cef90a30e5a0819d0004bc0f02557e98144f9 100644 --- a/src/test/java/api/test/rest/tsa/cache/CacheStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/cache/CacheStepDefinitions.java @@ -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); + } } } diff --git a/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java b/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java index 13aa8332e45093c2ce49cda6738433fa6deb4762..fc374d82f53e608dc95737db2d7832c3ed6f7f31 100644 --- a/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java @@ -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); diff --git a/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java b/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java new file mode 100644 index 0000000000000000000000000000000000000000..fb87712776e8d22c677ca9d043434c65bb59478f --- /dev/null +++ b/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java @@ -0,0 +1,54 @@ +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); + } +} 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 9cf0d8f4064220b9c8692e37f7fc7f25b2797d89..8a0967c4978136cdd428062eb7919b9d6db4e8e4 100644 --- a/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/task/TaskStepDefinitions.java @@ -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 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 cbc8a8c30749693b8887634b5f86cb960a337b7d..732bf9f4397d92f4d1feb2befec96aaa88adde8a 100644 --- a/src/test/resources/features/tsa/cache/v1/cache/GET.feature +++ b/src/test/resources/features/tsa/cache/v1/cache/GET.feature @@ -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 diff --git a/src/test/resources/features/tsa/cache/v1/cache/POST.feature b/src/test/resources/features/tsa/cache/v1/cache/POST.feature index f3758f531e21a75abd73dc70376ab1ef4e218a72..7ea0a589a19d413bf76bb84049db52b2f0fefd0a 100644 --- a/src/test/resources/features/tsa/cache/v1/cache/POST.feature +++ b/src/test/resources/features/tsa/cache/v1/cache/POST.feature @@ -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} diff --git a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/evaluation/POST.feature b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/evaluation/POST.feature index 2e6ce3506865ae623ef1311ab5c2ba1b2259a02c..ae395f1a4ddf16f9b40c3111e5088b0447ef411f 100644 --- a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/evaluation/POST.feature +++ b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/evaluation/POST.feature @@ -31,47 +31,46 @@ Feature: API -TSA - Policy - :group/:name/:version/evaluation POST Given we are testing the TSA Policy Api Scenario: TSA - Evaluate policy synchronously - Positive - Given I load the REST request {Policy.json} with profile {successful_evaluate} - And I execute the policy {/policy/example/test/1.0/evaluation} + When I load the REST request {Policy.json} with profile {successful_message} + And I execute the Policy group {example} name {test} version {1.0} via TSA Policy API Then the status code should be {200} And the response is valid according to the {Policy_Evaluate_schema.json} REST schema And the field {allow} has the value {true} - @bug-policy-35 Scenario: TSA - DID resolution - Positive - Given I load the REST request {Policy.json} with profile {didResolve_evaluate} - And I execute the policy {/policy/example/resolve/1.0/evaluation} + When I load the REST request {Policy.json} with profile {did_key} + And I execute the Policy group {example} name {resolve} version {1.0} via TSA Policy API Then the status code should be {200} And the response is valid according to the {Policy_EvaluateDID_schema.json} REST schema And the field {data.didDocument.id} has the value {did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6} @negative Scenario: TSA - Evaluate policy with incorrect value - Negative - Given I load the REST request {Policy.json} with profile {unsuccessful_evaluate} - And I execute the policy {/policy/example/test/1.0/evaluation} + When I load the REST request {Policy.json} with profile {incorrect_message} + And I execute the Policy group {example} name {test} version {1.0} via TSA Policy API Then the status code should be {200} And the response is valid according to the {Policy_Evaluate_schema.json} REST schema And the field {allow} has the value {false} @negative Scenario: TSA - Evaluate policy with missing body- Negative - Given I execute the policy {/policy/example/test/1.0/evaluation} + And I execute the Policy group {example} name {test} version {1.0} via TSA Policy API Then the status code should be {200} And the response is valid according to the {Policy_Evaluate_schema.json} REST schema And the field {allow} has the value {false} @negative Scenario: TSA - Evaluate missing policy - Negative - Then I load the REST request {Policy.json} with profile {successful_evaluate} - Given I execute the policy {/policy/testable/test0/1.0/evaluation} + When I load the REST request {Policy.json} with profile {successful_message} + And I execute the Policy group {example} name {missing} version {1.0} via TSA Policy API Then the status code should be {404} And the response is valid according to the {Policy_Evaluate_negative_schema.json} REST schema And the field {message} has the value {error evaluating policy} - @negative @bug-policy-35 + @negative Scenario: TSA - DID resolution with incorrect did - Negative - Then I load the REST request {Policy.json} with profile {didResolve_missing_method} - And I execute the policy {/policy/example/resolve/1.0/evaluation} + When I load the REST request {Policy.json} with profile {did_missing_method} + And I execute the Policy group {example} name {resolve} version {1.0} via TSA Policy API Then the status code should be {200} And the response is valid according to the {Policy_EvaluateDID_negative_schema.json} REST schema And the field {data.didResolutionMetadata.error} has the value {notFound} diff --git a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/DELETE.feature b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/DELETE.feature index 98592b36e4e7529297646de59512ac6ed8515d5b..e1a91103e0f969ad41eecfc7a3b7ea9439119e50 100644 --- a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/DELETE.feature +++ b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/DELETE.feature @@ -26,12 +26,16 @@ Feature: API - TSA - Policy - :group/:name/:version/lock DELETE Given we are testing the TSA Policy Api Scenario: TSA - Unlock policy - Positive - When I lock the policy {/policy/example/test/1.0/lock} - And I unlock the policy {/policy/example/test/1.0/lock} + When I lock the Policy group {example} name {test} version {1.0} + And I unlock the policy group {example} name {test} version {1.0} And the status code should be {200} + # Check if the policy can be executed + When I load the REST request {Policy.json} with profile {successful_message} + And I execute the Policy group {example} name {test} version {1.0} via TSA Policy API + Then the status code should be {200} @negative Scenario: TSA - Unlock none existing policy - Negative - When I unlock the policy {/policy/example/non_existing/1.0/lock} + And I unlock the policy group {example} name {non_existing} version {1.0} And the status code should be {404} And the field {message} has the value {policy not found} diff --git a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/POST.feature b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/POST.feature index 5aea20e16541f864122a3c069937c15306c0bbf7..6b904c34f57db71442a7545a1c27bd8167867d2b 100644 --- a/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/POST.feature +++ b/src/test/resources/features/tsa/policy/policy/{group}/{name}/{version}/lock/POST.feature @@ -31,20 +31,18 @@ Feature: API - TSA -Policy - :group/:name/:version/lock POST Given we are testing the TSA Policy Api Scenario: TSA - Lock policy - Positive - When I lock the policy {/policy/example/test/1.0/lock} + When I lock the Policy group {example} name {test} version {1.0} Then the status code should be {200} - When I load the REST request {Policy.json} with profile {successful_evaluate} - And I execute the policy {/policy/example/test/1.0/evaluation} + When I load the REST request {Policy.json} with profile {successful_message} + And I execute the Policy group {example} name {test} version {1.0} via TSA Policy API Then the status code should be {403} - And I lock the policy {/policy/example/test/1.0/lock} - And the status code should be {403} - And the field {message} has the value {policy is already locked} - And I unlock the policy {/policy/example/test/1.0/lock} + And the field {message} has the value {error evaluating policy} + And I unlock the policy group {example} name {test} version {1.0} @negative Scenario: TSA - Lock already locked policy - Negative - When I lock the policy {/policy/example/test/1.0/lock} - And I lock the policy {/policy/example/test/1.0/lock} + When I lock the Policy group {example} name {test} version {1.0} + When I lock the Policy group {example} name {test} version {1.0} And the status code should be {403} And the field {message} has the value {policy is already locked} - And I unlock the policy {/policy/example/test/1.0/lock} + And I unlock the policy group {example} name {test} version {1.0} diff --git a/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature b/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature new file mode 100644 index 0000000000000000000000000000000000000000..5e35cf3e2fe852154eda496902871bdddf8f7d1e --- /dev/null +++ b/src/test/resources/features/tsa/signer/v1/issuerDID/GET.feature @@ -0,0 +1,31 @@ +#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/issuerDID +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @signer +Feature: API - TSA - Signer Issuer DID - v1/keys GET + As user + I want to see who is the issuer of the keys + So I am better informed + + Background: + Given we are testing the TSA Signer Api + + Scenario: TSA - Getting Issuer DID - Positive + When I get issuer DID via TSA Signer API + And the status code should be {200} + And the field {did} has the value {did:web:gaiax.vereign.com:tsa:policy:policy:example:returnDID:1.0:evaluation} \ No newline at end of file diff --git a/src/test/resources/features/tsa/signer/v1/keys/GET.feature b/src/test/resources/features/tsa/signer/v1/keys/GET.feature new file mode 100644 index 0000000000000000000000000000000000000000..2ff98c1ac19d76a9c8fa00904693e4fdc6286e39 --- /dev/null +++ b/src/test/resources/features/tsa/signer/v1/keys/GET.feature @@ -0,0 +1,47 @@ +#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/keys +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @signer +Feature: API - TSA - Signer keys - v1/keys GET + As user + I want to see what keys are available + So I am able to use them the future + + Background: + Given we are testing the TSA Signer Api + + Scenario: TSA - Getting all keys from Singer - Positive + When I get all keys via TSA Signer API + And the status code should be {200} + And the response is valid according to the {Signer_GetAllKeys_schema.json} REST schema + And the field {$..type} has the value {["JsonWebKey2020","JsonWebKey2020"]} + And the field {$..publicKeyJwk.kid} has the value {["key1","key2"]} + And the field {$..publicKeyJwk.crv} has the value {["P-256","Ed25519"]} + + Scenario: TSA - Getting key1 from Singer - Positive + When I get key {key1} via TSA Signer API + And the status code should be {200} + And the response is valid according to the {Signer_GetKey_schema.json} REST schema + And the field {type} has the value {JsonWebKey2020} + And the field {publicKeyJwk.kid} has the value {key1} + And the field {publicKeyJwk.crv} has the value {P-256} + + Scenario: TSA - Getting non existing key - Negative + When I get key {non_existing} via TSA Signer API + And the response is valid according to the {Signer_GetKey_negative_schema.json} REST schema + And the status code should be {404} diff --git a/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature b/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature new file mode 100644 index 0000000000000000000000000000000000000000..84af1aa993b73986a93ac9815157d77514daaeba --- /dev/null +++ b/src/test/resources/features/tsa/signer/v1/presentation/proof/POST.feature @@ -0,0 +1,40 @@ +#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/proof +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @signer +Feature: API - TSA - Signer presentation proof - v1/presentation/proof POST + As user + I want to check a presentation proof + So I am sure it is valid + + Background: + Given we are testing the TSA Signer Api + + Scenario: TSA - validate presentation proof - Positive + When I load the request from json {/REST/json/Presentation.json} + When I validate presentation proof via TSA Signer API + And the status code should be {200} + 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} + + @wip @bug-signer-#13 + Scenario: TSA - validate presentation proof with empty body - Negative + When I set the following request body {{}} + When I validate presentation proof via TSA Signer API + And the status code should be {400} + And the field {message} has the value {missing required payload} diff --git a/src/test/resources/features/tsa/task/v1/task/taskListStatus/GET.feature b/src/test/resources/features/tsa/task/v1/task/taskListStatus/GET.feature new file mode 100644 index 0000000000000000000000000000000000000000..4cc18d898b0a84345398f1d3b55084c8e6ab5479 --- /dev/null +++ b/src/test/resources/features/tsa/task/v1/task/taskListStatus/GET.feature @@ -0,0 +1,66 @@ +#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/>. + +#http://gaiax.vereign.com/tsa/task/v1/taskListStatus +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @task +Feature: API -TSA - Task - v1/taskList GET + As user + I want to execute the list of tasks + So I am able to bring the consistency to running multiple asynchronous tasks + + Background: + Given we are testing the TSA Task Api + + Scenario: TSA - Get status from Task List execution - Positive + When I load the REST request {Policy.json} with profile {did_key} + And I execute the taskList {testList} via TSA Task API + Then the status code should be {200} + And the response is valid according to the {TaskList_Execute_schema.json} REST schema + And I wait for {1000} mseconds + Then I get the current taskList Status via TSA Task API + Then the status code should be {200} + Then I get the current taskList Status via TSA Task API + And the response is valid according to the {TaskList_Status_schema.json} REST schema + And the field {status} has the value {done} + And the field {$..tasks..status} has the value {["done","done"]} + + Scenario: TSA - Get status from Task List with three synchronous tasks second fails - Negative + When I set the following request body {{}} + And I execute the taskList {failTestListSync} via TSA Task API + Then the status code should be {200} + And the response is valid according to the {TaskList_Execute_schema.json} REST schema + And I wait for {1000} mseconds + Then I get the current taskList Status via TSA Task API + Then the status code should be {207} + Then I get the current taskList Status via TSA Task API + And the response is valid according to the {TaskList_Status_schema.json} REST schema + And the field {status} has the value {failed} + And the field {$..tasks..status} has the value {["done","failed","failed"]} + + Scenario: TSA - Get status from Task List with three asynchronous tasks second fails - Negative + When I set the following request body {{}} + And I execute the taskList {failTestListAsync} via TSA Task API + Then the status code should be {200} + And the response is valid according to the {TaskList_Execute_schema.json} REST schema + And I wait for {1000} mseconds + Then I get the current taskList Status via TSA Task API + Then the status code should be {207} + Then I get the current taskList Status via TSA Task API + And the response is valid according to the {TaskList_Status_schema.json} REST schema + And the field {status} has the value {failed} + And the field {$..tasks..status} has one of the values + | ["done","failed","done"] | ["failed","done","done"] | ["done","done","failed"] | \ No newline at end of file diff --git a/src/test/resources/features/tsa/task/v1/task/taskResult/GET.feature b/src/test/resources/features/tsa/task/v1/task/taskResult/GET.feature new file mode 100644 index 0000000000000000000000000000000000000000..fc627ff199bcef5bcbbd0c024bc470652bcf4c14 --- /dev/null +++ b/src/test/resources/features/tsa/task/v1/task/taskResult/GET.feature @@ -0,0 +1,55 @@ +#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/>. + +#http://gaiax.vereign.com/tsa/task/v1/taskResult +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @task +Feature: API -TSA - Task - v1/taskList GET + As user + I want to execute the list of tasks + So I am able to bring the consistency to running multiple asynchronous tasks + + Background: + Given we are testing the TSA Task Api + + 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 + #GET 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} + 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} + + Scenario: TSA - Get result from Task List with two synchronous tasks - Positive + When I set the following request body {{}} + And I execute the taskList {testList} via TSA Task API + Then the status code should be {200} + And the response is valid according to the {TaskList_Execute_schema.json} REST schema + And I wait for {1000} mseconds + Then I get the current taskList Status via TSA Task API + And the status code should be {200} + And I get the result of Task {0} + And the status code should be {200} + And I get the result of Task {1} + And the status code should be {200} + And the response is valid according to the {Policy_EvaluateDID_schema.json} REST schema + And the field {data.didDocument.id} has the value {did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6} 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 1ee887627188163aba4c2116b8d807e0427e1e2c..acab16840491af7aa94561b8a4ad0b7c2519dbbd 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,23 +30,8 @@ Feature: API -TSA - Task - v1/task GET Background: Given we are testing the TSA Task Api - @bug-policy-35 - Scenario: TSA - Executing Task with DID resolver and Evaluate the Cache - Positive - Given I load the REST request {Policy.json} with profile {didResolve_evaluate} - And I send the current request as POST to endpoint {/v1/task/didResolve} + Scenario: TSA - Executing Task with DID resolver - 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} - 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} - Then I clear the request body - And I wait for {2000} mseconds - And I send the current request to endpoint {v1/taskResult} with container value{taskID} - 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 + And the response is valid according to the {Task_Execute_schema.json} REST schema \ 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 bd1a4e3550c980b6ec5045e1f31676f5a3ef53e1..e7fcb0244ca3e4fea71c5cb1944e579e47ea54e7 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 @@ -30,23 +30,32 @@ Feature: API -TSA - Task - v1/task POST Background: Given we are testing the TSA Task Api - @bug-policy-35 Scenario: TSA - Executing Task with DID resolver - Positive - Then I load the REST request {Policy.json} with profile {didResolve_evaluate} - And I send the current request as POST to endpoint {/v1/task/didResolve} + 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 - Then I get the value of {taskID} from the last response and store it in the DataContainer with key {taskID} Then I clear the request body And I wait for {2000} mseconds - And I send the current request to endpoint {v1/taskResult} with container value{taskID} - Then the status code should be {200} + Then I get the current Task Result via TSA Task API + 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} + Scenario: TSA - Executing Task with method and url - Positive + When I set the following request body {{"message": "hello"}} + And I execute the Task {exampleTask} 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 + And I wait for {2000} mseconds + And I clear the request body + Then I get the current Task Result via TSA Task API + And the status code should be {200} + And the field {title} has the value {delectus aut autem} + @negative Scenario: TSA - Executing Task with non existing task template - Negative - Then I load the REST request {Policy.json} with profile {didResolve_evaluate} - And I send the current request as POST to endpoint {/v1/task/resolve} + When I load the REST request {Policy.json} with profile {did_key} + And I execute the Task {non_existing} via TSA Task API Then the response is valid according to the {Policy_Evaluate_negative_schema.json} REST schema And the field {message} has the value {task template not found} diff --git a/src/test/resources/features/tsa/task/v1/taskList/{listName}/POST.feature b/src/test/resources/features/tsa/task/v1/taskList/{listName}/POST.feature new file mode 100644 index 0000000000000000000000000000000000000000..5267ce919c2b9bea9ec7fa2f586deac8d9ebb4ec --- /dev/null +++ b/src/test/resources/features/tsa/task/v1/taskList/{listName}/POST.feature @@ -0,0 +1,32 @@ +#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/>. + +#http://gaiax.vereign.com/tsa/task/v1/taskList +#Author: Georgi Michev georgi.michev@vereign.com + +@rest @all @tsa @task +Feature: API -TSA - Task - v1/taskList POST + As user + I want to execute the list of tasks + So I am able to bring the consistency to running multiple asynchronous tasks + + Background: + Given we are testing the TSA Task Api + + Scenario: TSA - Executing Task List with two synchronous tasks - Positive + When I load the REST request {Policy.json} with profile {did_key} + And I execute the taskList {testList} via TSA Task API + Then the status code should be {200} + And the response is valid according to the {TaskList_Execute_schema.json} REST schema \ No newline at end of file