Skip to content
Snippets Groups Projects
Unverified Commit 1a02c923 authored by Georgi Michev's avatar Georgi Michev
Browse files

add cache tests

parent f75656bf
No related branches found
No related tags found
2 merge requests!18add cache and task tests,!17add cache tests
......@@ -233,7 +233,15 @@ public class JsonUtils {
* @return the uri
*/
public static String getTSAPolicy() {
return System.getProperty("baseUrl") + "/policy";
return System.getProperty("baseUrl") + ":8081/policy";
}
/**
* Get the url for "TSA Cache"
* @return the uri
*/
public static String getTSACache() {
return System.getProperty("baseUrl") + ":8083/v1/cache";
}
/**
......
{
"successful_set": {
"msg": "successful setting the cache"
}
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"kind": {
"type": "integer"
},
"message": {
"type": "string"
}
},
"required": [
"id",
"kind",
"message"
]
}
\ No newline at end of file
......@@ -603,15 +603,6 @@ public class GeneralStepDefinitions extends BaseStepDefinitions {
}
}
@When("^I send the current request as GET to endpoint \\{(.*?)\\}$")
public void iSendTheCurrentRequestAsGETToEndpoint(String endpoint) throws Throwable {
currentRequest.setPath(endpoint);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
/**
* Compares the values of a json array with the supplied cucumber table
*
......
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 cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class CacheStepDefinitions extends BaseStepDefinitions {
private static final Logger logger = LogManager.getLogger(RestGeneralStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer;
Request currentRequest;
public CacheStepDefinitions(RestSessionContainer restSessionContainer, Request currentRequest, DataContainer dataContainer) {
super(dataContainer);
this.restSessionContainer = restSessionContainer;
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");
}
}
#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:8083/v1/cache
#Author: Georgi Michev georgi.michev@vereign.com
@rest @all @tsa @cache
Feature: API -TSA - Cache - v1/cache POST
As policy administrator
I want to have distributed cache feature provided
So I am able to use cache functionality in my custom policies
Acceptance criteria:
- The plugin for rego language to get/set values is ready to use
- The working example how to use the plugin
- Green test based on example committed to the system
Background:
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 {}
And the status code should be {201}
Then I clear the request body
And I send the current request as GET to endpoint {}
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 {test} 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 {}
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}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment