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/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/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..da72e92ff7c96161767e4771482cf3a28fff28c4 --- /dev/null +++ b/src/test/java/api/test/rest/tsa/signer/SignerStepDefinitions.java @@ -0,0 +1,56 @@ +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; + } + + @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"); + } + + @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 iGetSignerDIDViaTSASignerAPI() { + currentRequest.setPath("/v1/issuerDID"); + Response response = RestClient.get(currentRequest); + addRequest(currentRequest); + addResponse(response); + } +} 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..831a682b3eb43056d2076a766b25f3ae95006626 --- /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 POST + 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 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 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..58d5a1a12c4b87660f1f3c92f4a71ca39545b93d 100644 --- a/src/test/resources/features/tsa/signer/v1/keys/GET.feature +++ 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 POST + 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}