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

added build folder for reports

parent b96fd791
No related branches found
No related tags found
1 merge request!9added build folder for reports
.gradle .gradle
.idea .idea
build
logs logs
.classpath .classpath
.project .project
......
...@@ -229,55 +229,13 @@ public class JsonUtils { ...@@ -229,55 +229,13 @@ public class JsonUtils {
/** /**
* Get the url for "viam" * Get the url for "TSA policy"
* @return the uri * @return the uri
*/ */
public static String getVIAM() { public static String getTSAPolicy() {
return System.getProperty("baseUrl") + "/api"; return System.getProperty("baseUrl") + "/policy";
} }
/**
* Get the url for "cardDav"
* @return the uri
*/
public static String getCardDav() {
return System.getProperty("baseUrl") + "/carddav";
}
/**
* Get the url for "wopi"
* @return the uri
*/
public static String getWopi() {
return System.getProperty("baseUrl") + "/wopi";
}
/**
* Get the url for "webDav"
* @return the uri
*/
public static String getWebDav() {
return System.getProperty("baseUrl")+ "/webdav";
}
/**
* Get the url for "webDav"
* @return the uri
*/
public static String getJsProxy() {
return System.getProperty("baseUrl")+ "/proxy";
}
/**
* Get the url for "Dashboard"
* @return the uri
*/
public static String getDashboard() {
return System.getProperty("baseUrl");
}
/** /**
* UTF8 encodes a string * UTF8 encodes a string
* *
......
...@@ -52,63 +52,16 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions { ...@@ -52,63 +52,16 @@ public class RestGeneralStepDefinitions extends BaseStepDefinitions {
} }
@Given("^we are testing the VIAM Api") @Given("^we are testing the TSA Policy Api")
public void we_are_testing_the_VIAM_api() throws Throwable { public void we_are_testing_the_Policy_api() throws Throwable {
RestClient.setDefaultEncoding("UTF8"); RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getVIAM()); RestClient.setBaseURI(JsonUtils.getTSAPolicy());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false); RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear(); currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework"); currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json"); currentRequest.setContentType("application/json");
} }
@Given("^we are testing the CardDav$")
public void we_are_testing_the_CardDav() throws Throwable {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getCardDav());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.clear();
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/xml");
}
@Given("^we are testing the WOPI")
public void we_are_testing_the_WOPI_service() throws Throwable {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getWopi());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
}
@Given("^we are testing the WebDav")
public void we_are_testing_the_WebDav_service() throws Throwable {
RestClient.setDefaultEncoding("UTF8");
RestClient.setBaseURI(JsonUtils.getWebDav());
RestClient.appendDefaultContentCharsetToContentTypeIfUndefined(false);
currentRequest.getHeaders().put("X-Client-UserAgent", "test framework");
currentRequest.setContentType("application/json");
}
@Given("^we are testing with the current session the WOPI$")
public void we_are_testing_with_the_current_session_the_WOPI() throws Throwable {
currentRequest.clear();
currentRequest.getHeaders().put("publicKey", restSessionContainer.getPublicKey());
currentRequest.getHeaders().put("uuid", restSessionContainer.getOauthUUID());
currentRequest.getHeaders().put("token", restSessionContainer.getOauthToken());
we_are_testing_the_WOPI_service();
}
@Given("^we are testing with the current session the WebDav$")
public void we_are_testing_with_the_current_session_the_WebDav() throws Throwable {
currentRequest.clear();
currentRequest.getHeaders().put("publicKey", restSessionContainer.getPublicKey());
currentRequest.getHeaders().put("uuid", restSessionContainer.getOauthUUID());
currentRequest.getHeaders().put("token", restSessionContainer.getOauthToken());
currentRequest.getHeaders().put("passportuuid", restSessionContainer.getPassportEntityUUID());
we_are_testing_the_WebDav_service();
}
@Given("^I load the REST request \\{(.*)\\} with profile \\{(.*)\\}$") @Given("^I load the REST request \\{(.*)\\} with profile \\{(.*)\\}$")
public void I_load_the_REST_request__with_profile_(String jsonName, String profileName) throws Throwable { 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); logger.info("Loading REST json into current request body. Json file= [{}] , profile= [{}]", jsonName, profileName);
......
/*
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
#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
#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 |
...@@ -13,29 +13,17 @@ ...@@ -13,29 +13,17 @@
#You should have received a copy of the GNU Affero General Public License #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/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#http://localhost/api/sendbatch #http://localhost/policy
#Author: Georgi Michev georgi.michev@vereign.como #Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @batch @all @rest @all
Feature: API - getTotalCount POST Feature: API - TSA - policy POST
Retrieve counters for processed seal statuses and batches Add a new policy
Background: Background:
Given we are testing the VIAM Api Given we are testing the TSA Policy Api Api
@getTotalCount @policy @test
Scenario: Send request with empty body - Positive Scenario: TSA - Adding a new Policy - Positive
#Send Request #Send Batch
Given I send a total count request via API And I clear the request body
And the status code should be {200} \ No newline at end of file
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}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment