diff --git a/src/main/resources/REST/json/Policy.json b/src/main/resources/REST/json/Policy.json index 0c1b8db037a6d5bfc52274a570166b41116e1e71..269ce83c443aeb81271e2516acbbf86873bf3eb6 100644 --- a/src/main/resources/REST/json/Policy.json +++ b/src/main/resources/REST/json/Policy.json @@ -4,5 +4,8 @@ }, "unsuccessful_evaluate": { "message": "wrong value!" + }, + "didResolve_evaluate": { + "did":"did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6" } } \ No newline at end of file diff --git a/src/main/resources/REST/schemas/Policy_EvaluateDID_schema.json b/src/main/resources/REST/schemas/Policy_EvaluateDID_schema.json new file mode 100644 index 0000000000000000000000000000000000000000..92261228ee480d244536601fe322df0f6032a5c9 --- /dev/null +++ b/src/main/resources/REST/schemas/Policy_EvaluateDID_schema.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "doc": { + "type": "object", + "properties": { + "@context": { + "type": "string" + }, + "didDocument": { + "type": "null" + }, + "didDocumentMetadata": { + "type": "object" + }, + "didResolutionMetadata": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + } + }, + "required": [ + "contentType" + ] + } + }, + "required": [ + "@context", + "didDocument", + "didDocumentMetadata", + "didResolutionMetadata" + ] + } + }, + "required": [ + "doc" + ] +} \ No newline at end of file diff --git a/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java b/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java index 3e07882ecc4aeaaab66cbe0074022edebe9de1a6..01c239007ca161d92c4159c121f3780863b1897f 100644 --- a/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java +++ b/src/test/java/api/test/rest/tsa/policy/PolicyStepDefinitions.java @@ -75,6 +75,23 @@ public class PolicyStepDefinitions extends BaseStepDefinitions { policies.insertOne(test); } + @Given("I upload a DID resolver policy to repository") + public void iUploadADIDResolverPolicyDidResolverToRepository() { + MongoClient client = MongoClients.create("mongodb://root:root@localhost:27017"); + MongoDatabase database = client.getDatabase("policy"); + MongoCollection<Document> policies = database.getCollection("policies"); + Document test = new Document("_id", new ObjectId()) + .append("filename", "didResolve_0.8.rego") + .append("name", "didResolve") + .append("group", "example") + .append("version", "1.0") + .append("locked", false) + .append("rego", "package example.didResolve\n" + + "doc = did.resolve(input.did)\n" + + "taskID := \"01234567\""); + policies.insertOne(test); + } + @And("set the policy to productive") public void setThePolicyToProductive() throws Throwable { } diff --git a/src/test/resources/features/tsa/policy/{group}/{name}/{version}/evaluation/POST.feature b/src/test/resources/features/tsa/policy/{group}/{name}/{version}/evaluation/POST.feature index 1ec52061f5aa9a3aeaf9bc3131dc72a0df239984..5ab7c97e3d834c5c635d3588bfca3bedfea7ab91 100644 --- a/src/test/resources/features/tsa/policy/{group}/{name}/{version}/evaluation/POST.feature +++ b/src/test/resources/features/tsa/policy/{group}/{name}/{version}/evaluation/POST.feature @@ -42,6 +42,15 @@ Feature: As user And the field {taskID} has the value {0123456} And delete policy {test1} from repository + Scenario: TSA - DID resolution - Positive + Given I upload a DID resolver policy to repository + Then I load the REST request {Policy.json} with profile {didResolve_evaluate} + And I execute the policy {/example/didResolve/1.0/evaluation} + Then the status code should be {200} + And the response is valid according to the {Policy_EvaluateDID_schema.json} REST schema + And the field {taskID} has the value {01234567} + And delete policy {didResolve} from repository + Scenario: TSA - Evaluate policy synchronously - Negative Given I upload a policy {test6} to repository And set the policy to productive