Skip to content
Snippets Groups Projects
Verified Commit d2cb56df authored by Georgi Michev's avatar Georgi Michev
Browse files

Add validate policy output by JSON schema tests

parent 9ae15110
Branches
No related tags found
1 merge request!55Add validate policy output by JSON schema tests
Pipeline #68782 passed
......@@ -14,5 +14,11 @@
"did_missing_method": {
"did":"did:idunion:BDrEcHc8Tb4Lb2VyQZWEDE"
},
"empty": {}
"empty": {},
"valid_schema_output": {
"foo": "barbaz"
},
"invalid_schema_output": {
"foo": "bar"
}
}
\ No newline at end of file
......@@ -11,8 +11,6 @@ import cucumber.api.java.en.When;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.*;
public class PolicyStepDefinitions extends BaseStepDefinitions {
private static final Logger logger =
......@@ -95,10 +93,25 @@ public class PolicyStepDefinitions extends BaseStepDefinitions {
@When("^I Export Policy group \\{(.*)\\} name \\{(.*)\\} version \\{(.*)\\}$")
public void iExportPolicyGroupExampleNameExamplePolicyVersion(
String group, String name, String version) throws IOException {
String group, String name, String version) {
currentRequest.setPath("/policy/policies/" + group + "/" + name + "/" + version + "/export");
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@When("^I validate the output of policy using (GET|POST) with group \\{(.*)\\} name \\{(.*)\\} version \\{(.*)\\} by JSON schema$")
public void iValidateTheOutputOfPolicyWithGroupExampleNameTestVersionByJSONSchema(String method, String group, String name, String version) {
currentRequest.setPath("/policy/policies/" + group + "/" + name + "/" + version + "/validation");
addRequest(currentRequest);
if (method.equals("GET")) {
Response response = RestClient.get(currentRequest);
addResponse(response);
} else if (method.equals("POST")) {
Response response = RestClient.post(currentRequest);
addResponse(response);
}
}
}
#Copyright (c) 2023 Vereign AG [https://www.vereign.com]
@rest @all @tsa @policy @phase2 @IDM.TSA.E1.00009
Feature: API - TSA -Policy - {repository}/{group}/{name}/{version}/validation POST
As user
I want to be able to evaluate a policy output by JSON schema
So I know if the output is as expected
Background:
Given we are testing the TSA Policy Api
Scenario: TSA - Validate policy output by JSON schema - Positive
When I load the REST request {Policy.json} with profile {valid_schema_output}
When I validate the output of policy using POST with group {example} name {examplePolicy} version {1.4} by JSON schema
Then the status code should be {200}
And the field {foo} has the value {barbaz}
@negative @wip @bug-https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/53
Scenario: TSA - Validate invalid policy output by JSON schema - Negative
When I load the REST request {Policy.json} with profile {invalid_schema_output}
When I validate the output of policy using POST with group {example} name {examplePolicy} version {1.4} by JSON schema
Then the status code should be {400}
And the field {message} has the value {policy output schema validation failed}
@negative
Scenario: TSA - Validate invalid policy output by JSON schema - Negative
When I load the REST request {Policy.json} with profile {invalid_schema_output}
When I validate the output of policy using POST with group {example} name {examplePolicy} version {1.2} by JSON schema
Then the status code should be {400}
And the field {message} has the value {validation schema for policy output is not found}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment