diff --git a/.gitignore b/.gitignore index 5e1422c..387bc27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea *.gem *.rbc /.config diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..ee3b3b0 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +inherit_from: .rubocop_todo.yml + +Layout/EndOfLine: + EnforcedStyle: lf + +Style/GlobalVars: + Description: 'Do not introduce global variables.' + StyleGuide: '#instance-vars' + Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html' + Enabled: false + +Metrics/LineLength: + Max: 130 \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..9a9ca6b --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,7 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-09-28 18:58:27 -0400 using RuboCop version 0.50.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..8c9bb5e --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } + +gem 'cucumber' +gem 'json' +gem 'json_spec' +gem 'pg' +gem 'rake' +gem 'report_builder' +gem 'rest-client' +gem 'rspec' +gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3c2002a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,91 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.3.0) + builder (3.2.3) + cucumber (2.4.0) + builder (>= 2.1.2) + cucumber-core (~> 1.5.0) + cucumber-wire (~> 0.0.1) + diff-lcs (>= 1.1.3) + gherkin (~> 4.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (1.5.0) + gherkin (~> 4.0) + cucumber-wire (0.0.1) + diff-lcs (1.3) + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) + ffi (1.9.18-x64-mingw32) + gherkin (4.1.3) + http-cookie (1.0.3) + domain_name (~> 0.5) + json (2.0.2) + json_spec (1.1.5) + multi_json (~> 1.0) + rspec (>= 2.0, < 4.0) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + multi_json (1.12.2) + multi_test (0.1.2) + netrc (0.11.0) + parallel (1.12.0) + parser (2.4.0.0) + ast (~> 2.2) + pg (0.21.0-x64-mingw32) + powerpack (0.1.1) + rainbow (2.2.2) + rake + rake (12.1.0) + report_builder (0.1.6) + builder (~> 3.2, >= 3.2.2) + json (>= 1.8.1) + rest-client (2.0.2-x64-mingw32) + ffi (~> 1.9) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rspec (3.6.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + rubocop (0.50.0) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + ruby-progressbar (1.9.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.4-x64-mingw32) + unicode-display_width (1.3.0) + +PLATFORMS + x64-mingw32 + +DEPENDENCIES + cucumber + json + json_spec + pg + rake + report_builder + rest-client + rspec + rubocop (~> 0.50.0) + +BUNDLED WITH + 1.15.4 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..8677a84 --- /dev/null +++ b/Rakefile @@ -0,0 +1,21 @@ +require 'rubygems' +require 'cucumber' +require 'cucumber/rake/task' +require 'report_builder' + +desc 'This task built the json report ' +task :rjson, [:tag] do |t, args| + sh "cucumber -t @#{args.tag} -f json -o reports/#{args.tag}/report.json" +end + +desc 'This task built the html report ' +task :rhtml, [:tag] do |t, args| + ReportBuilder.configure do |config| + config.json_path = "reports/#{args.tag}/" + config.report_path = "reports/#{args.tag}/report" + config.report_types = [:html] + config.report_title = 'Notifier Report Results' + config.include_images = false + end + ReportBuilder.build_report +end diff --git a/features/crud/delete_channel.feature b/features/crud/delete_channel.feature new file mode 100644 index 0000000..626089b --- /dev/null +++ b/features/crud/delete_channel.feature @@ -0,0 +1,22 @@ +@all @crud +Feature: CRUD for channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + Scenario: Delete channel by id + Given I make a 'DELETE' request to '/channels/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code diff --git a/features/crud/delete_template.feature b/features/crud/delete_template.feature new file mode 100644 index 0000000..775f012 --- /dev/null +++ b/features/crud/delete_template.feature @@ -0,0 +1,22 @@ +@all @crud +Feature: delete template + + Background: + Scenario: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for delete", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + Scenario: delete a specific template + Given I make a 'Delete' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I expect that the GET response it is empty \ No newline at end of file diff --git a/features/crud/get_all_channels.feature b/features/crud/get_all_channels.feature new file mode 100644 index 0000000..1fa182c --- /dev/null +++ b/features/crud/get_all_channels.feature @@ -0,0 +1,30 @@ +@all @crud +Feature: Get all channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Web-Hook-Demo", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get all channels + Given I make a 'GET' request to '/channels' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/crud/get_channels.feature b/features/crud/get_channels.feature new file mode 100644 index 0000000..e918432 --- /dev/null +++ b/features/crud/get_channels.feature @@ -0,0 +1,30 @@ +@all @crud +Feature: CRUD for channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel by id + Given I make a 'GET' request to '/channels/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature new file mode 100644 index 0000000..639ac8c --- /dev/null +++ b/features/crud/get_notification.feature @@ -0,0 +1,44 @@ +@all @crud +Feature: GET request for notification endpoint + + Background: Send a notification + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#general"], + "subject": "Test API", + "content": "A testing message from notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + + @delete_channel + Scenario: Get notification by id + Given I make a 'GET' request to '/notifications/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "notification_status_history" with + """ + { + "attachments": {}, + "templateId": null + + } + """ + And The response body is the same as builded \ No newline at end of file diff --git a/features/crud/get_template.feature b/features/crud/get_template.feature new file mode 100644 index 0000000..ed9aef1 --- /dev/null +++ b/features/crud/get_template.feature @@ -0,0 +1,24 @@ +@all @crud +Feature: get specific template + + Background: + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template 1", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I capture the response to the endpoint + + + Scenario: Get a specific template + Given I make a 'GET' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect POST response is the same as GET response + + diff --git a/features/crud/get_templates.feature b/features/crud/get_templates.feature new file mode 100644 index 0000000..7ca20e8 --- /dev/null +++ b/features/crud/get_templates.feature @@ -0,0 +1,25 @@ +@all @crud +Feature: get templates + + Background: + Background: + Given I create a 'template' with status code '201' and body as: + """ + { + "name": "Template 1", + "contentTemplate": "This should be at least 20 chars" + } + """ + And I save the 'id' of 'templates' + @delete_channel + Scenario: Get all templates + Given I make a 'GET' request to '/templates' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "templates" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature new file mode 100644 index 0000000..6a6173f --- /dev/null +++ b/features/crud/post_channel.feature @@ -0,0 +1,25 @@ +@all @crud +Feature: Post request for channels endpoint + @delete_channel + Scenario: Create a new channel + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Slack-Demo1", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature new file mode 100644 index 0000000..2e138e6 --- /dev/null +++ b/features/crud/post_notifications.feature @@ -0,0 +1,46 @@ +@all @crud +Feature: POST request for notification endpoint + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send a new notification + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + And I build the response for "notification" with + """ + { + "attachments": null, + "templateId": null + } + """ + And The response body is the same as builded + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | priority | recipients | subject | content | status_code | + | NORMAL | #general | Test1 | A testing message from notifier1 | 200 | + | NORMAL | #main | Test2 | A testing message from notifier2 | 200 | + diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature new file mode 100644 index 0000000..69b76ae --- /dev/null +++ b/features/crud/post_resend_notification.feature @@ -0,0 +1,49 @@ +@all @crud +Feature: CRUD resend notification + + Background: send a notification + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "Channel test resend AS:", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#general"], + "subject": "test API", + "content": "Hi there, The JCN team is making a demo about Notifier RESENDA." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + + @delete_channel + Scenario: resend a notification without param + Given I make a 'POST' request to '/notifications/events/$id/resend' endpoint + When I execute the request to the endpoint + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Then I expect a '200' status code + + + @delete_channel + Scenario: resend a notification with param + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | #general | + When I execute the request to the endpoint + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Then I expect a '200' status code diff --git a/features/crud/post_template.feature b/features/crud/post_template.feature new file mode 100644 index 0000000..d656eea --- /dev/null +++ b/features/crud/post_template.feature @@ -0,0 +1,22 @@ +@all @crud +Feature: template + + Scenario: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template test12", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I capture the response to the endpoint + Given I make a 'GET' request to '/templates/$id' endpoint + And I execute the request to the endpoint + Then I expect POST response is the same as GET response + + + diff --git a/features/crud/put_channel.feature b/features/crud/put_channel.feature new file mode 100644 index 0000000..ffc591c --- /dev/null +++ b/features/crud/put_channel.feature @@ -0,0 +1,40 @@ +@all @crud +Feature: CRUD for channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo11", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Update channel by id + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": "AT04-Slack-Demo-Updated11", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/crud/put_template.feature b/features/crud/put_template.feature new file mode 100644 index 0000000..81a217b --- /dev/null +++ b/features/crud/put_template.feature @@ -0,0 +1,33 @@ +@all @crud +Feature: template + + Background: + Scenario: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + Scenario: create a new template + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "new Template", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I capture the response to the endpoint + Given I make a 'GET' request to '/templates/$id' endpoint + Then I expect PUT response is the same as GET response + + diff --git a/features/functional/.gitignore b/features/functional/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/functional/channels/get_channels_params_name.feature b/features/functional/channels/get_channels_params_name.feature new file mode 100644 index 0000000..84397b7 --- /dev/null +++ b/features/functional/channels/get_channels_params_name.feature @@ -0,0 +1,59 @@ +@all @functional +Feature: Functional get for channels with params name + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Web-Hook-Demo", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel of type WEB_HOOK + Given I make a 'GET' request to '/channels' with: + | name | AT04-Web-Hook-Demo | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel of type WEB_HOOK + Given I make a 'GET' request to '/channels' with: + | name | at04-web-hook-demo | + | ignoreCase | true | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel of type WEB_HOOK + Given I make a 'GET' request to '/channels' with: + | name | AT04-Web-Hook-Demo | + | ignoreCase | false | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/functional/channels/get_channels_params_type_EMAIL.feature b/features/functional/channels/get_channels_params_type_EMAIL.feature new file mode 100644 index 0000000..2250aed --- /dev/null +++ b/features/functional/channels/get_channels_params_type_EMAIL.feature @@ -0,0 +1,32 @@ +@all @functional +Feature: Functional get for channels with params type for EMAIL + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Email-Demo", + "type": "EMAIL", + "configuration": { + "mail.from": "example@example.com", + "mail.host": "40.97.162.130" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel of type EMAIL + Given I make a 'GET' request to '/channels' with: + | type | EMAIL | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/functional/channels/get_channels_params_type_SLACK.feature b/features/functional/channels/get_channels_params_type_SLACK.feature new file mode 100644 index 0000000..7a2c437 --- /dev/null +++ b/features/functional/channels/get_channels_params_type_SLACK.feature @@ -0,0 +1,31 @@ +@all @functional +Feature: Functional get for channels with params type for SLACK + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel of type SLACK + Given I make a 'GET' request to '/channels' with: + | type | SLACK | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/functional/channels/get_channels_params_type_TWITTER.feature b/features/functional/channels/get_channels_params_type_TWITTER.feature new file mode 100644 index 0000000..b0ac15c --- /dev/null +++ b/features/functional/channels/get_channels_params_type_TWITTER.feature @@ -0,0 +1,34 @@ +@all @functional +Feature: Functional get for channels with params type for TWITTER + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", + "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", + "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", + "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel of type TWITTER + Given I make a 'GET' request to '/channels' with: + | type | TWITTER | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/functional/channels/get_channels_params_type_WEB_HOOK.feature b/features/functional/channels/get_channels_params_type_WEB_HOOK.feature new file mode 100644 index 0000000..912af83 --- /dev/null +++ b/features/functional/channels/get_channels_params_type_WEB_HOOK.feature @@ -0,0 +1,31 @@ +@all @functional +Feature: Functional get for all channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Web-Hook-Demo", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario: Get channel of type WEB_HOOK + Given I make a 'GET' request to '/channels' with: + | type | WEB_HOOK | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "channels" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/functional/channels/negative_delete_channel_invalid_endpoint.feature b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature new file mode 100644 index 0000000..2e43f1b --- /dev/null +++ b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature @@ -0,0 +1,41 @@ +@functional @all +Feature: delete channel + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Web-Hook-Demo", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Can't delete a channel with invalid endpoint + Given I make a 'DELETE' request to '//$id' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 404, + "error": "Not Found", + "message": "Not Found" + } + """ + Examples: + | Endpoint | + | chanel | + | chanels | + | channel | + | CHANNELS | + | channelll | + | | + diff --git a/features/functional/channels/negative_delete_channel_invalid_id.feature b/features/functional/channels/negative_delete_channel_invalid_id.feature new file mode 100644 index 0000000..b7cf579 --- /dev/null +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -0,0 +1,59 @@ +@functional @bug @all +Feature: Negative responses after making a delete request by invalid id + + Scenario Outline: Can't delete a channel by id with invalid params + Given I make a 'DELETE' request to '/channels/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + And excluding 'timestamp' and 'path' the response body contains: + + """ + { + "status": , + "error": "", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request" + } + """ + + Examples: + | Id | status_code | error | + | abc | 400 | Bad Request | + | !@$ | 400 | Bad Request | + | SDDF | 400 | Bad Request | + | 070./ | 400 | Bad Request | + | 510@ | 400 | Bad Request | + | 510. | 400 | Bad Request | + | 510.1 | 400 | Bad Request | + | 510.a | 400 | Bad Request | + | 51#$ | 400 | Bad Request | + | 610.M | 400 | Bad Request | + | . | 400 | Bad Request | + + + Scenario: Can't delete a channel by id with deleted id + Given I make a 'DELETE' request to '/channels/1170' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code + + + Scenario Outline: Can't delete a channel by id with invalid params + Given I make a 'DELETE' request to '/channels/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + And excluding 'timestamp' and 'path' the response body contains: + + """ + { + "status": 405, + "error": "Method Not Allowed", + "exception": "org.springframework.web.HttpRequestMethodNotSupportedException", + "message": "Request method 'DELETE' not supported" + } + """ + + Examples: + | Id | status_code | + | | 405 | + | .345 | 405 | + diff --git a/features/functional/channels/negative_get_channels_by_id.feature b/features/functional/channels/negative_get_channels_by_id.feature new file mode 100644 index 0000000..443613d --- /dev/null +++ b/features/functional/channels/negative_get_channels_by_id.feature @@ -0,0 +1,32 @@ +@all @functional +Feature: Negative responses after making a get request by id + + Scenario Outline: Can't find a channel by id with invalid params + Given I make a 'GET' request to '/channels/' endpoint + When I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels/" + } + """ + Examples: + | Id | + | abc | + | !@$ | + | 510@ | + | 510. | + | 510.1 | + | 510.a | + | 0510.$ | + | 0510.!@#$@!# | + + Scenario: Can't Find a channel with nonexistent id + Given I make a 'GET' request to '/channels/9999999' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code diff --git a/features/functional/channels/negative_get_channels_invalid_type.feature b/features/functional/channels/negative_get_channels_invalid_type.feature new file mode 100644 index 0000000..bf8c874 --- /dev/null +++ b/features/functional/channels/negative_get_channels_invalid_type.feature @@ -0,0 +1,105 @@ +@all @functional +Feature: Negative request get channels with invalid type + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Web-Hook-Demo", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Get channel of invalid and empty type + Given I make a 'GET' request to '/channels' with: + | type | | + When I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Type | + | ANOTHER | + | | + | $ | + @delete_channel + Scenario: Get channel of name empty + Given I make a 'GET' request to '/channels' with: + | name | | + When I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels" + } + """ + @delete_channel + Scenario: Get channel with nonexistent name + Given I make a 'GET' request to '/channels' with: + | name | Bad Name | + When I execute the request to the endpoint + Then I expect a '404' status code + And I expect that the GET response it is empty + And the response body contains excluding 'timestamp': + """ + """ + @delete_channel + Scenario Outline: Get channel with invalid name and ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | | + | ignoreCase | | + When I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Name | Case | + | AT04-Web-Hook-Demo | | + | AT04-Web-Hook-Demo | a | + | | true | + | | | + | | false | + + @delete_channel + Scenario Outline: Get channel with nonexistent name and valid ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | | + | ignoreCase | | + When I execute the request to the endpoint + Then I expect a '404' status code + And I expect that the GET response it is empty + And the response body contains excluding '': + """ + """ + Examples: + | Name | Case | + | NoTExists | true | + | NoTExists | false | diff --git a/features/functional/channels/negative_post_channels.feature b/features/functional/channels/negative_post_channels.feature new file mode 100644 index 0000000..068fea5 --- /dev/null +++ b/features/functional/channels/negative_post_channels.feature @@ -0,0 +1,173 @@ +@all @functional +Feature: Negative responses after making a post request + @delete_channel + Scenario Outline: Create a new channel for SLACK and WEBHOOK + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Slack-or-WebHook-Demo", + "type": "", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Type | Configuration | Field | + | SLACK | "url": "" | url | + | SLACK | "url": "123.com" | url | + | SLACK | "url": "www.example.com/" | url | + | SLACK | "url": "https:://www.example.com/***/***/" | url | + | WEB_HOOK | "url": "" | url | + | WEB_HOOK | "url": "123.com" | url | + | WEB_HOOK | "url": "www.example.com/" | url | + | WEB_HOOK | "url": "https:://www.example.com/***/***/" | url | + + @delete_channel + Scenario Outline: Create a new channel without name and configuration + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "", + "type": "EMAIL", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "name", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Name | Configuration | Field_1 | Field_2 | + | | "mail.from":"", "mail.host":"127.0.0.1" | name | email | + | | "mail.from":"example@gmail.com", "mail.host":"" | name | host | + + @delete_channel + Scenario Outline: Create a new channel for EMAIL + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Email-Demo", + "type": "EMAIL", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Configuration | Field | + | "mail.from":"", "mail.host":"127.0.0.1" | email | + | "mail.host":"127.0.0.1", "mail.from":"" | email | + | "mail.from":"example@gmail.com", "mail.host":"" | host | + | "mail.host":"" , "mail.from":"example@gmail.com" | host | + + @delete_channel + Scenario Outline: Create a new channel for WebHook, Email and Twitter with invalid params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Email-Demo", + "type": "EMAIL", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Configuration | Field_1 | Field_2 | + | | email | host | + | "mail.from":"", "mail.host":"" | email | host | + | "mail.from":"1", "mail.host": "" | email | host | + | "mail.from":1, "mail.host": "" | email | host | diff --git a/features/functional/channels/negative_post_channels_invalid.feature b/features/functional/channels/negative_post_channels_invalid.feature new file mode 100644 index 0000000..9cfdb74 --- /dev/null +++ b/features/functional/channels/negative_post_channels_invalid.feature @@ -0,0 +1,47 @@ +@all @functional +Feature: Negative responses after making a post request + @delete_channel + Scenario Outline: Create a new channel with invalid or empty params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": , + "type": , + "configuration": { + "url": "https://www.example.com/" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Name | Type | + | | | + | | "SLACK" | + | | "SLAC" | + | "" | "" | + | "" | "SLAC" | + | "" | $ | + | $ | | + | $ | # | + | $ | "SLACK" | + | $ | "SLAC" | + | $ | "" | + | "AT-04" | | + | "AT-04" | "" | + | "AT-04" | $ | + | 1 | | + | 1 | "" | + | 1 | $ | diff --git a/features/functional/channels/negative_post_channels_required.feature b/features/functional/channels/negative_post_channels_required.feature new file mode 100644 index 0000000..067bb92 --- /dev/null +++ b/features/functional/channels/negative_post_channels_required.feature @@ -0,0 +1,36 @@ +@all @functional +Feature: Negative responses after making a post request + @delete_channel + Scenario Outline: Create a new channel without required params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + + + "configuration": { + "url": "https://www.example.com/" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | Name | Type | Errors | + | | | {"field": "name","code": "name.required","defaultMessage": null}, {"field": "type","code": "NotNull","defaultMessage": "may not be null"} | + | | "type":"SLACK", | {"field": "name","code": "name.required","defaultMessage": null} | + | "name":"AT-04", | | {"field": "type","code": "NotNull","defaultMessage": "may not be null"} | diff --git a/features/functional/channels/negative_post_channels_twitter.feature b/features/functional/channels/negative_post_channels_twitter.feature new file mode 100644 index 0000000..a8d0afe --- /dev/null +++ b/features/functional/channels/negative_post_channels_twitter.feature @@ -0,0 +1,214 @@ +@all @functional +Feature: Negative responses after making a post request + @delete_channel + Scenario Outline: Create a new channel for Twitter with invalid params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "", + "consumer_key": "", + "consumer_secret": "", + "access_token_secret": "" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: +| A_Token | C_Key | C_Secret | A_T_Secret | Code_Error | +| | b | c | d | access_token | +| | 2 | 3 | 4 | access_token | +| % | 2 | 3 | 4 | access_token | +| a | | c | d | consumer_key | +| 1 | | 3 | 4 | consumer_key | +| 1 | ^ | 3 | 4 | consumer_key | +| a | b | | d | consumer_secret | +| 1 | 2 | | 4 | consumer_secret | +| 1 | 2 | & | 4 | consumer_secret | +| a | b | c | | access_token_secret | +| 1 | 2 | 3 | | access_token_secret | +| 1 | 2 | 3 | * | access_token_secret | + + @delete_channel + Scenario Outline: Create a new channel for Twitter with invalid params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "", + "consumer_key": "", + "consumer_secret": "", + "access_token_secret": "" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: +| A_Token | C_Key | C_Secret | A_T_Secret | First_Code_Error | Second_Code_Error | +| | | c | d | consumer_key | access_token | +| | | 3 | 4 | consumer_key | access_token | +| # | $ | 3 | 4 | consumer_key | access_token | +| a | | | d | consumer_key | consumer_secret | +| 1 | | | 4 | consumer_key | consumer_secret | +| 1 | $ | % | 4 | consumer_key | consumer_secret | +| a | b | | | consumer_secret | access_token_secret | +| 1 | 2 | | | consumer_secret | access_token_secret | +| 1 | 2 | % | ^ | consumer_secret | access_token_secret | + + @delete_channel + Scenario Outline: Create a new channel for Twitter with invalid params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "", + "consumer_key": "", + "consumer_secret": "", + "access_token_secret": "" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | A_Token | C_Key | C_Secret | A_T_Secret | First_Code_Error | Second_Code_Error | Third_Code_Error | + | | | | 4 | consumer_key | consumer_secret | access_token | + | 1 | | | | consumer_key | consumer_secret | access_token_secret | + | | 2 | | | consumer_secret | access_token | access_token_secret | + | | 3 | | | consumer_secret | access_token | access_token_secret | + + @delete_channel + Scenario Outline: Create a new channel for Twitter with invalid params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "", + "consumer_key": "", + "consumer_secret": "", + "access_token_secret": "" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'channels' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + }, + { + "field": "configuration", + "code": ".required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: + | A_Token | C_Key | C_Secret | A_T_Secret | First_Code_Error | Second_Code_Error | Third_Code_Error | Fourth_Code_Error | + | | | | | consumer_key | consumer_secret | access_token | access_token_secret | + | # | $ | % | ^ | consumer_key | consumer_secret | access_token | access_token_secret | diff --git a/features/functional/channels/negative_put_channels.feature b/features/functional/channels/negative_put_channels.feature new file mode 100644 index 0000000..bb8df86 --- /dev/null +++ b/features/functional/channels/negative_put_channels.feature @@ -0,0 +1,59 @@ +@all @functional +Feature: Negative responses after making a put request + Background: + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04_Old_Name", + "type": "SLACK", + "configuration": { + "url": "https://example.com" + }, + "onFail": "https://fail.com" + } + """ + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Update a created channel for WebHook, Email and Twitter with invalid params + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": "", + "type": "", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + + ], + "message": "Bad Request" + } + """ + Examples: + | Name | Type | Configuration | Errors | + | | SLACK | "url": "https://www.example.com/" | { "field": "name", "code": "name.required", "defaultMessage": null } | + | AT04-Slack-Demo | SLACK | | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-Slack-Demo | SLACK | "url": "" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-Slack-Demo | SLACK | "url": "www.example.com/" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-Slack-Demo | SLACK | "url": "https:://www.example.com/***/***/" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | | WEB_HOOK | "url": "https://www.example.com/" | { "field": "name", "code": "name.required", "defaultMessage": null } | + | AT04-WebHook-Demo | WEB_HOOK | | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-WebHook-Demo | WEB_HOOK | "url": "" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-WebHook-Demo | WEB_HOOK | "url": "www.example.com/" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https:://www.example.com/***/***/" | { "field": "configuration", "code": "url.required", "defaultMessage": null } | + | | EMAIL | "mail.from":"example@example.com", "mail.host":"127.0.0.1" | { "field": "name", "code": "name.required", "defaultMessage": null } | + | AT04-Email-Demo | EMAIL | | { "field": "configuration", "code": "email.required", "defaultMessage": null }, { "field": "configuration", "code": "host.required", "defaultMessage": null } | + | AT04-Email-Demo | EMAIL | "mail.from":"", "mail.host":"" | { "field": "configuration", "code": "email.required", "defaultMessage": null }, { "field": "configuration", "code": "host.required", "defaultMessage": null } | + | AT04-Email-Demo | EMAIL | "mail.from":"example@example.com", "mail.host":"" | { "field": "configuration", "code": "host.required", "defaultMessage": null } | + | AT04-Email-Demo | EMAIL | "mail.from":"", "mail.host":"127.0.0.1" | { "field": "configuration", "code": "email.required", "defaultMessage": null } | diff --git a/features/functional/channels/negative_put_channels_invalid.feature b/features/functional/channels/negative_put_channels_invalid.feature new file mode 100644 index 0000000..9359fa4 --- /dev/null +++ b/features/functional/channels/negative_put_channels_invalid.feature @@ -0,0 +1,58 @@ +@all @functional +Feature: Negative responses after making a put request + Background: + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04_Old_Name", + "type": "SLACK", + "configuration": { + "url": "https://example.com" + }, + "onFail": "https://fail.com" + } + """ + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Update a created channel with invalid or empty params + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": , + "type": , + "configuration": { + "url": "https://www.example.com/" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", + "message": "Bad Request" + } + """ + Examples: + | Name | Type | + | | | + | | "SLACK" | + | | "SLAC" | + | "" | "" | + | "" | "SLAC" | + | "" | $ | + | $ | | + | $ | # | + | $ | "SLACK" | + | $ | "SLAC" | + | $ | "" | + | "AT-04" | | + | "AT-04" | "" | + | "AT-04" | $ | + | 1 | | + | 1 | "" | + | 1 | $ | diff --git a/features/functional/channels/negative_put_channels_required.feature b/features/functional/channels/negative_put_channels_required.feature new file mode 100644 index 0000000..575a515 --- /dev/null +++ b/features/functional/channels/negative_put_channels_required.feature @@ -0,0 +1,47 @@ +@all @functional +Feature: Negative responses after making a post request + Background: + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04_Old_Name", + "type": "SLACK", + "configuration": { + "url": "https://example.com" + }, + "onFail": "https://fail.com" + } + """ + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Create a new channel without required params + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + + + "configuration": { + "url": "https://www.example.com/" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + + ], + "message": "Bad Request" + } + """ + Examples: + | Name | Type | Errors | + | | | {"field": "name","code": "name.required","defaultMessage": null}, {"field": "type","code": "NotNull","defaultMessage": "may not be null"} | + | | "type":"SLACK", | {"field": "name","code": "name.required","defaultMessage": null} | + | "name":"AT-04", | | {"field": "type","code": "NotNull","defaultMessage": "may not be null"} | diff --git a/features/functional/channels/negative_put_channels_twitter.feature b/features/functional/channels/negative_put_channels_twitter.feature new file mode 100644 index 0000000..3a38983 --- /dev/null +++ b/features/functional/channels/negative_put_channels_twitter.feature @@ -0,0 +1,62 @@ +@all @functional +Feature: Negative responses after making a put request + Background: + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04_Old_Name", + "type": "SLACK", + "configuration": { + "url": "https://example.com" + }, + "onFail": "https://fail.com" + } + """ + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Update a existent channel to Twitter with invalid params + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": "AT04-Twitter-Demo", + "type": "TWITTER", + "configuration": { + "access_token": "", + "consumer_key": "", + "consumer_secret": "", + "access_token_secret": "" + } + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + + ], + "message": "Bad Request", + "path": "/channels" + } + """ + Examples: +| A_Token | C_Key | C_Secret | A_T_Secret | Errors | +| | b | c | d | { "field": "configuration", "code": "access_token.required", "defaultMessage": null } | +| | 2 | 3 | 4 | { "field": "configuration", "code": "access_token.required", "defaultMessage": null } | +| % | 2 | 3 | 4 | { "field": "configuration", "code": "access_token.required", "defaultMessage": null } | +| a | | c | d | { "field": "configuration", "code": "consumer_key.required", "defaultMessage": null } | +| a | | c | d | { "field": "configuration", "code": "consumer_key.required", "defaultMessage": null } | +| 1 | ^ | 3 | 4 | { "field": "configuration", "code": "consumer_key.required", "defaultMessage": null } | +| a | b | | d | { "field": "configuration", "code": "consumer_secret.required", "defaultMessage": null } | +| 1 | 2 | | 4 | { "field": "configuration", "code": "consumer_secret.required", "defaultMessage": null } | +| a | b | & | d | { "field": "configuration", "code": "consumer_secret.required", "defaultMessage": null } | +| a | b | c | | { "field": "configuration", "code": "access_token_secret.required", "defaultMessage": null } | +| 1 | 2 | 3 | | { "field": "configuration", "code": "access_token_secret.required", "defaultMessage": null } | +| 1 | 2 | 3 | * | { "field": "configuration", "code": "access_token_secret.required", "defaultMessage": null } | +| | | | | { "field": "configuration", "code": "consumer_key.required", "defaultMessage": null }, { "field": "configuration", "code": "consumer_secret.required", "defaultMessage": null }, { "field": "configuration", "code": "access_token.required", "defaultMessage": null }, { "field": "configuration", "code": "access_token_secret.required", "defaultMessage": null } | +| $ | # | @ | ! | { "field": "configuration", "code": "consumer_key.required", "defaultMessage": null }, { "field": "configuration", "code": "consumer_secret.required", "defaultMessage": null }, { "field": "configuration", "code": "access_token.required", "defaultMessage": null }, { "field": "configuration", "code": "access_token_secret.required", "defaultMessage": null } | diff --git a/features/functional/channels/post_channel.feature b/features/functional/channels/post_channel.feature new file mode 100644 index 0000000..4eab5ac --- /dev/null +++ b/features/functional/channels/post_channel.feature @@ -0,0 +1,60 @@ +@all @functional +Feature: Post request for channels endpoint + @delete_channel + Scenario Outline: Create a new channel for WebHook, Email and Twitter + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "", + "type": "", + "configuration": { + + } + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + And I build the response for "channel" with + """ + { + "onFail": + } + """ + And The response body is the same as builded + Examples: + | Name | Type | Configuration | OnFail | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com" | null | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | null | + | AT04-Twitter-Demo | TWITTER | "access_token": "a", "consumer_key": "b", "consumer_secret": "c", "access_token_secret": "d" | null | + + @delete_channel + Scenario Outline: Create a new channel for WebHook, Email and Twitter with all neccesary params + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "", + "type": "", + "configuration": { + + }, + "onFail": "" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + And I build the response for "channel" with + """ + { + } + """ + And The response body is the same as builded + Examples: + | Name | Type | Configuration | OnFail | + | AT04-Slack-Demo | SLACK | "url": "https://hooks.slack.com/services" | https://hooks.slack.com | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services" | https://hooks.slack.com | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | https://hooks.slack.com/services/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 | + | AT04-Twitter-Demo | TWITTER | "access_token": "a", "consumer_key": "b", "consumer_secret": "c", "access_token_secret": "d" | https://hooks.slack.com | diff --git a/features/functional/channels/put_channels.feature b/features/functional/channels/put_channels.feature new file mode 100644 index 0000000..35ed6ac --- /dev/null +++ b/features/functional/channels/put_channels.feature @@ -0,0 +1,54 @@ +@all @functional +Feature: Puts request for channels endpoint + + Background: + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04_Old_Name", + "type": "SLACK", + "configuration": { + "url": "https://example.com" + }, + "onFail": "https://fail.com" + } + """ + And I save the 'id' of 'channels' + @delete_channel + Scenario Outline: Update channel by id + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": "", + "type": "", + "configuration": { + + } + + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + And I build the response for "channel" with + """ + { + } + """ + And The response body is the same as builded + Examples: + | Name | Type | Configuration | OnFail | + | AT04-Slack-Demo | SLACK | "url": "https://hooks.slack.com" | ,"onFail": "https://hooks.slack.com" | + | AT04-Slack-Demo | SLACK | "url": "https://hooks.slack.com" | ,"onFail": "" | + | AT04-Slack-Demo | SLACK | "url": "https://hooks.slack.com" | | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com" | ,"onFail": "https://hooks.slack.com" | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com" | ,"onFail": "" | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com" | | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | ,"onFail": "https://hooks.slack.com" | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | ,"onFail": "" | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | | + | AT04-Twitter-Demo | TWITTER | "access_token": "a", "consumer_key": "b", "consumer_secret": "c", "access_token_secret": "d" | ,"onFail": "https://hooks.slack.com" | + | AT04-Twitter-Demo | TWITTER | "access_token": "a", "consumer_key": "b", "consumer_secret": "c", "access_token_secret": "d" | ,"onFail": "" | + | AT04-Twitter-Demo | TWITTER | "access_token": "a", "consumer_key": "b", "consumer_secret": "c", "access_token_secret": "d" | | + diff --git a/features/functional/notifications/negative_get_notification.feature b/features/functional/notifications/negative_get_notification.feature new file mode 100644 index 0000000..4045adb --- /dev/null +++ b/features/functional/notifications/negative_get_notification.feature @@ -0,0 +1,175 @@ +@all @crud +Feature: GET request for notification endpoint + + Background: Send a notification + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#general"], + "subject": "Test API", + "content": "A testing message from notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + + @delete_channel + Scenario Outline: Get notification with invalid id + Given I make a 'GET' request to '/notifications/' endpoint + When I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/notifications/" + } + """ + Examples: + | Id | + | abc | + | !@$ | + | c4d6@ | + | c4d6. | + | c4d6.1 | + | c4d6.a | + | c4d6.$ | + | c4d6f70e-a693-47be-aedf | + | ef79dfdc-88ee | + + @delete_channel + Scenario Outline: Can't Find a notification with nonexistent id + Given I make a 'GET' request to '/notifications/' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 404, + "error": "Not Found", + "exception": "javax.persistence.EntityNotFoundException", + "message": "Notification not found with the id: ", + "path": "/notifications/" + } + """ + Examples: + | Id | + | ef79dfdc-88ee-475b-9f5d-deb532cf3988 | + | c4d6f70e-a693-47be-aedf-2b912e9f3e12 | + + + @delete_channel @bug + Scenario Outline: Get notification with valid id followed by a period plus one letter + Given I make a 'GET' request to '/notifications/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 406, + "error": "Not Acceptable", + "exception": "org.springframework.web.HttpMediaTypeNotAcceptableException", + "message": "Not Acceptable" + } + """ + Examples: + | Id | status_code | + | $id.a | 200 | + | $id.b | 200 | + | $id.c | 406 | + | $id.d | 200 | + | $id.e | 200 | + | $id.f | 406 | + | $id.g | 200 | + | $id.h | 406 | + | $id.i | 200 | + | $id.j | 200 | + | $id.k | 200 | + | $id.l | 200 | + | $id.m | 200 | + | $id.n | 200 | +# | $id.ñ | 200 | + | $id.o | 200 | + | $id.p | 406 | + | $id.q | 200 | + | $id.r | 200 | + | $id.s | 406 | + | $id.t | 406 | + | $id.u | 200 | + | $id.v | 200 | + | $id.w | 200 | + | $id.x | 200 | + | $id.y | 200 | + | $id.z | 406 | + | $id.A | 200 | + | $id.B | 200 | + | $id.C | 406 | + | $id.D | 200 | + | $id.E | 200 | + | $id.F | 406 | + | $id.G | 200 | + | $id.H | 406 | + | $id.I | 200 | + | $id.J | 200 | + | $id.K | 200 | + | $id.L | 200 | + | $id.M | 200 | + | $id.N | 200 | +# | $id.Ñ | 200 | + | $id.O | 200 | + | $id.P | 406 | + | $id.Q | 200 | + | $id.R | 200 | + | $id.S | 406 | + | $id.T | 406 | + | $id.U | 200 | + | $id.V | 200 | + | $id.W | 200 | + | $id.X | 200 | + | $id.Y | 200 | + | $id.Z | 406 | + + @delete_channel @bug + Scenario Outline: Get notification with valid id followed by a period plus one number + Given I make a 'GET' request to '/notifications/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 406, + "error": "Not Acceptable", + "exception": "org.springframework.web.HttpMediaTypeNotAcceptableException", + "message": "Not Acceptable" + } + """ + Examples: + | Id | status_code | + | $id.1 | 200 | + | $id.2 | 200 | + | $id.3 | 406 | + | $id.4 | 200 | + | $id.5 | 200 | + | $id.6 | 406 | + | $id.7 | 200 | + | $id.8 | 406 | + | $id.9 | 200 | + | $id.10 | 200 | diff --git a/features/functional/notifications/negative_notification_incorrect_request.feature b/features/functional/notifications/negative_notification_incorrect_request.feature new file mode 100644 index 0000000..cdea587 --- /dev/null +++ b/features/functional/notifications/negative_notification_incorrect_request.feature @@ -0,0 +1,45 @@ +@all @functional +Feature: Negative responses after making an incorrect request + + Background: Create a Channel for SLACK + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "Channel-for-SLACK", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send notification with an invalid request + Given I make a '' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [""], + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + And the response body contains excluding 'timestamp': + """ + { + "status": , + "error": "Method Not Allowed", + "exception": "org.springframework.web.HttpRequestMethodNotSupportedException", + "message": "Request method '' not supported", + "path": "/notifications" + } + """ + Examples: + | request | recipients | content | status_code | + | GET | #general | A testing message from notifier 1 | 405 | + | PUT | #general | A testing message from notifier 1 | 405 | + | DELETE | #general | A testing message from notifier 1 | 405 | diff --git a/features/functional/notifications/negative_post_notification.feature b/features/functional/notifications/negative_post_notification.feature new file mode 100644 index 0000000..29c7176 --- /dev/null +++ b/features/functional/notifications/negative_post_notification.feature @@ -0,0 +1,55 @@ +@all @functional +Feature: Negative responses after making a post request + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel @bug + Scenario Outline: Send a new notification with a parameter greater than 256 characters + Given I make a 'POST' request to '/notifications' endpoint + When I generate 'a' letter times and save for 'value' field + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'notification' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "", + "code": "Size", + "defaultMessage": "" + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | recipients | subject | content | number_of_letters | field | default_message | + | $value | Test | A testing message from notifier 1 | 256 | recipients | size must be between 1 and 22 | + | $value | Test | A testing message from notifier 1 | 257 | recipients | size must be between 1 and 22 | + | $value | Test | A testing message from notifier 1 | 300 | recipients | size must be between 1 and 22 | + | #general | $value | A testing message from notifier 1 | 300 | subject | size must be between 0 and 255 | diff --git a/features/functional/notifications/negative_post_notification_empty_parameters.feature b/features/functional/notifications/negative_post_notification_empty_parameters.feature new file mode 100644 index 0000000..8ce61c7 --- /dev/null +++ b/features/functional/notifications/negative_post_notification_empty_parameters.feature @@ -0,0 +1,192 @@ +@all @functional +Feature: Negative responses after making a post request with empty parameters. + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send a new notification with some empty parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": "", + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "", + "code": "", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | channelId | priority | recipients | subject | content | field | code | + | | NORMAL | #general | Test | A testing message from notifier | channelId | channelId.required | + | $channels_id | NORMAL | | Test | A testing message from notifier | recipients | recipients.valid | + | $channels_id | NORMAL | #general | | A testing message from notifier | subject | subject.required | + | $channels_id | NORMAL | #general | Test | | content | content.required | + + @delete_channel + Scenario Outline: Send a new notification with subject and content empty parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "subject", + "code": "subject.required", + "defaultMessage": null + }, + { + "field": "content", + "code": "content.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | + | NORMAL | #general | | | + + @delete_channel + Scenario Outline: Send a new notification with recipients, subject and content empty parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "recipients", + "code": "recipients.valid", + "defaultMessage": null + }, + { + "field": "subject", + "code": "subject.required", + "defaultMessage": null + }, + { + "field": "content", + "code": "content.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | + | NORMAL | | | | + + @delete_channel + Scenario Outline: Send a new notification with channel id ,recipients, subject and content empty parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": , + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "channelId", + "code": "channelId.required", + "defaultMessage": null + }, + { + "field": "recipients", + "code": "recipients.valid", + "defaultMessage": null + }, + { + "field": "subject", + "code": "subject.required", + "defaultMessage": null + }, + { + "field": "content", + "code": "content.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | channelId | priority | recipients | subject | content | + | "" | NORMAL | | | | diff --git a/features/functional/notifications/negative_post_notification_invalid_endpoint.feature b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature new file mode 100644 index 0000000..572a89b --- /dev/null +++ b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature @@ -0,0 +1,47 @@ +@functional @all +Feature: Post Notification with invalid endpoint + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Can't post a notification with invalid endpoint + Given I make a 'POST' request to '/' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [], + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '404' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 404, + "error": "Not Found", + "message": "Not Found", + "path": "/api/" + } + """ + Examples: + | Endpoint | recipients | content | + | notific | "#general" | A testing message from notifier 0 | + | notification | "#general" | A testing message from notifier 1 | + | NOTIFICATIONS | "#general" | A testing message from notifier 2 | + | notificationsV1 | "#general" | A testing message from notifier 3 | + | notifications1 | "#general" | A testing message from notifier 4 | + | notifications!@ | "#general" | A testing message from notifier 5 | + diff --git a/features/functional/notifications/negative_post_notification_invalid_parameters.feature b/features/functional/notifications/negative_post_notification_invalid_parameters.feature new file mode 100644 index 0000000..df05e7c --- /dev/null +++ b/features/functional/notifications/negative_post_notification_invalid_parameters.feature @@ -0,0 +1,50 @@ +@all @functional +Feature: Negative responses after making a post request + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + + @delete_channel + Scenario Outline: Send a new notification with invalid parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": , + "priority": , + "recipients": [], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | channelId | priority | recipients | subject | content | + | "One" | "NORMAL" | recipients | Test1 | A testing message from notifier | + | 01 | "NORMAL" | recipients | Test2 | A testing message from notifier | + | $id | "" | recipients | Test3 | A testing message from notifier | + | $id | 5 | recipients | Test3 | A testing message from notifier | + | $id | "NORMAL" | | Test3 | A testing message from notifier | + diff --git a/features/functional/notifications/negative_post_notification_priority.feature b/features/functional/notifications/negative_post_notification_priority.feature new file mode 100644 index 0000000..3be6e73 --- /dev/null +++ b/features/functional/notifications/negative_post_notification_priority.feature @@ -0,0 +1,82 @@ +@all @functional +Feature: Negative responses after making a post request + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send notification with nonexistent priorities + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | status_code | + | LOW | #general | Test1 | A testing message from notifier 1 | 400 | + | NOW | #general | Test2 | A testing message from notifier 2 | 400 | + | LATER | #general | Test3 | A testing message from notifier 3 | 400 | + | URGENCY | #general | Test4 | A testing message from notifier 4 | 400 | + | IMPORTANCE | #general | Test5 | A testing message from notifier 5 | 400 | + + + @delete_channel + Scenario Outline: Send notification with lowercase and uppercase the first letter of the priority + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | status_code | + | normal | #general | Test1 | A testing message from notifier 1 | 400 | + | high | #general | Test2 | A testing message from notifier 2 | 400 | + | Normal | #general | Test3 | A testing message from notifier 3 | 400 | + | High | #general | Test4 | A testing message from notifier 4 | 400 | + diff --git a/features/functional/notifications/negative_post_notification_without_parameters.feature b/features/functional/notifications/negative_post_notification_without_parameters.feature new file mode 100644 index 0000000..7702bbb --- /dev/null +++ b/features/functional/notifications/negative_post_notification_without_parameters.feature @@ -0,0 +1,50 @@ +@all @functional +Feature: Negative responses after making a post request + + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send a new notification without parameter required + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + + + + + + } + """ + And I execute the request to the endpoint + Then I expect a '400' status code + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | parameter_channelID | parameter_priority | parameter_recipients | parameter_subject | parameter_content | error | + | | "priority" : "NORMAL", | "recipients" : ["#general"], | "subject" : "Test", | "content" : "A testing message from notifier" | {"field": "channelId","code": "channelId.required","defaultMessage": null} | + | "channelId": $channels_id, | "priority" : "NORMAL", | | "subject" : "Test", | "content" : "A testing message from notifier" | {"field": "recipients","code": "NotEmpty","defaultMessage": "may not be empty"},{"field": "recipients","code":"recipients.valid","defaultMessage": null} | + | "channelId": $channels_id, | "priority" : "NORMAL", | "recipients" : ["#general"], | "subject" : "Test" | | {"field": "content","code": "content.required","defaultMessage": null} | + | | | | | | {"field": "recipients","code": "NotEmpty","defaultMessage": "may not be empty"},{"field": "channelId","code": "channelId.required", "defaultMessage": null},{"field": "recipients","code": "recipients.valid","defaultMessage": null},{"field": "content","code": "content.required", "defaultMessage": null} | \ No newline at end of file diff --git a/features/functional/notifications/negative_post_resend_notification.feature b/features/functional/notifications/negative_post_resend_notification.feature new file mode 100644 index 0000000..cc2543a --- /dev/null +++ b/features/functional/notifications/negative_post_resend_notification.feature @@ -0,0 +1,72 @@ +@all @functional +Feature: Negative responses after making a post request + + Background: Send a notification + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#recipient_one","#recipient_two"], + "subject": "Test API", + "content": "A testing message from notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + + @delete_channel + Scenario Outline: Resend notification with non-existent recipient in the notification for resend. + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | | + When I execute the request to the endpoint + Then I expect a '404' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 404, + "error": "Not Found", + "exception": "javax.persistence.EntityNotFoundException", + "message": "The recipient '' was not found in the notification recipients." + } + """ + Examples: + | name_of_recipient | + | #non_existent_recipient | + | #random_recipient | + | #non_existent_recipient, #random_recipient | + + @delete_channel + Scenario Outline: Resend notification with non-existent recipient in the notification for resend. + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | | + When I execute the request to the endpoint + Then I expect a '404' status code + And excluding 'timestamp' and 'path' the response body contains: + """ + { + "status": 404, + "error": "Not Found", + "exception": "javax.persistence.EntityNotFoundException", + "message": "The recipient '' was not found in the notification recipients." + } + """ + Examples: + | name_of_recipient | + | #non_existent_recipient | + | #random_recipient | + | #non_existent_recipient, #random_recipient | \ No newline at end of file diff --git a/features/functional/notifications/post_notification_for_SLACK.feature b/features/functional/notifications/post_notification_for_SLACK.feature new file mode 100644 index 0000000..06af0b7 --- /dev/null +++ b/features/functional/notifications/post_notification_for_SLACK.feature @@ -0,0 +1,102 @@ +@all @functional +Feature: Functional post for Notification for SLACK + + Background: Create a Channel for SLACK + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "Channel-for-SLACK", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send notification only with the necessary parameters + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [""], + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | recipients | content | status_code | + | #general | A testing message from notifier 1 | 200 | + + @delete_channel + Scenario Outline: Send notification with the two predetermined priorities + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | priority | recipients | subject | content | status_code | + | HIGH | #general | Test1 | A testing message from notifier 1 | 200 | + | NORMAL | #main | Test2 | A testing message from notifier 2 | 200 | + + @delete_channel + Scenario Outline: Send notification with different types of channel Id data + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": , + "recipients": [""], + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | channel_id | recipients | content | + | "$channels_id" | #general | A testing message from notifier 1 | + | $channels_id.5 | #general | A testing message from notifier 2 | + | $channels_id.435 | #general | A testing message from notifier 3 | + | $channels_id.645 | #general | A testing message from notifier 4 | + | $channels_id.999 | #general | A testing message from notifier 5 | + + @delete_channel + Scenario Outline: Sending notification to multiple recipients + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [], + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | recipients | content | + | "#recipient_one" | A testing message from notifier 1 | + | "#recipient_one" ,"#recipient_two" | A testing message from notifier 2 | + | "#recipient_one" ,"#recipient_two","#recipient_three" | A testing message from notifier 3 | + | "#recipient_one" ,"#recipient_two","#recipient_three","#recipient_four" | A testing message from notifier 4 | + | "#recipient_one" ,"#recipient_two","#recipient_three","#recipient_four","#recipient_five" | A testing message from notifier 5 | diff --git a/features/functional/notifications/post_notification_for_TWITTER.feature b/features/functional/notifications/post_notification_for_TWITTER.feature new file mode 100644 index 0000000..7d0763a --- /dev/null +++ b/features/functional/notifications/post_notification_for_TWITTER.feature @@ -0,0 +1,47 @@ +@all @functional @bug +Feature: Functional post for Notification for TWITTER + + Background: Create a Channel for TWITTER + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "Channel-for-TWITTER", + "type": "TWITTER", + "configuration": { + "access_token": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", + "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", + "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", + "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send a new notification with the two different priorities + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + And I build the response for "notification" with + """ + { + "attachments": null, + "templateId": null + } + """ + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'FAILED' + Examples: + | priority | recipients | subject | content | status_code | + | HIGH | testing_at04 | Test1 | A testing message from notifier 1 | 200 | + | NORMAL | testing_at0401 | Test2 | A testing message from notifier 2 | 200 | diff --git a/features/functional/notifications/post_notification_for_WEB_HOOK.feature b/features/functional/notifications/post_notification_for_WEB_HOOK.feature new file mode 100644 index 0000000..805626b --- /dev/null +++ b/features/functional/notifications/post_notification_for_WEB_HOOK.feature @@ -0,0 +1,44 @@ +@all @functional +Feature: Functional post for Notification for WEB-HOOK + + Background: Create a Channel for WEB-HOOK + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "Channel-for-WEB-HOOK", + "type": "WEB_HOOK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + + @delete_channel + Scenario Outline: Send a new notification with the two different priorities + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "", + "recipients": [""], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I save the 'id' of 'notification' + And I build the response for "notification" with + """ + { + "attachments": null, + "templateId": null + } + """ + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + Examples: + | priority | recipients | subject | content | status_code | + | HIGH | #general | Test1 | A testing message from notifier 1 | 200 | + | NORMAL | #main | Test2 | A testing message from notifier 2 | 200 | diff --git a/features/functional/notifications/post_notification_with_template.feature b/features/functional/notifications/post_notification_with_template.feature new file mode 100644 index 0000000..12287c6 --- /dev/null +++ b/features/functional/notifications/post_notification_with_template.feature @@ -0,0 +1,52 @@ +@all @functional +Feature: Negative post notification with templates + + + Background: Create new template and new channel + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for test notification", + "subjectTemplate": "${information}", + "contentTemplate": "Email address. \n${email} \nwith security code: ${code}", + "description": "Template Demo" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "Channel test resend AS:", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + + @delete_channel @delete_templates + Scenario: resend a notification without param + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId":$channels_id, + "templateId":$templates_id, + "priority":"HIGH", + "recipients":["#general"], + "subject":"{ \"information\" : \"Verify email\"}", + "content":"{ \"email\":\"juan@jalasoft.com\", \"code\": 50}" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + diff --git a/features/functional/notifications/post_resend_notification.feature b/features/functional/notifications/post_resend_notification.feature new file mode 100644 index 0000000..dd1dfb3 --- /dev/null +++ b/features/functional/notifications/post_resend_notification.feature @@ -0,0 +1,72 @@ +@all @functional +Feature: Functional post for Resend Notification + + Background: Send a notification + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#recipient_one","#recipient_two"], + "subject": "Test API", + "content": "A testing message from notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + + @delete_channel + Scenario: Resend notification with name of recipient. + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | #recipient_one | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "notification" with + """ + { + "attachments": {}, + "templateId": null + } + """ + And The response body is the same as builded + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'RE_SENT' + + @delete_channel + Scenario: Resend notification without name of recipient. + Given I make a 'POST' request to '/notifications/events/$id/resend' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "notification" with + """ + { + "attachments": {}, + "templateId": null + } + """ + And The response body is the same as builded + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' + + @delete_channel + Scenario Outline: Resend to only one of the notification recipients. + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | | + When I execute the request to the endpoint + Then I expect a '200' status code + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'RE_SENT' + Examples: + | name_of_recipient | + | #recipient_two | diff --git a/features/functional/templates/get_templates_params_name.feature b/features/functional/templates/get_templates_params_name.feature new file mode 100644 index 0000000..22e1dc8 --- /dev/null +++ b/features/functional/templates/get_templates_params_name.feature @@ -0,0 +1,64 @@ +@all @functional +Feature: get templates with params name + + Background: : create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "My template at-04", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + @delete_templates + Scenario: Get template with params name + Given I make a 'GET' request to '/templates' with: + | name | My template at-04| + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "templates" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + + @delete_templates + Scenario: Get template with params name and ignore case + Given I make a 'GET' request to '/templates' with: + | name | My template at-04 | + | ignoreCase | true | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "templates" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + + @delete_templates + Scenario: Get template with params name and ignore case + Given I make a 'GET' request to '/templates' with: + | name | My template at-04 | + | ignoreCase | false | + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "templates" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded \ No newline at end of file diff --git a/features/functional/templates/negative_delete_template_invalid_id.feature b/features/functional/templates/negative_delete_template_invalid_id.feature new file mode 100644 index 0000000..49c080f --- /dev/null +++ b/features/functional/templates/negative_delete_template_invalid_id.feature @@ -0,0 +1,38 @@ +@all @functional +Feature: Functional get for templates with ID + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario Outline: Send a new template + Given I make a 'DELETE' request to '/templates/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + + Examples: + | id | status_code | description | + | DIKE@$# | 400 | Send an invalid id (letters) | + | asd13asd | 400 | Send an invalid id (letters and number) | + | 1 | 404 | Send a non-exist id | + | | 405 | Send an empty id | + | -3 | 404 | Send an id less or equals to 0 | + | 0 | 404 | Send an id 0 | diff --git a/features/functional/templates/negative_get_templates_invalid_endpoint.feature b/features/functional/templates/negative_get_templates_invalid_endpoint.feature new file mode 100644 index 0000000..d7b2f1d --- /dev/null +++ b/features/functional/templates/negative_get_templates_invalid_endpoint.feature @@ -0,0 +1,40 @@ +@functional @all +Feature: get templates with invalid endpoint + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + @delete_templates + Scenario Outline: Can't find a template with invalid endpoint + Given I make a 'GET' request to '//$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And the response body contains excluding 'timestamp': + """ + { + "timestamp": 1507389627623, + "status": 404, + "error": "Not Found", + "message": "Not Found", + "path": "/api//$id" + } + """ + Examples: + | Endpoint | + | template | + | template123 | + | . | + | TEMPLATES | + | teeemmplllates | + | | + | template24!@#$@!| diff --git a/features/functional/templates/negative_get_templates_invalid_id.feature b/features/functional/templates/negative_get_templates_invalid_id.feature new file mode 100644 index 0000000..902ca03 --- /dev/null +++ b/features/functional/templates/negative_get_templates_invalid_id.feature @@ -0,0 +1,39 @@ +@functional @all +Feature: Functional get for templates with ID + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario Outline: Send a new template + Given I make a 'GET' request to '/templates/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + + Examples: + | id | status_code | description | + | DIKJAS | 400 | Send an invalid id (letters) | + | asd13asd | 400 | Send an invalid id (letters and number) | + | 1 | 404 | Send a non-exist id | + | | 200 | Send an empty id | + | -3 | 404 | Send an id less or equals to 0 | + | 0 | 404 | Send an id 0 | + diff --git a/features/functional/templates/negative_get_templates_params.feature b/features/functional/templates/negative_get_templates_params.feature new file mode 100644 index 0000000..3d6a0f6 --- /dev/null +++ b/features/functional/templates/negative_get_templates_params.feature @@ -0,0 +1,48 @@ +@all @functional +Feature: get templates with params name + + Background: : create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "My template at-04", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + @delete_templates + Scenario Outline: Get template with params name + Given I make a 'GET' request to '/templates' with: + | name | | + When I execute the request to the endpoint + Then I expect a '' status code +Examples: + | name | status | + | | 404 | + | rgdfg | 404 | + | 3243hghtr| 404 | + | . | 400 | + | #$%$#&%/| 400 | + + + + @delete_templates + Scenario Outline: Get template with params name and empty ignore case + Given I make a 'GET' request to '/templates' with: + | name | My template at-04 | + | ignoreCase | | + When I execute the request to the endpoint + Then I expect a '' status code + Examples: + | ignoreCase | status | + | | 400 | + | t | 400 | + | 3243hghtr | 400 | + | . | 400 | + | #$%$#&%/ | 400 | + | 34325 | 400 | + | tru | 400 | \ No newline at end of file diff --git a/features/functional/templates/negative_post_templates_invalid_content_template_params.feature b/features/functional/templates/negative_post_templates_invalid_content_template_params.feature new file mode 100644 index 0000000..322348c --- /dev/null +++ b/features/functional/templates/negative_post_templates_invalid_content_template_params.feature @@ -0,0 +1,144 @@ +@all @functional +Feature: created template + + @delete_templates + Scenario: create a new template with invalid or empty content Template params + Given I make a 'POST' request to '/templates' endpoint + When I generate 'a' letter 2147483648 times and save for 'contentTemplate' field + And I set the body with name: + """ + { + "name": "name at-04", + "subjectTemplate": "template1", + "contentTemplate": $contentTemplate, + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "contentTemplate", + "code": "Size", + "defaultMessage": "size must be between 20 and 2147483647" + } + ], + "message": "Bad Request", + "path": "/templates" + } + """ + + + @delete_templates + Scenario Outline: Create a new template with invalid or empty contentTemplate + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": "template at-04 team", + "subjectTemplate": "test_template", + "contentTemplate": "", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And excluding 'timestamp' and 'exception' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "errors": [ + { + "field": "contentTemplate", + "code": "Size", + "defaultMessage": "size must be between 20 and 2147483647" + } + ], + "message": "Bad Request", + "path": "/templates" + } + """ + + Examples: + | contentTemplate | + | trfg | + | | + | $ | + | 1 | + | . | + | 22 | + + + @delete_templates + Scenario: Create a new template without content Template params + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": "template at-04 team", + "subjectTemplate": "test_template", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And the response body contains excluding 'timestamp': + """ + { + "timestamp": 1507651901739, + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "contentTemplate", + "code": "NotNull", + "defaultMessage": "may not be null" + } + ], + "message": "Bad Request", + "path": "/templates" + } + """ + + + @delete_templates + Scenario Outline: Create a new template with invalid or empty contentTemplate values + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": "template at-04 team", + "subjectTemplate": "test_template", + "contentTemplate": "", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And excluding 'timestamp' and 'exception' the response body contains: + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/templates" + } + """ + + Examples: + | contentTemplate | + | " " | + | .................... | + | " ." | diff --git a/features/functional/templates/negative_post_templates_invalid_name_params.feature b/features/functional/templates/negative_post_templates_invalid_name_params.feature new file mode 100644 index 0000000..7bb750d --- /dev/null +++ b/features/functional/templates/negative_post_templates_invalid_name_params.feature @@ -0,0 +1,179 @@ +@all @functional +Feature: created template + @delete_templates + Scenario: create a new template with invalid or empty name params + Given I make a 'POST' request to '/templates' endpoint + When I generate 'a' letter 257 times and save for 'name' field + And I set the body with name: + """ + { + "name": "$name", + "subjectTemplate": "template1", + "contentTemplate": "This is a new complete template.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And the response body contains excluding 'timestamp': + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "name", + "code": "Size", + "defaultMessage": "size must be between 4 and 256" + } + ], + "message": "Bad Request", + "path": "/templates" + } + """ + + + @delete_templates + Scenario Outline: Create a new template with invalid or empty name + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": , + "subjectTemplate": "template1", + "contentTemplate": "This is a new complete template.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And excluding 'timestamp' and 'exception' the response body contains: + """ +{ + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/templates" +} + """ + + Examples: + | Name | + | tr | + | $ | + | #$%&/( | + | . | + | | + | a | + + + @delete_templates + Scenario: Create a new template without name params + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "subjectTemplate": "template1", + "contentTemplate": "This is a new complete template.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And the response body contains excluding 'timestamp': + + """ + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "name", + "code": "NotNull", + "defaultMessage": "may not be null" + } + ], + "message": "Bad Request", + "path": "/templates" +} + """ + + + @delete_templates + Scenario Outline: Create a new template with invalid or empty name + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": , + "subjectTemplate": "template1", + "contentTemplate": "This is a new complete template.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And excluding 'timestamp' and 'exception' the response body contains: + """ +{ + "status": 400, + "error": "Bad Request", + "errors": [ + { + "field": "name", + "code": "Size", + "defaultMessage": "size must be between 4 and 256" + } + ], + "message": "Bad Request", + "path": "/templates" +} + + """ + + Examples: + | Name | + | "sd" | + | 1 | + + + + + @delete_templates + Scenario: Create a new template with invalid or empty name + Given I make a 'POST' request to '/templates' endpoint + And I set the body as: + """ + { + "name": " ", + "subjectTemplate": "template1", + "contentTemplate": "This is a new complete template.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + And I save the 'id' of 'templates' + And excluding 'timestamp' and 'exception' the response body contains: + """ +{ + "status": 400, + "error": "Bad Request", + "errors": [ + { + "field": "name", + "code": "name.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/templates" +} + + """ diff --git a/features/functional/templates/negative_put_template_with_param.feature b/features/functional/templates/negative_put_template_with_param.feature new file mode 100644 index 0000000..36a2bf5 --- /dev/null +++ b/features/functional/templates/negative_put_template_with_param.feature @@ -0,0 +1,125 @@ +@functional @all +Feature: Functional put for notification with several name param + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "New Template", + "contentTemplate": "This template has been created." + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario Outline: send several case for the param + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "", + "subjectTemplate": "", + "contentTemplate": "", + "description": "" + + } + """ + When I execute the request to the endpoint + Then I expect a '' status code + + + Examples: + | name | subject | content | description | status | +# | send more 256? | subject is valid for this case | subject is valid for this case | description is valid | 400 | + | Test @#!@# 12 | subject is valid for this case | content is valid for this case | description is valid | 200 | + | Tes | subject is valid for this case | content is valid for this case | description is valid | 400 | + | | subject is valid for this case | content is valid for this case | description is valid | 400 | +# | Valid name | send more 256? | content is valid for this case | description is valid | 400 | + | Valid name | Test invalid !@#!3 123 @$#123 | content is valid for this case | description is valid | 200 | + | Valid name | | content is valid for this case | description is valid | 400 | +# | Valid name | subject is valid for this case | send more 2147483647 | description is valid | 400 | + | Valid name | subject is valid for this case | less 20 characters | description is valid | 400 | + | Valid name | subject is valid for this case | | description is valid | 400 | + | Valid name | subject is valid for this case | content is valid for this case | | 200 | + | Valid name | subject is valid for this case | content is valid for this case | description is valid | 200 | + + @delete_templates + Scenario: send without param name + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "subjectTemplate": "subject is valid for this case", + "contentTemplate": "content is valid for this case", + "description": "description is valid" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + + @delete_templates + Scenario: send without param subject + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "test template", + "contentTemplate": "content is valid for this case", + "description": "description is valid" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "template" with + """ + { + "subjectTemplate": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario: send without param content + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "test template", + "subjectTemplate": "subject is valid for this case", + "description": "description is valid" + } + """ + When I execute the request to the endpoint + Then I expect a '400' status code + + @delete_templates + Scenario: send without param description + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "test template", + "subjectTemplate": "subject is valid for this case", + "contentTemplate": "content is valid for this case" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "template" with + """ + { + "description": null + } + """ + And The response body is the same as builded \ No newline at end of file diff --git a/features/functional/templates/negative_put_templates_invalid_id.feature b/features/functional/templates/negative_put_templates_invalid_id.feature new file mode 100644 index 0000000..a85d4ed --- /dev/null +++ b/features/functional/templates/negative_put_templates_invalid_id.feature @@ -0,0 +1,45 @@ +@functional @all +Feature: Functional post for templates with ID + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario Outline: Send a new template + Given I make a 'PUT' request to '/templates/' endpoint + When I set the body as: + """ + { + "name": "new Template", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '' status code + + Examples: + | id | status_code | description | + | DIKJAS | 400 | Send an invalid id (letters) | + | asd13asd | 400 | Send an invalid id (letters and number) | + | 1 | 404 | Send a non-exist id | + | | 405 | Send an empty id | + | -3 | 404 | Send an id less or equals to 0 | + | 0 | 404 | Send an id 0 | diff --git a/features/functional/templates/post_template.feature b/features/functional/templates/post_template.feature new file mode 100644 index 0000000..6f1cda9 --- /dev/null +++ b/features/functional/templates/post_template.feature @@ -0,0 +1,22 @@ +@all @functional +Feature: created template + + Scenario: create a new template with all params + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template complete", + "subjectTemplate": "template", + "contentTemplate": "This is a new complete template by at-04.", + "description": "template" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I capture the response to the endpoint + Given I make a 'GET' request to '/templates/$id' endpoint + And I execute the request to the endpoint + Then I expect POST response is the same as GET response + diff --git a/features/functional/templates/template_has_been_deleted.feature b/features/functional/templates/template_has_been_deleted.feature new file mode 100644 index 0000000..e9bc6bc --- /dev/null +++ b/features/functional/templates/template_has_been_deleted.feature @@ -0,0 +1,43 @@ +@functional @all +Feature: Functional get for templates with ID + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "New Template", + "contentTemplate": "This template has been created." + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + Given I make a 'Delete' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + + @delete_templates + Scenario: delete a template that has been deleted + Given I make a 'Delete' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code + + @delete_templates + Scenario: get a template that has been deleted + Given I make a 'GET' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect a '404' status code + + @delete_templates + Scenario: put a template that has been deleted + Given I make a 'PUT' request to '/templates/$id' endpoint + When I set the body as: + """ + { + "name": "New Template", + "contentTemplate": "This template has been created." + } + """ + When I execute the request to the endpoint + Then I expect a '404' status code \ No newline at end of file diff --git a/features/functional/templates/template_with_front_zeros.feature b/features/functional/templates/template_with_front_zeros.feature new file mode 100644 index 0000000..0a1127f --- /dev/null +++ b/features/functional/templates/template_with_front_zeros.feature @@ -0,0 +1,65 @@ +@all @functional +Feature: Functional get for templates with ID + + Background: create a new template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "Template for update", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario: Delete template when I send an id with zeros by front + Given I make a 'DELETE' request to '/templates/000$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I expect that the GET response it is empty + + @delete_templates + Scenario: Get template when I send an id with zeros by front + Given I make a 'GET' request to '/templates/000$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "template" with + """ + { + "subjectTemplate": null, + "description": null + } + """ + And The response body is the same as builded + + @delete_templates + Scenario: Put template when I send an id with zeros by front + Given I make a 'PUT' request to '/templates/000$id' endpoint + When I set the body as: + """ + { + "name": "new Template", + "subjectTemplate": "subject of the template", + "contentTemplate": "This should be at least 20 chars" + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I build the response for "template" with + """ + { + "description": null + } + """ + And The response body is the same as builded \ No newline at end of file diff --git a/features/smoke/channels_templates.feature b/features/smoke/channels_templates.feature new file mode 100644 index 0000000..48c91b5 --- /dev/null +++ b/features/smoke/channels_templates.feature @@ -0,0 +1,11 @@ +@smoke @all +Feature: Channels and Templates + + Scenario Outline: Get all + Given I make a 'GET' request to '' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code + Examples: + | endpoint | + | /channels | + | /templates | \ No newline at end of file diff --git a/features/smoke/specific_channel.feature b/features/smoke/specific_channel.feature new file mode 100644 index 0000000..f9f0205 --- /dev/null +++ b/features/smoke/specific_channel.feature @@ -0,0 +1,24 @@ +@smoke @all +Feature: Specific Channels + + Background: Create a Channel + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo-for-A-Specific-Channel", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'channels' + + @delete_channel + Scenario: Get a specific channel + Given I make a 'GET' request to '/channels/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code diff --git a/features/smoke/specific_notification.feature b/features/smoke/specific_notification.feature new file mode 100644 index 0000000..bdfe17e --- /dev/null +++ b/features/smoke/specific_notification.feature @@ -0,0 +1,35 @@ +@smoke @all +Feature: Specific Notification + + Background: Create a notification + Given I create a 'channel' with status code '200' and body as: + """ + { + "name": "AT04-Slack-Demo-for-Get-Specific-Notification", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + } + } + """ + And I save the 'id' of 'channels' + Then I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $channels_id, + "priority": "HIGH", + "recipients": ["#general"], + "subject": "Test API", + "content": "A testing message from notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the 'id' of 'notification' + + @delete_channel + Scenario: Get a specific Notification + Given I make a 'GET' request to '/notifications/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code \ No newline at end of file diff --git a/features/smoke/specific_template.feature b/features/smoke/specific_template.feature new file mode 100644 index 0000000..b5e7cd2 --- /dev/null +++ b/features/smoke/specific_template.feature @@ -0,0 +1,21 @@ +@smoke @all +Feature: Specific Template + + Background: Create a Template + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name" : "New Template", + "subjectTemplate":"${information}", + "contentTemplate":"Jalasoft account \nVerify your email address \n \nTo finish setting up this Microsoft account, we just need to make sure this email address is yours. \n${email} \nOr you may be asked to enter this security code: ${code} \nThanks, \nThe Jalasoft account team." + } + """ + And I execute the request to the endpoint + Then I expect a '201' status code + And I save the 'id' of 'templates' + + Scenario: Get a specific Template + Given I make a 'GET' request to '/templates/$id' endpoint + When I execute the request to the endpoint + Then I expect a '200' status code \ No newline at end of file diff --git a/features/step_definitions/assert/.gitignore b/features/step_definitions/assert/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb new file mode 100644 index 0000000..b89a338 --- /dev/null +++ b/features/step_definitions/common/steps.rb @@ -0,0 +1,109 @@ +Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| + @request = ApiRequest.new(EndpointBuilder.builder(endpoint)) + @request.method = method +end + +When(/^I execute the request to the endpoint$/) do + @response = RequestManager.execute_request(@request) +end + +Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| + expect(@response.code).to eql(status_code_expected.to_i) +end + +And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| + @request = ApiRequest.new(EndpointBuilder.param(endpoint, param.raw)) + @request.method = method +end + +Then(/^The response body is$/) do |expected_body| + expect(JSON.parse(@response.body)).to eq JSON.parse(expected_body) +end + +When(/^I set the body as:$/) do |body| + @body = body + @request.body = body +end + +When(/^I set the body with (?:\w+):$/) do |body| + @body = BodyBuilder.builder(body) + @request.body = BodyBuilder.builder(body) + puts @body +end + +When(/^I save the '(\w+)' of '(channels|notification|templates)'$/) do |name, type| + # $identifier_name = name + $identifier_name = "#{type}_#{name}" + $id_hash.store($identifier_name, JSON.parse(@response.body)[name]) +end + +Then(/^I build the response for "([^"]*)" with$/) do |template, json| + @builded_hash = ResponseManager.build_response(template, @body, json, @response.body) +end + +Then(/^The response body is the same as builded$/) do + expect(@builded_hash.to_json).to eq @response.body + puts @builded_hash.to_json + puts @response.body +end + +Then(/^I capture the response to the endpoint$/) do + @stored_response = @response.body +end + +Then(/^I expect (?:PUT|POST) response is the same as GET response$/) do + expect(@response.body).to eq @stored_response + @response.body + @stored_response +end + +Then(/^I expect that the GET response it is empty$/) do + expect(@response.body).to eq '' +end + +And(/^I make a '(GET)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| + $app_max_wait_time.times do + sleep 1 + steps %{ + And I make a '#{method}' request to '#{endpoint}' endpoint + And I execute the request to the endpoint + } + @result_expected = JSON.parse(@response.body)[field][params] + break if @result_expected == value + end + expect(value).to eq @result_expected +end + +Given(/^I create a '(channel|template)' with status code '(\d+)' and body as:$/) do |type, status, body| + steps %{ + Given I make a 'POST' request to '/#{type}s' endpoint + When I set the body as: + """ + #{body} + """ + And I execute the request to the endpoint + Then I expect a '#{status}' status code + } +end + +Then(/^the response body contains excluding '([^"]*)':$/) do |exclude, json| + expect(json).to be_json_eql(@response.body).excluding(exclude) + puts json + puts @response.body +end + +Then(/^excluding '([^"]*)' and '(.*)' the response body contains:$/) do |exclude1, exclude2, json| + expect(json).to be_json_eql(@response.body).excluding(exclude1, exclude2) + puts json + puts @response.body +end + +Then(/^I generate '(\w+)' letter (\d+) times and save for '(\w+)' field$/) do |letter, n, field| + $id_hash.store(field, RequestManager.generator(letter, n)) +end + +Then(/^The response body should contain the builded response$/) do + expect(ResponseManager.contains_json(@builded_hash.to_json, @response.body)).to be(true) + puts @builded_hash.to_json + puts @response.body +end diff --git a/features/step_definitions/request/.gitignore b/features/step_definitions/request/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000..9e63811 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,42 @@ +require 'json' +require 'json_spec/cucumber' +require 'pathname' +require 'pg' +require 'rest-client' +require 'yaml' +$id_hash = {} +def find_config_file(filename) + root = Pathname.pwd + until root.root? + root.find do |path| + return path.to_s if path.file? && path.basename.to_s == filename + end + root = root.parent + end + raise 'Configuration file ' +end + +def load_app_config_file(filename) + config_file = find_config_file(filename) + config = YAML.load_file(config_file) + $app_context = config['app']['rootPath'] + config +end + +AfterConfiguration do + configuration = load_app_config_file('env.yml') + $app_host = configuration['app']['host'] + $app_port = configuration['app']['port'] + $app_root = configuration['app']['rootPath'] + $app_max_wait_time = configuration['app']['maxWaitTime'] + $bd_connection = configuration['database']['connection'] + $bd_host = configuration['database']['host'] + $bd_port = configuration['database']['port'] + $bd_database = configuration['database']['database'] + $bd_username = configuration['database']['username'] + $bd_password = configuration['database']['password'] +end + +def last_json + # Just for initialize +end diff --git a/features/support/env.yml b/features/support/env.yml new file mode 100644 index 0000000..46aadf9 --- /dev/null +++ b/features/support/env.yml @@ -0,0 +1,14 @@ +app: + host: + port: + rootPath: + maxWaitTime: + + +database: + connection: + host: + port: + database: + username: + password: diff --git a/features/support/env_yml.example b/features/support/env_yml.example new file mode 100644 index 0000000..5bb807b --- /dev/null +++ b/features/support/env_yml.example @@ -0,0 +1,12 @@ +app: + host: http://12.43.3.94 + port: 8080 + rootPath: /api/v2 + +database: + connection: postgres + host: 127.0.0.1 + port: 3306 + database: home + username: username + password: secret \ No newline at end of file diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb new file mode 100644 index 0000000..25dae27 --- /dev/null +++ b/features/support/hooks/hooks.rb @@ -0,0 +1,15 @@ +# Delete channel +After('@delete_channel') do + endpoint = "/channels/#{$id_hash['channels_id']}" + request = ApiRequest.new(endpoint) + request.method = 'DELETE' + RequestManager.execute_request(request) +end + +# Delete templates +After('@delete_templates') do + endpoint = "/templates/#{$id_hash['templates_id']}" + request = ApiRequest.new(endpoint) + request.method = 'DELETE' + RequestManager.execute_request(request) +end diff --git a/features/support/utils/api_request.rb b/features/support/utils/api_request.rb new file mode 100644 index 0000000..084d7a0 --- /dev/null +++ b/features/support/utils/api_request.rb @@ -0,0 +1,12 @@ +# ApiRequest class. +class ApiRequest + attr_reader :header, :url + attr_accessor :body, :method + + def initialize(endpoint) + @endpoint = endpoint + @header = { :'Content-Type' => 'application/json' } + @body = {} + @url = "#{$app_host}#{$app_root}#{endpoint}" + end +end diff --git a/features/support/utils/body_builder.rb b/features/support/utils/body_builder.rb new file mode 100644 index 0000000..86ef50e --- /dev/null +++ b/features/support/utils/body_builder.rb @@ -0,0 +1,9 @@ +# This module build endpoint with id and params +module BodyBuilder + def self.builder(body) + $id_hash.each do |key, value| + body = body.gsub("$#{key}", value.to_s) + end + body + end +end diff --git a/features/support/utils/database_manager.rb b/features/support/utils/database_manager.rb new file mode 100644 index 0000000..870e35f --- /dev/null +++ b/features/support/utils/database_manager.rb @@ -0,0 +1,10 @@ +# Conect to Database +module DatabaseManager + def self.conn + PG.connect host: $bd_host, + port: $bd_port, + dbname: $bd_database, + user: $bd_username, + password: $bd_password + end +end diff --git a/features/support/utils/endpoint_builder.rb b/features/support/utils/endpoint_builder.rb new file mode 100644 index 0000000..ec850ab --- /dev/null +++ b/features/support/utils/endpoint_builder.rb @@ -0,0 +1,16 @@ +# This module build endpoint with id and params +module EndpointBuilder + def self.builder(endpoint) + endpoint.gsub('$id', $id_hash[$identifier_name].to_s) + end + + def self.param(endpoint, param) + point = builder endpoint + param.each_with_index do |value, index| + params = "#{value[0].gsub(' ', '%20')}=#{value[1].gsub(' ', '%20')}" + params = "#{params.gsub('#', '%23')}" + point = index.to_i.zero? ? "#{point}?#{params}" : "#{point}&#{params}" + end + point + end +end diff --git a/features/support/utils/request_manager.rb b/features/support/utils/request_manager.rb new file mode 100644 index 0000000..53d4e1c --- /dev/null +++ b/features/support/utils/request_manager.rb @@ -0,0 +1,19 @@ +# Request Manager class. +module RequestManager + def self.execute_request(api_request) + RestClient::Request.execute(method: api_request.method, + url: api_request.url, + payload: api_request.body, + headers: api_request.header) + rescue RestClient::ExceptionWithResponse => error + error.response + end + + def self.generator(l, n) + cad = '' + n.to_i.times do + cad += l.to_s + end + cad + end +end diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb new file mode 100644 index 0000000..1685686 --- /dev/null +++ b/features/support/utils/response_manager.rb @@ -0,0 +1,52 @@ +# Manage the conversion of hashes and string to json +module ResponseManager + def self.parse_file(filename) + base_path = File.dirname(__FILE__) + path = "#{base_path}/templates/#{filename}.json" + file = File.read(path) + @template = JSON.parse(file) + @copy = @template.is_a?(Hash) ? Hash[@template] : [].replace(@template) + end + + def self.replace_elements_in_collection(collection) + if @template.is_a?(Hash) + @template.each_key do |key| + @copy[key] = collection[key] if !(@template[key].eql? collection[key]) && (collection.key? key) + end + else + @template.first.each_key do |key| + @copy.first[key] = collection[key] if !(@template.first[key].eql? collection[key]) && (collection.key? key) + end + end + @copy + end + + def self.diff_elements_in_collection(collection) + if @copy.is_a?(Hash) + collection.delete_if { |key| !(@copy[key].eql? @template[key]) } + else + collection.delete_if { |key| !(@copy.first[key].eql? @template.first[key]) } + end + end + + def self.build_response(filename, request, expected, response) + parse_file(filename) + replace_elements_in_collection(JSON.parse(request)) + replace_elements_in_collection(JSON.parse(expected)) + if @copy.is_a?(Hash) + replace_elements_in_collection(diff_elements_in_collection(JSON.parse(response))) + else + replace_elements_in_collection(diff_elements_in_collection(JSON.parse(response).first)) + end + @copy + end + + def self.contains_json(expected, response) + expected = JSON.parse(expected) + response = JSON.parse(response) + response.each do |key| + return true if key == expected.first + end + false + end +end diff --git a/features/support/utils/templates/channel.json b/features/support/utils/templates/channel.json new file mode 100644 index 0000000..68678c1 --- /dev/null +++ b/features/support/utils/templates/channel.json @@ -0,0 +1,8 @@ +{ + "id": "integer", + "name": "string", + "type": "string", + "configuration": { + }, + "onFail": "boolean" +} diff --git a/features/support/utils/templates/channels.json b/features/support/utils/templates/channels.json new file mode 100644 index 0000000..029e69c --- /dev/null +++ b/features/support/utils/templates/channels.json @@ -0,0 +1,10 @@ +[ + { + "id": "integer", + "name": "string", + "type": "string", + "configuration": { + }, + "onFail": "boolean" + } +] diff --git a/features/support/utils/templates/error.json b/features/support/utils/templates/error.json new file mode 100644 index 0000000..6946f86 --- /dev/null +++ b/features/support/utils/templates/error.json @@ -0,0 +1,8 @@ +{ + "timestamp": "integer", + "status": "integer", + "error": "string", + "exception": "string", + "message": "string", + "path": "string" +} diff --git a/features/support/utils/templates/notification.json b/features/support/utils/templates/notification.json new file mode 100644 index 0000000..ac66993 --- /dev/null +++ b/features/support/utils/templates/notification.json @@ -0,0 +1,11 @@ +{ + "id": "integer", + "channelId": "integer", + "priority": "string", + "status": "string", + "recipients": ["string"], + "subject": "string", + "attachments": "boolean", + "content": "string", + "templateId": "boolean" +} diff --git a/features/support/utils/templates/notification_status_history.json b/features/support/utils/templates/notification_status_history.json new file mode 100644 index 0000000..ae9ab56 --- /dev/null +++ b/features/support/utils/templates/notification_status_history.json @@ -0,0 +1,21 @@ +{ + "notification": { + "id": "string", + "channelId": "integer", + "priority": "string", + "status": "string", + "recipients": ["string"], + "subject": "string", + "attachments": {}, + "content": "string", + "templateId": "boolean" + }, + "statusHistory": [ + { + "id": "integer", + "status": "string", + "message": "boolean", + "updatedOn": "string" + } + ] +} \ No newline at end of file diff --git a/features/support/utils/templates/template.json b/features/support/utils/templates/template.json new file mode 100644 index 0000000..a541bb1 --- /dev/null +++ b/features/support/utils/templates/template.json @@ -0,0 +1,7 @@ +{ + "id": "Integer", + "name": "string", + "subjectTemplate": "string", + "contentTemplate": "string", + "description": "string" +} \ No newline at end of file diff --git a/features/support/utils/templates/templates.json b/features/support/utils/templates/templates.json new file mode 100644 index 0000000..9203f01 --- /dev/null +++ b/features/support/utils/templates/templates.json @@ -0,0 +1,9 @@ +[ + { + "id": "Integer", + "name": "string", + "subjectTemplate": "string", + "contentTemplate": "string", + "description": "string" + } +] \ No newline at end of file diff --git a/reports/.gitignore b/reports/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/reports/all/.gitignore b/reports/all/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/reports/crud/.gitignore b/reports/crud/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/reports/functional/.gitignore b/reports/functional/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/reports/smoke/.gitignore b/reports/smoke/.gitignore new file mode 100644 index 0000000..e69de29