diff --git a/src/main/resources/REST/json/Webhook.json b/src/main/resources/REST/json/Webhook.json new file mode 100644 index 0000000000000000000000000000000000000000..40a3535da17de672f04b721914bcf9184f5de700 --- /dev/null +++ b/src/main/resources/REST/json/Webhook.json @@ -0,0 +1,12 @@ +{ + "successful_address": { + "subscriber": "vereign.test.policy", + "webhook_url": "https://webhook.site/4d79f1a0-9608-4d5b-9187-dfe18ae3467b" + }, + "missing_url": { + "subscriber": "vereign.rest.policy" + }, + "missing_subscriber": { + "webhook_url": "https://webhook.site/4d79f1a0-9608-4d5b-9187-dfe18ae3467b" + } +} \ No newline at end of file diff --git a/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/notifychange/POST.feature b/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/notifychange/POST.feature index d34d63ab06d76acc5917da8b9120a9f976863fb9..0e4afc7e7f6f925decbf4809129e8eb6a112acdb 100644 --- a/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/notifychange/POST.feature +++ b/src/test/resources/features/tsa/policy/policy/{respository}/{group}/{name}/{version}/notifychange/POST.feature @@ -1,6 +1,6 @@ #Copyright (c) 2023 Vereign AG [https://www.vereign.com] -@rest @all @tsa @policy @phase2 @IDM.TSA.E1.00007 @wip +@rest @all @tsa @policy @phase2 @IDM.TSA.E1.00007 @IDM.TSA.E1.00008 @wip Feature: API - TSA -Policy - :group/:name/:version/notifychange POST As user I want to be able to subscribe for events for the Policy service @@ -21,3 +21,42 @@ Feature: API - TSA -Policy - :group/:name/:version/notifychange POST And The same message should have field {type} which has value {update_policy} And the response is valid according to the {update_policy_message_schema.json} REST schema Then I unlock the policy group {example} name {test} version {1.0} + + Scenario: TSA - Get notifications from Webhook for policy change - Positive + When I load the REST request {Webhook.json} with profile {successful_address} + And I send the request to the notify change + Then the status code should be {200} + And I lock the Policy group {example} name {test} version {1.0} + Then the status code should be {200} + Then I should see a message with field {repository} which has value {policies} + Then I should see a message with field {name} which has value {locked} + Then I should see a message with field {version} which has value {1.0} + Then I should see a message with field {group} which has value {example} + + @negative + Scenario: TSA - Subscribe for second time to the Webhook for policy change - Negative + When I load the REST request {Webhook.json} with profile {successful_address} + And I send the request to the notify change with group {example} name {test} version {1.0} via TSA Policy API + Then the status code should be {500} + Then the field {message} has the value {subscriber already exists} + + @negative + Scenario: TSA - Get notifications from Webhook for policy change with missing url - Negative + When I load the REST request {Webhook.json} with profile {missing_url} + And I send the request to the notify change with group {example} name {test} version {1.0} via TSA Policy API + Then the status code should be {400} + Then the field {message} has the value {"webhook_url" is missing from body} + + @negative + Scenario: TSA - Get notifications from Webhook for policy change with missing subscriber - Negative + When I load the REST request {Webhook.json} with profile {missing_subscriber} + And I send the request to the notify change with group {example} name {test} version {1.0} via TSA Policy API + Then the status code should be {400} + Then the field {message} has the value {"subscriber" is missing from body} + + @negative + Scenario: TSA - Get notifications from Webhook for non-existing policy - Negative + When I load the REST request {Webhook.json} with profile {successful_address} + And I send the request to the notify change with group {example} name {non_existing} version {1.0} via TSA Policy API + Then the status code should be {500} + Then the field {message} has the value {mongo: no documents in result}