diff --git a/.gitignore b/.gitignore index 2d40710b6499cf6e3b567fd2c009f426f6597f0a..2ccbd780b2355b4c7683909abf310eb7c80cd2bb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ bin local.properties logs QA.log +out # Java # Compiled class file diff --git a/README.md b/README.md index 4765231c63b286da2fb263d5c787d25fba1233e4..c5e059789ad428e61cf7d6255bb433a236e20d4c 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,19 @@ 1. [Introduction](#introduction) 1. [Setup](#setup) 1. [Description](#description) -1. [License](#license) + # Introduction -This repository holds the test automation framework based on Java and used for testing of [Dashboard]() and [RESTful API](). +This repository holds the test automation framework based on Java and used for testing TSA # Setup ### Prerequisites -- Install Java > 8 - https://www.java.com/en/download/help/download_options.xml +- Install Java version > 17 -- Install gradle - https://gradle.org/install/ +- Install gradle version > 7.4.1 - https://gradle.org/install/ - Favorite IDE (I recommend IntelliJ IDEA - https://www.jetbrains.com/idea/) @@ -23,15 +23,4 @@ This repository holds the test automation framework based on Java and used for t ### Running -- Run configuration for local example: - ```-Ptags=@test,~@wip``` - ```-Penv="local"``` -- Run the tests on a remote env: ```gradle cucumber -Penv=local -Ptags=@rest,~@wip``` - -# Contributions - -Big up for rosen.georgiev@vereign.com - -## License - -This project is licensed under the AGPL License - see the [LICENSE](/code/Documentation/wikis/LICENSE) file for details. \ No newline at end of file +- Run the tests on a remote env: ```gradle regressionSuite -PbaseUrl=https://TestEnv -Dcucumber.tags="@rest, ~@wip" -Dcourgette.threads=10 -Dcourgette.runLevel=Scenario -Dcourgette.rerunFailedScenarios=false -Dcourgette.rerunAttempts=1``` \ No newline at end of file diff --git a/build.gradle b/build.gradle index 41beeeb63988debfc71d25026adc3ff4a180bcad..9b5d8139788f4d274369592849a677bffaf39bf7 100644 --- a/build.gradle +++ b/build.gradle @@ -83,8 +83,8 @@ dependencies { implementation(group: "com.google.code.gson", name: "gson", version: "+") implementation(group: "io.rest-assured", name: "rest-assured", version: "4.+") implementation(group: "com.jayway.jsonpath", name: "json-path", version: "+") - implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5' - implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5' + implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '+' + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '+' implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60' implementation 'org.bouncycastle:bcpkix-jdk15on:1.51' implementation group: 'net.sourceforge.tess4j', name: 'tess4j', version: '4.4.1' diff --git a/src/test/java/api/test/rest/batch/BatchStepDefinitions.java b/src/test/java/api/test/rest/batch/BatchStepDefinitions.java deleted file mode 100644 index a9f21e88cbcc35d475301328ca49ac4f3aabf223..0000000000000000000000000000000000000000 --- a/src/test/java/api/test/rest/batch/BatchStepDefinitions.java +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright (c) 2018 Vereign AG [https://www.vereign.com] - -This is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -package api.test.rest.batch; - -import api.test.core.BaseStepDefinitions; -import api.test.rest.RestSessionContainer; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.jayway.jsonpath.JsonPath; -import core.DataContainer; -import core.Request; -import core.Response; -import core.RestClient; -import cucumber.api.java.en.Given; -import cucumber.api.java.en.Then; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import utils.RAFRandomize; -import java.util.Base64; -import static org.junit.Assert.assertTrue; - -public class BatchStepDefinitions extends BaseStepDefinitions { - private static final Logger logger = LogManager.getLogger(BatchStepDefinitions.class.getSimpleName()); - RestSessionContainer restSessionContainer; - Request currentRequest; - - public BatchStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) { - super(dataContainer); - this.restSessionContainer = restSessionContainer; - this.currentRequest = currentRequest; - } - - @Given("^I send a new batch request via API$") - public void I_send_a_new_batch_request_via_API() { - currentRequest.setPath("/sendBatch"); - - Response response = RestClient.post(currentRequest); - addRequest(currentRequest); - addResponse(response); - } - - @Given("^I call getStatuses request via API$") - public void I_call_getStatuses_request_via_API() { - currentRequest.setPath("/getStatuses"); - - Response response = RestClient.post(currentRequest); - addRequest(currentRequest); - addResponse(response); - } - - @Then("^I assert that getStatus status is the same as the sendBatch value via API$") - public void I_assert_that_getStatus_status_is_the_same_as_the_sendBatch_value_via_API() { - String responseBody = getLastResponse().getBody(); - if (restSessionContainer.getBatchValue() != null) { - String actualValue = JsonPath.read(responseBody, "$..Status").toString(); - assertTrue("'Batch Value' doesn't match expected claim: ", actualValue.contains(restSessionContainer.getBatchValue())); - } - } - - - @Given("^I call getStatuses with the current (sealKey|sealKey2) via API$") - public void I_call_getStatuses_with_the_current_sealKey_via_API(String sealKey) { - Gson gson = new Gson(); - JsonElement initialBody = gson.fromJson(currentRequest.getBody(), JsonElement.class); - // only try to load body as JsonObject if it is not null. - JsonObject newBody = new JsonObject(); - if (initialBody != null) newBody = initialBody.getAsJsonObject(); - - switch (sealKey) { - case "sealKey": - newBody.addProperty("key", restSessionContainer.getBatchKey()); - break; - case "sealKey2": - newBody.addProperty("key", restSessionContainer.getBatchKey2()); - break; - } - - currentRequest.setBody(gson.toJson(newBody)); - - I_call_getStatuses_request_via_API(); - } - - @Given("^I send a new random batch request via API$") - public void I_send_a_new_random_batch_request_via_API() throws Throwable { - String originalInput = "batchValue+" + RAFRandomize.getAlphabetic(5, 5); - String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes()); - restSessionContainer.setBatchValue(encodedString); - - String batchKey = "seal_id_" + RAFRandomize.getAlphabetic(8, 8); - restSessionContainer.setBatchKey(batchKey); - - Gson gson = new Gson(); - JsonElement initialBody = gson.fromJson(currentRequest.getBody(), JsonElement.class); - // only try to load body as JsonObject if it is not null. - JsonObject newBody = new JsonObject(); - JsonObject batch = new JsonObject(); - if (initialBody != null) newBody = initialBody.getAsJsonObject(); - batch.addProperty(batchKey, encodedString); - newBody.add("batch", batch); - currentRequest.setBody(gson.toJson(newBody)); - - I_send_a_new_batch_request_via_API(); - } - - @Given("^I send a new random batch request with 2 objects via API$") - public void I_send_a_new_random_batch_request_with_2_objects_via_API() throws Throwable { - String originalInput = "batchValue+" + RAFRandomize.getAlphabetic(5, 5); - String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes()); - restSessionContainer.setBatchValue(encodedString); - - String batchKey = "seal_id_" + RAFRandomize.getAlphabetic(8, 8); - String batchKey2 = "seal_id_" + RAFRandomize.getAlphabetic(8, 8); - restSessionContainer.setBatchKey(batchKey); - restSessionContainer.setBatchKey2(batchKey2); - - Gson gson = new Gson(); - JsonElement initialBody = gson.fromJson(currentRequest.getBody(), JsonElement.class); - // only try to load body as JsonObject if it is not null. - JsonObject newBody = new JsonObject(); - JsonObject batch = new JsonObject(); - if (initialBody != null) newBody = initialBody.getAsJsonObject(); - batch.addProperty(batchKey, encodedString); - batch.addProperty(batchKey2, encodedString); - newBody.add("batch", batch); - currentRequest.setBody(gson.toJson(newBody)); - - I_send_a_new_batch_request_via_API(); - } - - @Given("^I send a total count request via API$") - public void I_send_a_total_count_request_via_API() { - currentRequest.setPath("/getTotalCount"); - - Response response = RestClient.post(currentRequest); - addRequest(currentRequest); - addResponse(response); - } - -} \ No newline at end of file diff --git a/src/test/resources/features/batch/api/getStatuses/POST.feature b/src/test/resources/features/batch/api/getStatuses/POST.feature deleted file mode 100644 index beff4258066ed6153cabd7c0870ea0aaae4b9090..0000000000000000000000000000000000000000 --- a/src/test/resources/features/batch/api/getStatuses/POST.feature +++ /dev/null @@ -1,91 +0,0 @@ -#Copyright (c) 2018 Vereign AG [https://www.vereign.com] -# -#This is free software: you can redistribute it and/or modify -#it under the terms of the GNU Affero General Public License as -#published by the Free Software Foundation, either version 3 of the -#License, or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU Affero General Public License for more details. -# -#You should have received a copy of the GNU Affero General Public License -#along with this program. If not, see <http://www.gnu.org/licenses/>. - -#http://localhost/api/getStatuses -#Author: Rosen Georgiev rosen.georgiev@vereign.com - -@rest @batch @all -Feature: API - getStatuses POST - Get the previously added Batches - - Background: - Given we are testing the VIAM Api - - @getStatuses @test - Scenario: Send a batch request and then fetch it with getStatuses - Positive -#Send Batch - Given I load the REST request {Batch.json} with profile {successful_batch} - Given I send a new random batch request via API - And the status code should be {200} -#Get Statuses - Then I wait for {60000} mseconds - Given I clear the request body - Then I call getStatuses with the current sealKey via API - And the status code should be {200} - And the field {$.status} has the value {OK} - And the field {$.code} has the value {200} - And the response is valid according to the {Batch_GetStatuses_schema.json} REST schema - And I assert that getStatus status is the same as the sendBatch value via API - - @getStatuses @negative - Scenario Outline: Try to call getStatuses with invalid request - <profile> - Negative -#Get Statuses - Given I clear the request body - Given I load the REST request {Batch.json} with profile {<profile>} - Then I call getStatuses request via API - And the status code should be {400} - And the field {$.message} has the value {<msg>} - Examples: - | profile | msg | - | getStatuses_missing_key | sealID (key) is missing | - | getStatuses_missing_value | sealID (key) is missing | - | getStatuses_empty | sealID (key) is missing | - - @sendbatch - Scenario: Send a batch requests with 2 objects and then get them - Positive -#Send Batch - Given I load the REST request {Batch.json} with profile {successful_batch} - Then I send a new random batch request with 2 objects via API - And the status code should be {200} - And the field {message} has the value {batch is queued} -#Get Statuses of seal key 1 - Then I wait for {60000} mseconds - Given I clear the request body - Then I call getStatuses with the current sealKey via API - And the status code should be {200} - And the response is valid according to the {Batch_GetStatuses_schema.json} REST schema - And I assert that getStatus status is the same as the sendBatch value via API -#Get Statuses of seal key 2 - Given I clear the request body - Then I call getStatuses with the current sealKey2 via API - And the status code should be {200} - And the response is valid according to the {Batch_GetStatuses_schema.json} REST schema - And I assert that getStatus status is the same as the sendBatch value via API - - @sendbatch - Scenario: Send 2 separate batch requests for the same key and then get them - Positive -#Send Batch - Given I load the REST request {Batch.json} with profile {successful_batch} - Given I send a new random batch request via API - And the status code should be {200} - Then I send a new batch request via API - And the status code should be {200} - And the field {message} has the value {batch is queued} -#Get Statuses - Then I wait for {120000} mseconds - Given I clear the request body - Then I call getStatuses with the current sealKey via API - And the status code should be {200} - And the field {$..Status} contains {2} elements \ No newline at end of file diff --git a/src/test/resources/features/batch/api/getTotalCount/POST.feature b/src/test/resources/features/batch/api/getTotalCount/POST.feature deleted file mode 100644 index adcef82bab203cf994fa7f1110c52aa6bfe622a7..0000000000000000000000000000000000000000 --- a/src/test/resources/features/batch/api/getTotalCount/POST.feature +++ /dev/null @@ -1,41 +0,0 @@ -#Copyright (c) 2018 Vereign AG [https://www.vereign.com] -# -#This is free software: you can redistribute it and/or modify -#it under the terms of the GNU Affero General Public License as -#published by the Free Software Foundation, either version 3 of the -#License, or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU Affero General Public License for more details. -# -#You should have received a copy of the GNU Affero General Public License -#along with this program. If not, see <http://www.gnu.org/licenses/>. - -#http://localhost/api/sendbatch -#Author: Georgi Michev georgi.michev@vereign.como - -@rest @batch @all -Feature: API - getTotalCount POST - Retrieve counters for processed seal statuses and batches - - Background: - Given we are testing the VIAM Api - - @getTotalCount - Scenario: Send request with empty body - Positive - #Send Request - Given I send a total count request via API - And the status code should be {200} - And the response is valid according to the {Batch_GetTotalCount_schema.json} REST schema - And the field {data} is present and not empty - And the field {data} is not equal to the value {0} - And the field {receivedStatus} is present and not empty - And the field {receivedStatus} is not equal to the value {0} - And the field {storedStatus} is present and not empty - And the field {storedStatus} is not equal to the value {0} - And the field {anchoredStatus} is present and not empty - And the field {anchoredStatus} is not equal to the value {0} - And the field {anchoredBatches} is present and not empty - And the field {anchoredBatches} is not equal to the value {0} diff --git a/src/test/resources/features/batch/api/sendBatch/POST.feature b/src/test/resources/features/batch/api/sendBatch/POST.feature deleted file mode 100644 index 005ee34866dd37d73ad61bfb7e784fbad880e48d..0000000000000000000000000000000000000000 --- a/src/test/resources/features/batch/api/sendBatch/POST.feature +++ /dev/null @@ -1,61 +0,0 @@ -#Copyright (c) 2018 Vereign AG [https://www.vereign.com] -# -#This is free software: you can redistribute it and/or modify -#it under the terms of the GNU Affero General Public License as -#published by the Free Software Foundation, either version 3 of the -#License, or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU Affero General Public License for more details. -# -#You should have received a copy of the GNU Affero General Public License -#along with this program. If not, see <http://www.gnu.org/licenses/>. - -#http://localhost/api/sendbatch -#Author: Rosen Georgiev rosen.georgiev@vereign.com - -@rest @batch @all -Feature: API - sendBatch POST - This all sends batch request - - Background: - Given we are testing the VIAM Api - - @sendbatch - Scenario: Send a new random batch - Positive -#Send Batch - Given I load the REST request {Batch.json} with profile {successful_batch} - Given I send a new random batch request via API - And the status code should be {200} - And the field {message} has the value {batch is queued} - - @sendbatch - Scenario: Send 2 batch requests for the same key - Positive -#Send Batch - Given I load the REST request {Batch.json} with profile {successful_batch} - Given I send a new random batch request via API - And the status code should be {200} - Then I send a new batch request via API - And the status code should be {200} - And the field {message} has the value {batch is queued} - - @sendbatch @negative - Scenario Outline: Try to send invalid batch requests for sendBatch - <profile> - Negative -#Send Batch - Given I load the REST request {Batch.json} with profile {<profile>} - Given I send a new batch request via API - And the status code should be {<code>} - And the field {message} has the value {<message>} - And the field {kind} has the value {<kind>} - And the field {id} is present and not empty - Examples: - | profile | message | code | kind | - | missing_batch | no status entries to process | 400 | 1 | - | empty_seal_key | invalid batch | 400 | 1 | - | empty_seal_value | invalid batch | 400 | 1 | - | missing_seal | no status entries to process | 400 | 1 | - | not_base64_value | invalid batch | 400 | 1 | - -