diff --git a/src/main/resources/REST/json/Policy.json b/src/main/resources/REST/json/Policy.json index b2dcc0f912beac65c0219f98135cdc3bc96330ba..22e04438a11c70cbbfe92531e720c2d7b1c2e6e9 100644 --- a/src/main/resources/REST/json/Policy.json +++ b/src/main/resources/REST/json/Policy.json @@ -20,5 +20,26 @@ }, "invalid_schema_output": { "foo": "bar" + }, + "storageSet": { + "key": "dataEntry1", + "data": { + "record1": "value for record 1", + "record2": true, + "record3": 3 + } + }, + "storageKey": { + "key": "dataEntry1" + }, + "missingKey": { + "data": { + "record1": "value for record 1", + "record2": true, + "record3": 3 + } + }, + "missingData": { + "key": "dataEntry1" } } \ No newline at end of file diff --git a/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/evaluation/POST.feature b/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/evaluation/POST.feature index f212fb5a1fead52da9376ba0523381dfe37739af..90671299758a18abca28ee1fd8f3a75ff8b2f67e 100644 --- a/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/evaluation/POST.feature +++ b/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/evaluation/POST.feature @@ -35,6 +35,15 @@ Feature: API -TSA - Policy - {repository}/{group}/{name}/{version}/evaluation PO Then the status code should be {200} And the field {key} has the value {someValue} + Scenario: TSA - using multiple header values for policy execution - Positive + When I load the REST request {Policy.json} with profile {empty} + And I load value {someValue} into current request HEADER {X-Cache-Key} + And I load value {another-value} into current request HEADER {X-Another-Header} + And I execute the Policy group {example} name {getMultiHeaders} version {1.0} via TSA Policy API + Then the status code should be {200} + And the field {key} has the value {someValue} + And the field {another} has the value {another-value} + @phase2 @IDM.TSA.E1.00013 Scenario: TSA - Calling external URL - Positive When I execute the Policy group {example} name {externalURL} version {1.0} via TSA Policy API @@ -49,14 +58,23 @@ Feature: API -TSA - Policy - {repository}/{group}/{name}/{version}/evaluation PO Then the status code should be {200} And the field {body.data.didDocument.id} has the value {did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6} - Scenario: TSA - using multiple header values for policy execution - Positive - When I load the REST request {Policy.json} with profile {empty} - And I load value {someValue} into current request HEADER {X-Cache-Key} - And I load value {another-value} into current request HEADER {X-Another-Header} - And I execute the Policy group {example} name {getMultiHeaders} version {1.0} via TSA Policy API - Then the status code should be {200} - And the field {key} has the value {someValue} - And the field {another} has the value {another-value} + @phase2 @IDM.TSA.E1.00014 + Scenario: TSA - Work with database storage - Set data - Positive + When I load the REST request {Policy.json} with profile {storageSet} + And I execute the Policy group {example} name {storageSet} version {1.0} via TSA Policy API + Then the status code should be {200} + When I clear the request body + And I load the REST request {Policy.json} with profile {storageKey} + And I execute the Policy group {example} name {storageGet} version {1.0} via TSA Policy API + Then the status code should be {200} + And the field {record1} has the value {value for record 1} + And the field {record2} has the value {true} + And the field {record2} has the value {true} + And the field {record3} has the value {3} + When I clear the request body + And I load the REST request {Policy.json} with profile {storageKey} + And I execute the Policy group {example} name {storageDelete} version {1.0} via TSA Policy API + Then the status code should be {200} @negative Scenario: TSA - Evaluate policy with incorrect value - Negative @@ -88,3 +106,33 @@ Feature: API -TSA - Policy - {repository}/{group}/{name}/{version}/evaluation PO Then the status code should be {200} And the response is valid according to the {Policy_EvaluateDID_negative_schema.json} REST schema And the field {data.didResolutionMetadata.error} has the value {notFound} + + @negative @phase2 @IDM.TSA.E1.00014 @wip @https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/54 + Scenario: TSA - Work with database storage - Set data with empty body - Negative + When I load the REST request {Policy.json} with profile {empty} + And I execute the Policy group {example} name {storageSet} version {1.0} via TSA Policy API + Then the status code should be {400} + + @negative @phase2 @IDM.TSA.E1.00014 @wip @wip @https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/54 + Scenario: TSA - Work with database storage - Set data with missing key - Negative + When I load the REST request {Policy.json} with profile {missingKey} + And I execute the Policy group {example} name {storageSet} version {1.0} via TSA Policy API + Then the status code should be {400} + + @negative @phase2 @IDM.TSA.E1.00014 @wip @wip @https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/54 + Scenario: TSA - Work with database storage - Set data with missing data field - Negative + When I load the REST request {Policy.json} with profile {missingData} + And I execute the Policy group {example} name {storageSet} version {1.0} via TSA Policy API + Then the status code should be {400} + + @negative @phase2 @IDM.TSA.E1.00014 @wip @wip @https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/54 + Scenario: TSA - Work with database storage - Get data with empty body - Negative + When I load the REST request {Policy.json} with profile {empty} + And I execute the Policy group {example} name {storageGet} version {1.0} via TSA Policy API + Then the status code should be {400} + + @negative @phase2 @IDM.TSA.E1.00014 @wip @wip @https://gitlab.eclipse.org/eclipse/xfsc/tsa/policy/-/issues/54 + Scenario: TSA - Work with database storage - Delete data with empty body - Negative + When I load the REST request {Policy.json} with profile {empty} + And I execute the Policy group {example} name {storageDelete} version {1.0} via TSA Policy API + Then the status code should be {400} diff --git a/test_data/mongo/policy/collections/policies.json b/test_data/mongo/policy/collections/policies.json index d2954e9651e08c08cbc4b97d082a75d09a0026f4..16db9ecdb5417f28488f8f13428e63de37e1e13b 100644 --- a/test_data/mongo/policy/collections/policies.json +++ b/test_data/mongo/policy/collections/policies.json @@ -532,5 +532,47 @@ "nextDataRefreshTime": null, "exportConfig": null, "outputSchema": null + }, + { + "_id": {"$oid": "65818dd64a3da56c5d140c46"}, + "filename": "example/storageSet/1.0/policy.rego", + "group": "example", + "locked": false, + "name": "storageSet", + "rego": "package example.storageSet\n\n_ = storage.set(input.key, input.data)", + "repository": "policies", + "version": "1.0" + }, + { + "_id": {"$oid": "65818e9a4a3da56c5d140c47"}, + "filename": "example/storageGet/1.0/policy.rego", + "group": "example", + "lastUpdate": null, + "locked": false, + "name": "storageGet", + "rego": "package example.storageGet\n\n_ = storage.get(input.key)", + "repository": "policies", + "version": "1.0", + "data": null, + "dataConfig": null, + "nextDataRefreshTime": null, + "exportConfig": null, + "outputSchema": null + }, + { + "_id": {"$oid": "65818ee94a3da56c5d140c48"}, + "filename": "example/storageDelete/1.0/policy.rego", + "group": "example", + "lastUpdate": null, + "locked": false, + "name": "storageDelete", + "rego": "package example.storageDelete\n\n_ = storage.delete(input.key)", + "repository": "policies", + "version": "1.0", + "data": null, + "dataConfig": null, + "nextDataRefreshTime": null, + "exportConfig": null, + "outputSchema": null } ]