From 6efe391364383936d8c1df9645a3ea0d372dded3 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 28 Sep 2017 16:19:12 -0400 Subject: [PATCH 01/85] Initial setup for Project --- .rubocop.yml | 4 ++ .rubocop_todo.yml | 7 +++ Gemfile | 11 +++++ Gemfile.lock | 69 ++++++++++++++++++++++++++++ features/step_definitions/.gitignore | 0 features/support/env.rb | 0 6 files changed, 91 insertions(+) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 features/step_definitions/.gitignore create mode 100644 features/support/env.rb diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5b7814e --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,4 @@ +inherit_from: .rubocop_todo.yml + +Layout/EndOfLine: + EnforcedStyle: lf diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..921ad78 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,7 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2017-09-28 16:03:29 -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..083179d --- /dev/null +++ b/Gemfile @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } + +gem 'cucumber' +gem 'faraday' +gem 'report_builder' +gem 'rspec' +gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a97a406 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,69 @@ +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) + faraday (0.13.1) + multipart-post (>= 1.2, < 3) + gherkin (4.1.3) + json (2.0.2) + multi_json (1.12.2) + multi_test (0.1.2) + multipart-post (2.0.0) + parallel (1.12.0) + parser (2.4.0.0) + ast (~> 2.2) + 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) + 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) + unicode-display_width (1.3.0) + +PLATFORMS + x64-mingw32 + +DEPENDENCIES + cucumber + faraday + report_builder + rspec + rubocop (~> 0.50.0) + +BUNDLED WITH + 1.15.4 diff --git a/features/step_definitions/.gitignore b/features/step_definitions/.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..e69de29 From 7f2aa39dcac60e60cee48cbbe56e3f2c65506840 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 28 Sep 2017 19:31:04 -0400 Subject: [PATCH 02/85] Adding Json Spec --- .rubocop_todo.yml | 2 +- Gemfile | 1 + Gemfile.lock | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 921ad78..9a9ca6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-09-28 16:03:29 -0400 using RuboCop version 0.50.0. +# 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 diff --git a/Gemfile b/Gemfile index 083179d..6c7b0d8 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } gem 'cucumber' gem 'faraday' +gem 'json_spec' gem 'report_builder' gem 'rspec' gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index a97a406..7b32cd7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -19,6 +19,9 @@ GEM multipart-post (>= 1.2, < 3) gherkin (4.1.3) json (2.0.2) + json_spec (1.1.5) + multi_json (~> 1.0) + rspec (>= 2.0, < 4.0) multi_json (1.12.2) multi_test (0.1.2) multipart-post (2.0.0) @@ -61,6 +64,7 @@ PLATFORMS DEPENDENCIES cucumber faraday + json_spec report_builder rspec rubocop (~> 0.50.0) From e13bbb39f2b38fcc7693a4fa5d75c02700278092 Mon Sep 17 00:00:00 2001 From: Abel Date: Mon, 2 Oct 2017 10:43:30 -0400 Subject: [PATCH 03/85] Adding conversion to JSON --- features/support/utils/response_manager.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 features/support/utils/response_manager.rb diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb new file mode 100644 index 0000000..d41b4d4 --- /dev/null +++ b/features/support/utils/response_manager.rb @@ -0,0 +1,12 @@ +require 'json' + +# Manage the conversion of hashes and string to json +module ResponseManager + def hash_to_json(hash) + hash.to_json + end + + def string_to_json(string) + JSON.parse string + end +end From 4653a74d96e0571ad02758ec3f587cd3c4ed77b5 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 2 Oct 2017 16:40:46 +0000 Subject: [PATCH 04/85] ENV.YML and After Configuration --- features/support/env.rb | 43 ++++++++++++++++++++++++++++++++ features/support/env.yml | 12 +++++++++ features/support/env_yml.example | 12 +++++++++ 3 files changed, 67 insertions(+) create mode 100644 features/support/env.yml create mode 100644 features/support/env_yml.example diff --git a/features/support/env.rb b/features/support/env.rb index e69de29..96e6e6f 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -0,0 +1,43 @@ +require 'pathname' +require 'yaml' + +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 + +def load_bd_config_file(filename) + config_file = find_config_file(filename) + config_bd = YAML.load_file(config_file) + $bd_context = config_bd['database']['connection'] + config_bd +end + +AfterConfiguration do + # read config file + configuration = load_app_config_file('env.yml') + configuration_bd = load_bd_config_file('env.yml') + # Load application configuration parameters + $app_host = configuration['app']['host'] + $app_port = configuration['app']['port'] + $app_root = configuration['app']['rootPath'] + $bd_connection = configuration_bd['database']['connection'] + $bd_host = configuration_bd['database']['host'] + $bd_port = configuration_bd['database']['port'] + $bd_database = configuration_bd['database']['database'] + $bd_username = configuration_bd['database']['username'] + $bd_password = configuration_bd['database']['password'] +end diff --git a/features/support/env.yml b/features/support/env.yml new file mode 100644 index 0000000..7c5eb22 --- /dev/null +++ b/features/support/env.yml @@ -0,0 +1,12 @@ +app: + host: + port: + rootPath: + +database: + connection: + host: + port: + database: + username: + password: \ No newline at end of file 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 From c3b2924878c86999321378428f1449dd5355337c Mon Sep 17 00:00:00 2001 From: yuryver Date: Mon, 2 Oct 2017 14:54:11 -0400 Subject: [PATCH 05/85] base for conect to database --- Gemfile | 2 ++ Gemfile.lock | 3 +++ features/support/utils/database_manager.rb | 11 +++++++++++ 3 files changed, 16 insertions(+) create mode 100644 features/support/utils/database_manager.rb diff --git a/Gemfile b/Gemfile index 6c7b0d8..50ef81d 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,9 @@ git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } gem 'cucumber' gem 'faraday' +gem 'json' gem 'json_spec' +gem 'pg' gem 'report_builder' gem 'rspec' gem 'rubocop', '~> 0.50.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 7b32cd7..3443c6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM 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 @@ -64,7 +65,9 @@ PLATFORMS DEPENDENCIES cucumber faraday + json json_spec + pg report_builder rspec rubocop (~> 0.50.0) diff --git a/features/support/utils/database_manager.rb b/features/support/utils/database_manager.rb new file mode 100644 index 0000000..84d8be2 --- /dev/null +++ b/features/support/utils/database_manager.rb @@ -0,0 +1,11 @@ +require 'pg' +# 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 From e61aa99cb9cf9888eb3f783b3186353188fb5b40 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 2 Oct 2017 19:20:06 +0000 Subject: [PATCH 06/85] improve yml file --- .rubocop.yml | 6 ++++++ features/support/env.rb | 22 ++++++---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5b7814e..9152bbc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,3 +2,9 @@ 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 diff --git a/features/support/env.rb b/features/support/env.rb index 96e6e6f..7622a13 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -19,25 +19,15 @@ def load_app_config_file(filename) config end -def load_bd_config_file(filename) - config_file = find_config_file(filename) - config_bd = YAML.load_file(config_file) - $bd_context = config_bd['database']['connection'] - config_bd -end - AfterConfiguration do - # read config file configuration = load_app_config_file('env.yml') - configuration_bd = load_bd_config_file('env.yml') - # Load application configuration parameters $app_host = configuration['app']['host'] $app_port = configuration['app']['port'] $app_root = configuration['app']['rootPath'] - $bd_connection = configuration_bd['database']['connection'] - $bd_host = configuration_bd['database']['host'] - $bd_port = configuration_bd['database']['port'] - $bd_database = configuration_bd['database']['database'] - $bd_username = configuration_bd['database']['username'] - $bd_password = configuration_bd['database']['password'] + $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 From 9788fa54d5e8ecf6130823f3f4a1b06d89f15ad0 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 2 Oct 2017 15:35:29 -0400 Subject: [PATCH 07/85] Adding Request Manager --- .gitignore | 1 + Gemfile | 3 ++- Gemfile.lock | 22 ++++++++++++++++++---- features/smoke_channels.feature | 6 ++++++ features/step_definitions/smoke_steps.rb | 17 +++++++++++++++++ features/support/env.yml | 4 ++-- features/support/utils/api_request.rb | 15 +++++++++++++++ features/support/utils/request_manager.rb | 13 +++++++++++++ 8 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 features/smoke_channels.feature create mode 100644 features/step_definitions/smoke_steps.rb create mode 100644 features/support/utils/api_request.rb create mode 100644 features/support/utils/request_manager.rb 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/Gemfile b/Gemfile index 6c7b0d8..208721d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,9 @@ source 'https://rubygems.org' git_source(:github) { 'https://github.com/sphinix27/notifier_api_test' } gem 'cucumber' -gem 'faraday' gem 'json_spec' gem 'report_builder' +gem 'rest-client' gem 'rspec' gem 'rubocop', '~> 0.50.0', require: false + diff --git a/Gemfile.lock b/Gemfile.lock index 7b32cd7..a4f9ac9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,16 +15,22 @@ GEM gherkin (~> 4.0) cucumber-wire (0.0.1) diff-lcs (1.3) - faraday (0.13.1) - multipart-post (>= 1.2, < 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) - multipart-post (2.0.0) + netrc (0.11.0) parallel (1.12.0) parser (2.4.0.0) ast (~> 2.2) @@ -35,6 +41,11 @@ GEM 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) @@ -56,6 +67,9 @@ GEM 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 @@ -63,9 +77,9 @@ PLATFORMS DEPENDENCIES cucumber - faraday json_spec report_builder + rest-client rspec rubocop (~> 0.50.0) diff --git a/features/smoke_channels.feature b/features/smoke_channels.feature new file mode 100644 index 0000000..23d1ab5 --- /dev/null +++ b/features/smoke_channels.feature @@ -0,0 +1,6 @@ +Feature:Smoke Test Channels + + Scenario:Get all Channels + Given I make a 'GET' request to '/channels' + When I execute the request + Then I expect a '200' status code \ No newline at end of file diff --git a/features/step_definitions/smoke_steps.rb b/features/step_definitions/smoke_steps.rb new file mode 100644 index 0000000..8c7ff75 --- /dev/null +++ b/features/step_definitions/smoke_steps.rb @@ -0,0 +1,17 @@ +require_relative '../../features/support/utils/api_request' +require_relative '../../features/support/utils/request_manager' + +Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| + @method = method + @endpoint = endpoint +end +When(/^I execute the request$/) do + smoke = ApiRequest.new(@endpoint) + smoke.method = @method + smoke.append_endpoint + @response = RequestManager.execute_request(smoke) +end + +Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| + expect(@response.code).to eql(status_code_expected.to_i) +end diff --git a/features/support/env.yml b/features/support/env.yml index 7c5eb22..4d8260a 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,7 +1,7 @@ app: - host: + host: http://10.31.2.91 port: - rootPath: + rootPath: /api database: connection: diff --git a/features/support/utils/api_request.rb b/features/support/utils/api_request.rb new file mode 100644 index 0000000..bb7d7a7 --- /dev/null +++ b/features/support/utils/api_request.rb @@ -0,0 +1,15 @@ +# ApiRequest class. +class ApiRequest + attr_reader :header, :url + attr_accessor :body, :method + + def initialize(endpoint) + @endpoint = endpoint + @header = { :'Content-Type' => 'application/json' } + @body = {} + end + + def append_endpoint + @url = "#{$app_host}#{$app_root}#{@endpoint}" + end +end diff --git a/features/support/utils/request_manager.rb b/features/support/utils/request_manager.rb new file mode 100644 index 0000000..d105ddd --- /dev/null +++ b/features/support/utils/request_manager.rb @@ -0,0 +1,13 @@ +require 'rest-client' + +# 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 +end From d0af5c281c26d87f7cb94bc1e9fb70a9bff89c34 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 2 Oct 2017 15:56:53 -0400 Subject: [PATCH 08/85] Adding structure --- features/{step_definitions => crud}/.gitignore | 0 features/functional/.gitignore | 0 features/{ => smoke}/smoke_channels.feature | 0 features/step_definitions/assert/.gitignore | 0 features/step_definitions/{ => common}/smoke_steps.rb | 4 ++-- features/step_definitions/request/.gitignore | 0 6 files changed, 2 insertions(+), 2 deletions(-) rename features/{step_definitions => crud}/.gitignore (100%) create mode 100644 features/functional/.gitignore rename features/{ => smoke}/smoke_channels.feature (100%) create mode 100644 features/step_definitions/assert/.gitignore rename features/step_definitions/{ => common}/smoke_steps.rb (77%) create mode 100644 features/step_definitions/request/.gitignore diff --git a/features/step_definitions/.gitignore b/features/crud/.gitignore similarity index 100% rename from features/step_definitions/.gitignore rename to features/crud/.gitignore diff --git a/features/functional/.gitignore b/features/functional/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/smoke_channels.feature b/features/smoke/smoke_channels.feature similarity index 100% rename from features/smoke_channels.feature rename to features/smoke/smoke_channels.feature 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/smoke_steps.rb b/features/step_definitions/common/smoke_steps.rb similarity index 77% rename from features/step_definitions/smoke_steps.rb rename to features/step_definitions/common/smoke_steps.rb index 8c7ff75..668dabf 100644 --- a/features/step_definitions/smoke_steps.rb +++ b/features/step_definitions/common/smoke_steps.rb @@ -1,5 +1,5 @@ -require_relative '../../features/support/utils/api_request' -require_relative '../../features/support/utils/request_manager' +require_relative '../../support/utils/api_request' +require_relative '../../support/utils/request_manager' Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| @method = method diff --git a/features/step_definitions/request/.gitignore b/features/step_definitions/request/.gitignore new file mode 100644 index 0000000..e69de29 From 4326b3299a8888c9f5021c31a821008c34676ba4 Mon Sep 17 00:00:00 2001 From: Abel Date: Mon, 2 Oct 2017 17:21:53 -0400 Subject: [PATCH 09/85] Refactoring Api Request and adding new features --- features/crud/get_channels.feature | 18 +++++++++++++ features/crud/post_channel.feature | 27 +++++++++++++++++++ features/smoke/smoke_channels.feature | 2 +- .../step_definitions/common/smoke_steps.rb | 25 ++++++++++++----- features/support/utils/api_request.rb | 5 +--- features/support/utils/response_manager.rb | 4 +-- 6 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 features/crud/get_channels.feature create mode 100644 features/crud/post_channel.feature diff --git a/features/crud/get_channels.feature b/features/crud/get_channels.feature new file mode 100644 index 0000000..df0351f --- /dev/null +++ b/features/crud/get_channels.feature @@ -0,0 +1,18 @@ +Feature: CRUD for channels + + Scenario: Get channel by id + Given I make a 'GET' request to '/channels/11' + When I execute the request + Then I expect a '200' status code + And The response body is + """ + { + "id": 11, + "name": "Slack at-04", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" + }, + "onFail": null + } + """ diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature new file mode 100644 index 0000000..ff53c95 --- /dev/null +++ b/features/crud/post_channel.feature @@ -0,0 +1,27 @@ +Feature: Post request for channels endpoint + Scenario: Create a new channel + Given I make a 'POST' request to '/channels' + When I set the body as: + """ + { + "name":"AT04", + "type":"WEB_HOOK", + "configuration":{ + "url":"https://web.webhooks.com/services/..." + } + } + """ + And I execute the request + And I save the id as "channelId" + Then I expect a '200' status code + And The response body is + """ + { + "name": "AT04", + "type": "WEB_HOOK", + "configuration": { + "url":"https://web.webhooks.com/services/..." + }, + "onFail": null + } + """ diff --git a/features/smoke/smoke_channels.feature b/features/smoke/smoke_channels.feature index 23d1ab5..d5d0b11 100644 --- a/features/smoke/smoke_channels.feature +++ b/features/smoke/smoke_channels.feature @@ -3,4 +3,4 @@ Feature:Smoke Test Channels Scenario:Get all Channels Given I make a 'GET' request to '/channels' When I execute the request - Then I expect a '200' status code \ No newline at end of file + Then I expect a '200' status code diff --git a/features/step_definitions/common/smoke_steps.rb b/features/step_definitions/common/smoke_steps.rb index 668dabf..4433671 100644 --- a/features/step_definitions/common/smoke_steps.rb +++ b/features/step_definitions/common/smoke_steps.rb @@ -1,17 +1,30 @@ require_relative '../../support/utils/api_request' require_relative '../../support/utils/request_manager' +require_relative '../../support/utils/response_manager' Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| - @method = method - @endpoint = endpoint + # TODO: Method for build the endpoint + @request = ApiRequest.new(endpoint) + @request.method = method end + When(/^I execute the request$/) do - smoke = ApiRequest.new(@endpoint) - smoke.method = @method - smoke.append_endpoint - @response = RequestManager.execute_request(smoke) + @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 + +Then(/^The response body is$/) do |expected_body| + expect(ResponseManager.string_to_json(@response.body)).to eq(ResponseManager.string_to_json(expected_body)) + expect(JSON.parse(@response.body)).to eq JSON.parse(expected_body) +end + +When(/^I set the body as:$/) do |body| + @request.body = ResponseManager.string_to_json body +end + +When(/^I save the id as "([^"]*)"$/) do |id| + pending # Write code here that turns the phrase above into concrete actions +end diff --git a/features/support/utils/api_request.rb b/features/support/utils/api_request.rb index bb7d7a7..084d7a0 100644 --- a/features/support/utils/api_request.rb +++ b/features/support/utils/api_request.rb @@ -7,9 +7,6 @@ def initialize(endpoint) @endpoint = endpoint @header = { :'Content-Type' => 'application/json' } @body = {} - end - - def append_endpoint - @url = "#{$app_host}#{$app_root}#{@endpoint}" + @url = "#{$app_host}#{$app_root}#{endpoint}" end end diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index d41b4d4..4f827e5 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -2,11 +2,11 @@ # Manage the conversion of hashes and string to json module ResponseManager - def hash_to_json(hash) + def self.hash_to_json(hash) hash.to_json end - def string_to_json(string) + def self.string_to_json(string) JSON.parse string end end From 12ed3a5ffbf7259d091b92f189a390142bcb5251 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 2 Oct 2017 21:27:42 +0000 Subject: [PATCH 10/85] Adding Smoke Tests --- features/smoke/channels.feature | 6 ++++++ features/smoke/notification.feature | 6 ++++++ features/smoke/smoke_channels.feature | 6 ------ features/smoke/specific_channel.feature | 6 ++++++ features/smoke/specific_template.feature | 6 ++++++ features/smoke/templates.feature | 6 ++++++ .../step_definitions/common/{smoke_steps.rb => steps.rb} | 4 ++-- 7 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 features/smoke/channels.feature create mode 100644 features/smoke/notification.feature delete mode 100644 features/smoke/smoke_channels.feature create mode 100644 features/smoke/specific_channel.feature create mode 100644 features/smoke/specific_template.feature create mode 100644 features/smoke/templates.feature rename features/step_definitions/common/{smoke_steps.rb => steps.rb} (76%) diff --git a/features/smoke/channels.feature b/features/smoke/channels.feature new file mode 100644 index 0000000..fccda6c --- /dev/null +++ b/features/smoke/channels.feature @@ -0,0 +1,6 @@ +Feature:Channels + + 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 \ No newline at end of file diff --git a/features/smoke/notification.feature b/features/smoke/notification.feature new file mode 100644 index 0000000..0ec7070 --- /dev/null +++ b/features/smoke/notification.feature @@ -0,0 +1,6 @@ +Feature:Specific Notification + + Scenario: Get a specific Notification + Given I make a 'GET' request to '/notifications/3e8d2814-f298-4474-8767-a69fb3d4bcb2' 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/smoke_channels.feature b/features/smoke/smoke_channels.feature deleted file mode 100644 index 23d1ab5..0000000 --- a/features/smoke/smoke_channels.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature:Smoke Test Channels - - Scenario:Get all Channels - Given I make a 'GET' request to '/channels' - When I execute the request - Then I expect a '200' status code \ 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..b42286c --- /dev/null +++ b/features/smoke/specific_channel.feature @@ -0,0 +1,6 @@ +Feature:Specific Channels + + Scenario: Get a specific channel + Given I make a 'GET' request to '/channels/1' 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..c1f3509 --- /dev/null +++ b/features/smoke/specific_template.feature @@ -0,0 +1,6 @@ +Feature:Specific Template + + Scenario: Get a specific Template + Given I make a 'GET' request to '/templates/1' 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/templates.feature b/features/smoke/templates.feature new file mode 100644 index 0000000..6f5067e --- /dev/null +++ b/features/smoke/templates.feature @@ -0,0 +1,6 @@ +Feature:Templates + + 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 \ No newline at end of file diff --git a/features/step_definitions/common/smoke_steps.rb b/features/step_definitions/common/steps.rb similarity index 76% rename from features/step_definitions/common/smoke_steps.rb rename to features/step_definitions/common/steps.rb index 668dabf..fb12ab8 100644 --- a/features/step_definitions/common/smoke_steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,11 +1,11 @@ require_relative '../../support/utils/api_request' require_relative '../../support/utils/request_manager' -Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| +Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @method = method @endpoint = endpoint end -When(/^I execute the request$/) do +When(/^I execute the request to the endpoint$/) do smoke = ApiRequest.new(@endpoint) smoke.method = @method smoke.append_endpoint From aa59f380735efc43a3c642ffaf99c9a815fe9852 Mon Sep 17 00:00:00 2001 From: yuryver Date: Mon, 2 Oct 2017 21:14:44 -0400 Subject: [PATCH 11/85] advanced enpoint builder --- features/buildEnpoint.feature | 8 +++++++ .../step_definitions/common/smoke_steps.rb | 22 +++++++++++++++---- features/support/utils/enpoint_builder.rb | 9 ++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 features/buildEnpoint.feature create mode 100644 features/support/utils/enpoint_builder.rb diff --git a/features/buildEnpoint.feature b/features/buildEnpoint.feature new file mode 100644 index 0000000..281dd19 --- /dev/null +++ b/features/buildEnpoint.feature @@ -0,0 +1,8 @@ +Feature: bluid + + Scenario: enpoint + Given value id: 15 + And I make a 'GET' request to '/channels/$id' + And I make a 'POST' request to '/channels/$id' with paramethers: + | type | slack | + | name | email | diff --git a/features/step_definitions/common/smoke_steps.rb b/features/step_definitions/common/smoke_steps.rb index 668dabf..300382a 100644 --- a/features/step_definitions/common/smoke_steps.rb +++ b/features/step_definitions/common/smoke_steps.rb @@ -1,8 +1,6 @@ -require_relative '../../support/utils/api_request' -require_relative '../../support/utils/request_manager' - -Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| +Given(/^I make a '(GET|POST)' request to '(.+)'$/) do |method, endpoint| @method = method + EnpointBuilder::builder endpoint @endpoint = endpoint end When(/^I execute the request$/) do @@ -15,3 +13,19 @@ Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| expect(@response.code).to eql(status_code_expected.to_i) end + + +Given(/^value id: (\d+)$/) do |id| + $id =id +end + + +And(/^I make a '(PUT|POST)' request to '(.+)' with paramethers:$/) do |method, enpoint, paramether| + # table is a table.hashes.keys # => [:type, :slack] + paramether.column_names.each do |field| + puts field + end + + puts paramether.content_columns + +end \ No newline at end of file diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb new file mode 100644 index 0000000..9bca07d --- /dev/null +++ b/features/support/utils/enpoint_builder.rb @@ -0,0 +1,9 @@ +module EnpointBuilder + def EnpointBuilder.builder enpoint + enpoint = enpoint.gsub('$id', $id.to_s) + puts enpoint + end + +end + +# EnpointBuilder::builder 'notifications/{id}/asd' \ No newline at end of file From ccd22b780d1165ac2d07092344ac9bef3e0d716d Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 3 Oct 2017 10:51:16 -0400 Subject: [PATCH 12/85] Improving the response manager --- features/crud/post_channel.feature | 13 ++++------- .../step_definitions/common/smoke_steps.rb | 9 ++------ features/support/utils/response_manager.rb | 22 +++++++++++++++++++ features/support/utils/templates/channel.json | 9 ++++++++ 4 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 features/support/utils/templates/channel.json diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index ff53c95..598b4b9 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -4,10 +4,10 @@ Feature: Post request for channels endpoint When I set the body as: """ { - "name":"AT04", - "type":"WEB_HOOK", - "configuration":{ - "url":"https://web.webhooks.com/services/..." + "name": "AT04-Slack-Demo", + "type": "SLACK", + "configuration": { + "url": "https://hooks.slack.com/services/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" } } """ @@ -17,11 +17,6 @@ Feature: Post request for channels endpoint And The response body is """ { - "name": "AT04", - "type": "WEB_HOOK", - "configuration": { - "url":"https://web.webhooks.com/services/..." - }, "onFail": null } """ diff --git a/features/step_definitions/common/smoke_steps.rb b/features/step_definitions/common/smoke_steps.rb index 4433671..3fec36c 100644 --- a/features/step_definitions/common/smoke_steps.rb +++ b/features/step_definitions/common/smoke_steps.rb @@ -1,7 +1,3 @@ -require_relative '../../support/utils/api_request' -require_relative '../../support/utils/request_manager' -require_relative '../../support/utils/response_manager' - Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| # TODO: Method for build the endpoint @request = ApiRequest.new(endpoint) @@ -9,7 +5,7 @@ end When(/^I execute the request$/) do - @response = RequestManager.execute_request(@request) + @response = RequestManager.execute_request(@request) end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| @@ -17,12 +13,11 @@ end Then(/^The response body is$/) do |expected_body| - expect(ResponseManager.string_to_json(@response.body)).to eq(ResponseManager.string_to_json(expected_body)) expect(JSON.parse(@response.body)).to eq JSON.parse(expected_body) end When(/^I set the body as:$/) do |body| - @request.body = ResponseManager.string_to_json body + @request.body = body end When(/^I save the id as "([^"]*)"$/) do |id| diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 4f827e5..3140f76 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -1,4 +1,5 @@ require 'json' +require 'hashdiff' # Manage the conversion of hashes and string to json module ResponseManager @@ -9,4 +10,25 @@ def self.hash_to_json(hash) def self.string_to_json(string) JSON.parse string end + + def self.parse_file_to_hash(filename) + file = File.read(filename) + @template_hash = JSON.parse(file) + end + + def self.copy_template + @hash = Hash[@template_hash] + end + + def self.replace_in_hash(hash) + @template_hash.each { |key, value| + @hash[key] = hash[key] if !(@template_hash[key].eql? hash[key]) && (hash.has_key? key) + } + @hash + end + + def self.diff_hash(hash) + hash.delete_if {|key, value| !(@hash[key].eql? @template_hash[key])} + p hash + end end diff --git a/features/support/utils/templates/channel.json b/features/support/utils/templates/channel.json new file mode 100644 index 0000000..6c0f753 --- /dev/null +++ b/features/support/utils/templates/channel.json @@ -0,0 +1,9 @@ +{ + "id": "integer", + "name": "string", + "type": "string", + "configuration": { + "url": "string" + }, + "onFail": "boolean" +} From 845c13db0bfd8a4d94fd9591bfc3232497577330 Mon Sep 17 00:00:00 2001 From: yuryver Date: Tue, 3 Oct 2017 11:47:53 -0400 Subject: [PATCH 13/85] build enpoint --- features/buildEnpoint.feature | 8 -------- .../common/{smoke_steps.rb => steps.rb} | 17 ++++++----------- features/support/utils/enpoint_builder.rb | 13 ++++++++----- 3 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 features/buildEnpoint.feature rename features/step_definitions/common/{smoke_steps.rb => steps.rb} (69%) diff --git a/features/buildEnpoint.feature b/features/buildEnpoint.feature deleted file mode 100644 index 281dd19..0000000 --- a/features/buildEnpoint.feature +++ /dev/null @@ -1,8 +0,0 @@ -Feature: bluid - - Scenario: enpoint - Given value id: 15 - And I make a 'GET' request to '/channels/$id' - And I make a 'POST' request to '/channels/$id' with paramethers: - | type | slack | - | name | email | diff --git a/features/step_definitions/common/smoke_steps.rb b/features/step_definitions/common/steps.rb similarity index 69% rename from features/step_definitions/common/smoke_steps.rb rename to features/step_definitions/common/steps.rb index 300382a..a9b672e 100644 --- a/features/step_definitions/common/smoke_steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,9 +1,8 @@ Given(/^I make a '(GET|POST)' request to '(.+)'$/) do |method, endpoint| @method = method - EnpointBuilder::builder endpoint - @endpoint = endpoint + @endpoint = EnpointBuilder::builder endpoint end -When(/^I execute the request$/) do +When(/^I execute the request to the endpoint$/) do smoke = ApiRequest.new(@endpoint) smoke.method = @method smoke.append_endpoint @@ -20,12 +19,8 @@ end -And(/^I make a '(PUT|POST)' request to '(.+)' with paramethers:$/) do |method, enpoint, paramether| +And(/^I make a '(PUT|POST)' request to '(.+)' with paramethers:$/) do |method, endpoint, paramether| # table is a table.hashes.keys # => [:type, :slack] - paramether.column_names.each do |field| - puts field - end - - puts paramether.content_columns - -end \ No newline at end of file + @method = method + @endpoint = EnpointBuilder::builderWithParamethers endpoint, paramether.raw +end diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index 9bca07d..23901e4 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -1,9 +1,12 @@ module EnpointBuilder def EnpointBuilder.builder enpoint - enpoint = enpoint.gsub('$id', $id.to_s) - puts enpoint + enpoint.gsub('$id', $id.to_s) + end + def EnpointBuilder.builderWithParamethers enpoint, paramethers + enpoint = builder enpoint + paramethers.each_with_index do |value, index| + (index.to_i ==0) ? enpoint = "#{enpoint}?#{value[0]}=#{value[1]}" : enpoint = "#{enpoint}&#{value[0]}=#{value[1]}" + end + enpoint end - end - -# EnpointBuilder::builder 'notifications/{id}/asd' \ No newline at end of file From 66a6e83f3e12830832ae1ca74728d4513fbd3fdf Mon Sep 17 00:00:00 2001 From: yuryver Date: Tue, 3 Oct 2017 14:23:27 -0400 Subject: [PATCH 14/85] complete builder endpoint --- features/step_definitions/common/steps.rb | 7 ++++--- features/support/utils/enpoint_builder.rb | 16 ++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index a9adde6..2775335 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,6 +1,6 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @method = method - @endpoint = EnpointBuilder::builder endpoint + @endpoint = EnpointBuilder.builder endpoint end When(/^I execute the request to the endpoint$/) do smoke = ApiRequest.new(@endpoint) @@ -13,8 +13,9 @@ expect(@response.code).to eql(status_code_expected.to_i) end -And(/^I make a '(PUT|POST)' request to '(.+)' with paramethers:$/) do |method, endpoint, paramether| +And(/^I make a '(PUT|POST)' request to '(.+)' with:$/) do |method, endpoint, param| # table is a table.hashes.keys # => [:type, :slack] @method = method - @endpoint = EnpointBuilder::builderWithParamethers endpoint, paramether.raw + @endpoint = EnpointBuilder.param endpoint, param.raw end + diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index 491641f..c52a06e 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -1,12 +1,16 @@ +# This module build endpoint with id and params module EnpointBuilder - def EnpointBuilder.builder enpoint + def self.builder(enpoint) enpoint.gsub('$id', $id.to_s) end - def EnpointBuilder.builderWithParamethers endpoint, paramethers - endpoint = builder endpoint - paramethers.each_with_index do |value, index| - (index.to_i ==0) ? endpoint = "#{endpoint}?#{value[0]}=#{value[1]}" : endpoint = "#{endpoint}&#{value[0]}=#{value[1]}" + + def self.param(endpoint, param) + point = builder endpoint + param.each_with_index do |value, index| + params = "#{value[0].gsub(' ', '%20')}=#{value[1].gsub(' ', '%20')}" + point = index.to_i.zero? ? "#{point}?#{params}" : "#{point}&#{params}" end - endpoint + puts point + point end end From c371053b00314a122c0eed0b053251416727caa3 Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 3 Oct 2017 14:29:16 -0400 Subject: [PATCH 15/85] Implementing get channels --- features/crud/get_channels.feature | 19 ++++++++++++++-- features/crud/post_channel.feature | 8 +++---- features/step_definitions/common/steps.rb | 21 ++++++++++++++---- features/support/utils/response_manager.rb | 25 +++++++--------------- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/features/crud/get_channels.feature b/features/crud/get_channels.feature index df0351f..429bab4 100644 --- a/features/crud/get_channels.feature +++ b/features/crud/get_channels.feature @@ -1,8 +1,23 @@ 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 Scenario: Get channel by id - Given I make a 'GET' request to '/channels/11' - When I execute the request + 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 The response body is """ diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index 598b4b9..8c77271 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -1,6 +1,6 @@ Feature: Post request for channels endpoint Scenario: Create a new channel - Given I make a 'POST' request to '/channels' + Given I make a 'POST' request to '/channels' endpoint When I set the body as: """ { @@ -11,12 +11,12 @@ Feature: Post request for channels endpoint } } """ - And I execute the request - And I save the id as "channelId" + And I execute the request to the endpoint Then I expect a '200' status code - And The response body is + And I build the response for "channel" with """ { "onFail": null } """ + And The response body is the same as builded diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c218673..b3cfd36 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,10 +1,10 @@ -Given(/^I make a '(\w+)' request to '(.+)'$/) do |method, endpoint| +Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| # TODO: Method for build the endpoint @request = ApiRequest.new(endpoint) @request.method = method end -When(/^I execute the request$/) do +When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) end @@ -17,9 +17,22 @@ end When(/^I set the body as:$/) do |body| + @body = JSON.parse(body) @request.body = body end -When(/^I save the id as "([^"]*)"$/) do |id| - pending # Write code here that turns the phrase above into concrete actions +When(/^I save the id$/) do + $id = JSON.parse(@response.body)['id'] +end + +Then(/^I build the response for "([^"]*)" with$/) do |template, json| + ResponseManager.parse_file_to_hash(template) + ResponseManager.replace_in_hash(@body) + ResponseManager.replace_in_hash(JSON.parse(json)) + response_hash = ResponseManager.diff_hash(JSON.parse(@response.body)) + @builded_hash = ResponseManager.replace_in_hash(response_hash) +end + +Then(/^The response body is the same as builded$/) do + expect(@builded_hash.to_json).to eq @response.body end diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 6ea81dc..7de8f8c 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -1,31 +1,22 @@ # Manage the conversion of hashes and string to json module ResponseManager - def self.hash_to_json(hash) - hash.to_json - end - - def self.string_to_json(string) - JSON.parse string - end - def self.parse_file_to_hash(filename) - file = File.read(filename) + path = "./features/support/utils/templates/#{filename}.json" + file = File.read(path) @template_hash = JSON.parse(file) - end - - def self.copy_template @hash = Hash[@template_hash] end def self.replace_in_hash(hash) - @template_hash.each { |key, value| - @hash[key] = hash[key] if !(@template_hash[key].eql? hash[key]) && (hash.has_key? key) - } + @template_hash.each_key do |key| + if !(@template_hash[key].eql? hash[key]) && (hash.key? key) + @hash[key] = hash[key] + end + end @hash end def self.diff_hash(hash) - hash.delete_if {|key, value| !(@hash[key].eql? @template_hash[key])} - p hash + hash.delete_if { |key| !(@hash[key].eql? @template_hash[key]) } end end From a2a8b2840ba0673a364f53537f8878ae58043cba Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 3 Oct 2017 14:43:36 -0400 Subject: [PATCH 16/85] Adding Put channel crud --- features/crud/get_channels.feature | 1 + features/crud/post_channel.feature | 5 ++-- features/crud/put_channel.feature | 39 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 features/crud/put_channel.feature diff --git a/features/crud/get_channels.feature b/features/crud/get_channels.feature index 3702486..f057b03 100644 --- a/features/crud/get_channels.feature +++ b/features/crud/get_channels.feature @@ -1,3 +1,4 @@ +@crud Feature: CRUD for channels Background: diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index 8c77271..aba60e6 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -1,7 +1,8 @@ +@crud Feature: Post request for channels endpoint Scenario: Create a new channel Given I make a 'POST' request to '/channels' endpoint - When I set the body as: + And I set the body as: """ { "name": "AT04-Slack-Demo", @@ -11,7 +12,7 @@ Feature: Post request for channels endpoint } } """ - And I execute the request to the endpoint + When I execute the request to the endpoint Then I expect a '200' status code And I build the response for "channel" with """ diff --git a/features/crud/put_channel.feature b/features/crud/put_channel.feature new file mode 100644 index 0000000..2e24d41 --- /dev/null +++ b/features/crud/put_channel.feature @@ -0,0 +1,39 @@ +@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 + Scenario: Get channel by id + Given I make a 'PUT' request to '/channels/$id' endpoint + And I set the body as: + """ + { + "name": "AT04-Slack-Demo-Updated", + "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 From d7d332062f239f5f40270b2e1d006980f1214b9e Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 3 Oct 2017 15:33:02 -0400 Subject: [PATCH 17/85] Adding delete channel crud, Hooks for delete channels --- Gemfile | 1 - features/crud/delete_channel.feature | 22 ++++++++++++++++++++++ features/crud/get_channels.feature | 1 + features/crud/post_channel.feature | 2 ++ features/crud/put_channel.feature | 3 ++- features/support/hooks/hooks.rb | 6 ++++++ 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 features/crud/delete_channel.feature create mode 100644 features/support/hooks/hooks.rb diff --git a/Gemfile b/Gemfile index 3b40866..d82d173 100644 --- a/Gemfile +++ b/Gemfile @@ -12,4 +12,3 @@ gem 'report_builder' gem 'rest-client' gem 'rspec' gem 'rubocop', '~> 0.50.0', require: false - diff --git a/features/crud/delete_channel.feature b/features/crud/delete_channel.feature new file mode 100644 index 0000000..4c9fbaa --- /dev/null +++ b/features/crud/delete_channel.feature @@ -0,0 +1,22 @@ +@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 + 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/get_channels.feature b/features/crud/get_channels.feature index f057b03..5ee67be 100644 --- a/features/crud/get_channels.feature +++ b/features/crud/get_channels.feature @@ -16,6 +16,7 @@ Feature: CRUD for channels And I execute the request to the endpoint Then I expect a '200' status code And I save the id + @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 diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index aba60e6..446afd1 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -1,5 +1,6 @@ @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: @@ -14,6 +15,7 @@ Feature: Post request for channels endpoint """ When I execute the request to the endpoint Then I expect a '200' status code + And I save the id And I build the response for "channel" with """ { diff --git a/features/crud/put_channel.feature b/features/crud/put_channel.feature index 2e24d41..42a06ef 100644 --- a/features/crud/put_channel.feature +++ b/features/crud/put_channel.feature @@ -16,7 +16,8 @@ Feature: CRUD for channels And I execute the request to the endpoint Then I expect a '200' status code And I save the id - Scenario: Get channel by id + @delete_channel + Scenario: Update channel by id Given I make a 'PUT' request to '/channels/$id' endpoint And I set the body as: """ diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb new file mode 100644 index 0000000..67a86a0 --- /dev/null +++ b/features/support/hooks/hooks.rb @@ -0,0 +1,6 @@ +# Delete channel +After('@delete_channel') do + request = ApiRequest.new(EnpointBuilder.builder('/channels/$id')) + request.method = 'DELETE' + RequestManager.execute_request(request) +end From 54ae0cc2e12106113c1ec0bd7ec5b8e011178f93 Mon Sep 17 00:00:00 2001 From: yuryver Date: Tue, 3 Oct 2017 17:14:29 -0400 Subject: [PATCH 18/85] post resend notification --- .../crud/post_resend_notification.feature | 32 +++++++++++++++++++ features/step_definitions/common/steps.rb | 6 ++++ features/support/utils/enpoint_builder.rb | 1 + 3 files changed, 39 insertions(+) create mode 100644 features/crud/post_resend_notification.feature diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature new file mode 100644 index 0000000..0981134 --- /dev/null +++ b/features/crud/post_resend_notification.feature @@ -0,0 +1,32 @@ +Feature: CRUD resend notification + + Background: send a notification + Given I make a 'POST' request to '/notifications' endpoint + When I set the body as: + """ + { + "channelId": 8, + "priority": "HIGH", + "recipients": ["#general"], + "subject": "test API", + "content": "Hi there, The JCN team is making a demo about Notifier." + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the id + + + Scenario: resend a notification without param + Given sleep + And 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 + + + Scenario: resend a notification with param + Given sleep + Given I make a 'POST' request to '/notifications/events/$id/resend' with: + | recipient | #general | + When I execute the request to the endpoint + Then I expect a '200' status code diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index d4b9284..110c4cf 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,6 +1,7 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method + puts EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @@ -40,3 +41,8 @@ Then(/^The response body is the same as builded$/) do expect(@builded_hash.to_json).to eq @response.body end + + +Given(/^sleep$/) do + sleep 3 +end diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index c52a06e..049c658 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -8,6 +8,7 @@ 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 puts point From 9b8a1ec316c1d5fb66705dce83d6ceaf10ceff2c Mon Sep 17 00:00:00 2001 From: yuryver Date: Tue, 3 Oct 2017 17:24:38 -0400 Subject: [PATCH 19/85] corrections resend notification --- features/step_definitions/common/steps.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 110c4cf..90a6f1c 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,7 +1,6 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method - puts EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @@ -42,7 +41,6 @@ expect(@builded_hash.to_json).to eq @response.body end - Given(/^sleep$/) do sleep 3 end From eccc96d01e2cb5d60d43858d97f612a030d29019 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 3 Oct 2017 21:36:46 +0000 Subject: [PATCH 20/85] Adding templates CRUD --- features/crud/delete_template.feature | 21 +++++++++++++++ features/crud/get_template.feature | 23 ++++++++++++++++ features/crud/get_templates.feature | 7 +++++ features/crud/post_template.feature | 21 +++++++++++++++ features/crud/put_template.feature | 32 +++++++++++++++++++++++ features/step_definitions/common/steps.rb | 12 +++++++++ 6 files changed, 116 insertions(+) create mode 100644 features/crud/delete_template.feature create mode 100644 features/crud/get_template.feature create mode 100644 features/crud/get_templates.feature create mode 100644 features/crud/post_template.feature create mode 100644 features/crud/put_template.feature diff --git a/features/crud/delete_template.feature b/features/crud/delete_template.feature new file mode 100644 index 0000000..eedc98a --- /dev/null +++ b/features/crud/delete_template.feature @@ -0,0 +1,21 @@ +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 + + 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_template.feature b/features/crud/get_template.feature new file mode 100644 index 0000000..01fe44f --- /dev/null +++ b/features/crud/get_template.feature @@ -0,0 +1,23 @@ +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 + 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..18791e1 --- /dev/null +++ b/features/crud/get_templates.feature @@ -0,0 +1,7 @@ +Feature: get templates + + 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 expect that the GET response it is empty \ No newline at end of file diff --git a/features/crud/post_template.feature b/features/crud/post_template.feature new file mode 100644 index 0000000..b6ca4b6 --- /dev/null +++ b/features/crud/post_template.feature @@ -0,0 +1,21 @@ +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 + 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_template.feature b/features/crud/put_template.feature new file mode 100644 index 0000000..1fab64b --- /dev/null +++ b/features/crud/put_template.feature @@ -0,0 +1,32 @@ +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 + + 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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index d4b9284..30368b9 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -40,3 +40,15 @@ Then(/^The response body is the same as builded$/) do expect(@builded_hash.to_json).to eq @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(JSON.parse(@response.body)).to eq JSON.parse(@stored_response) +end + +Then(/^I expect that the GET response it is empty$/) do + expect(@response.body).to eq '' +end From 8300e3ebe76317a9c66f223b1dd2b938b426953e Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 3 Oct 2017 18:36:24 -0400 Subject: [PATCH 21/85] Increasing crud coverage --- features/crud/post_channel.feature | 75 +++++++++++++++++++ features/functional/get_channels.feature | 31 ++++++++ features/step_definitions/common/steps.rb | 4 +- features/support/utils/enpoint_builder.rb | 1 - features/support/utils/templates/channel.json | 1 - 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 features/functional/get_channels.feature diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index 446afd1..5f88e73 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -23,3 +23,78 @@ Feature: Post request for channels endpoint } """ And The response body is the same as builded + @delete_channel + Scenario: Create a new channel + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-WebHook-Demo", + "type": "WEB_HOOK", + "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 + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded + + @delete_channel + Scenario: Create a new channel + Given I make a 'POST' request to '/channels' endpoint + And I set the body as: + """ + { + "name": "AT04-Email-Demo", + "type": "EMAIL", + "configuration":{ + "mail.from":"example@jalasoft.com", + "mail.host":"127.0.0.1" + } + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the id + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded + + @delete_channel + Scenario: Create a new channel + Given I make a 'POST' request to '/channels' endpoint + And 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" + } + } + """ + When I execute the request to the endpoint + Then I expect a '200' status code + And I save the id + And I build the response for "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/functional/get_channels.feature b/features/functional/get_channels.feature new file mode 100644 index 0000000..3edba4d --- /dev/null +++ b/features/functional/get_channels.feature @@ -0,0 +1,31 @@ +@functional +Feature: Functional get for channels + + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-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 + @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 "channel" with + """ + { + "onFail": null + } + """ + And The response body is the same as builded diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 90a6f1c..cda68f3 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -11,7 +11,7 @@ expect(@response.code).to eql(status_code_expected.to_i) end -And(/^I make a '(PUT|POST)' request to '(.+)' with:$/) do |method, endpoint, param| +And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| @request = ApiRequest.new(EnpointBuilder.param(endpoint, param.raw)) @request.method = method end @@ -39,6 +39,8 @@ 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 Given(/^sleep$/) do diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index 049c658..92e2ee1 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -11,7 +11,6 @@ def self.param(endpoint, param) params = "#{params.gsub('#','%23')}" point = index.to_i.zero? ? "#{point}?#{params}" : "#{point}&#{params}" end - puts point point end end diff --git a/features/support/utils/templates/channel.json b/features/support/utils/templates/channel.json index 6c0f753..68678c1 100644 --- a/features/support/utils/templates/channel.json +++ b/features/support/utils/templates/channel.json @@ -3,7 +3,6 @@ "name": "string", "type": "string", "configuration": { - "url": "string" }, "onFail": "boolean" } From dcf9b59ecd763b6a5a7346aa17f52d5ba6e99371 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Tue, 3 Oct 2017 20:45:00 -0400 Subject: [PATCH 22/85] Adding GET-POST Notifications --- .rubocop.yml | 3 ++ features/crud/get_notification.feature | 27 +++++++++++++++++ features/crud/post_notifications.feature | 30 +++++++++++++++++++ features/step_definitions/common/steps.rb | 19 ++++++++++++ features/support/env.rb | 1 + features/support/env.yml | 1 + .../support/utils/templates/notification.json | 10 +++++++ .../templates/notificationStatusHistory.json | 21 +++++++++++++ 8 files changed, 112 insertions(+) create mode 100644 features/crud/get_notification.feature create mode 100644 features/crud/post_notifications.feature create mode 100644 features/support/utils/templates/notification.json create mode 100644 features/support/utils/templates/notificationStatusHistory.json diff --git a/.rubocop.yml b/.rubocop.yml index 9152bbc..72443c8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,3 +8,6 @@ Style/GlobalVars: StyleGuide: '#instance-vars' Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html' Enabled: false + +Metrics/LineLength: + Max: 120 \ No newline at end of file diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature new file mode 100644 index 0000000..2b59ddc --- /dev/null +++ b/features/crud/get_notification.feature @@ -0,0 +1,27 @@ +@crud +Feature: GET request for notification endpoint + + Background: + Given I make a 'POST' request to '/notifications' endpoint + When I set the body as: + """ + { + "channelId": 18 , + "priority": "NORMAL", + "recipients": ["#general"], + "subject": "Test", + "content": "A testing message from notifier" + } + """ + And I execute the request to the endpoint + Then I expect a '200' status code + And I save the id + + 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 'GET' request to '/notifications/$id' until the 'status' is 'DELIVERED' + + + + diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature new file mode 100644 index 0000000..0ba23f5 --- /dev/null +++ b/features/crud/post_notifications.feature @@ -0,0 +1,30 @@ +@crud +Feature: POST request for notification endpoint + + Scenario Outline: Send a new notification + Given I make a 'POST' request to '/notifications' endpoint + When I set the body as: + """ + { + "channelId": , + "priority": "", + "recipients": [], + "subject": "", + "content": "" + } + """ + And I execute the request to the endpoint + Then I expect a '' status code + And I build the response for "notification" with + """ + { + "attachments": null, + "templateId": null + } + """ + Examples: + | channelId | priority | recipients | subject | content | status_code | + | 18 | NORMAL | "#general","main" | Test | A testing message from notifier1 | 200 | + | 18 | NORMAL | "#general" | Test2 | A testing message from notifier2 | 200 | + + diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index d4b9284..0665ca1 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -40,3 +40,22 @@ Then(/^The response body is the same as builded$/) do expect(@builded_hash.to_json).to eq @response.body end + +And(/^I '(?:GET|POST)' request to '(.+)' until the '(.+)' is '(.+)'$/) do |endpoint, params, value| + time = 0 + result_expected = JSON.parse(@response.body)['notification'][params] + until result_expected == value + sleep 1 + time += 1 + steps %{ + And I make a 'GET' request to '#{endpoint}' endpoint + And I execute the request to the endpoint + } + result_expected = JSON.parse(@response.body)['notification'][params] + + if time <= $maxWaitTime.to_i + break + end + end + expect(value).to eq result_expected +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index 6bd6c5a..09c6d43 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -27,6 +27,7 @@ def load_app_config_file(filename) $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'] diff --git a/features/support/env.yml b/features/support/env.yml index 2bf58ac..0adbdf7 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -2,6 +2,7 @@ app: host: port: rootPath: + maxWaitTime: database: connection: diff --git a/features/support/utils/templates/notification.json b/features/support/utils/templates/notification.json new file mode 100644 index 0000000..88955e8 --- /dev/null +++ b/features/support/utils/templates/notification.json @@ -0,0 +1,10 @@ +{ + "id": "integer", + "channelId": "integer", + "priority": "string", + "status": "string", + "recipients": ["string"], + "attachments": "boolean", + "content": "string", + "templateId": "boolean" +} diff --git a/features/support/utils/templates/notificationStatusHistory.json b/features/support/utils/templates/notificationStatusHistory.json new file mode 100644 index 0000000..ae9ab56 --- /dev/null +++ b/features/support/utils/templates/notificationStatusHistory.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 From 695301a81eaddb2c102496b7b3d5361192153fd0 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Wed, 4 Oct 2017 13:36:01 -0400 Subject: [PATCH 23/85] Improvement of the step waiting until the change of a parameter --- .rubocop.yml | 2 +- features/crud/get_notification.feature | 4 ++-- features/step_definitions/common/steps.rb | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 72443c8..ee3b3b0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,4 +10,4 @@ Style/GlobalVars: Enabled: false Metrics/LineLength: - Max: 120 \ No newline at end of file + Max: 130 \ No newline at end of file diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 2b59ddc..3caa5f2 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -6,7 +6,7 @@ Feature: GET request for notification endpoint When I set the body as: """ { - "channelId": 18 , + "channelId": 353 , "priority": "NORMAL", "recipients": ["#general"], "subject": "Test", @@ -20,7 +20,7 @@ Feature: GET request for notification endpoint 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 'GET' request to '/notifications/$id' until the 'status' is 'DELIVERED' + Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index b91c049..289cdd2 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -59,18 +59,17 @@ sleep 3 end -And(/^I '(?:GET|POST)' request to '(.+)' until the '(.+)' is '(.+)'$/) do |endpoint, params, value| +And(/^I make a '(\w+)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| time = 0 - result_expected = JSON.parse(@response.body)['notification'][params] + result_expected = JSON.parse(@response.body)[field][params] until result_expected == value sleep 1 time += 1 steps %{ - And I make a 'GET' request to '#{endpoint}' endpoint + And I make a '#{method}' request to '#{endpoint}' endpoint And I execute the request to the endpoint } - result_expected = JSON.parse(@response.body)['notification'][params] - + result_expected = JSON.parse(@response.body)[field][params] if time <= $maxWaitTime.to_i break end From 04b166a57466da58fbce5146d9fea41a09a8bea2 Mon Sep 17 00:00:00 2001 From: yuryver Date: Wed, 4 Oct 2017 15:31:41 -0400 Subject: [PATCH 24/85] dinamic paramethers --- features/crud/post_resend_notification.feature | 18 +++++++++--------- features/step_definitions/common/steps.rb | 7 ++++--- features/support/env.rb | 2 +- features/support/utils/enpoint_builder.rb | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature index 0981134..2e97471 100644 --- a/features/crud/post_resend_notification.feature +++ b/features/crud/post_resend_notification.feature @@ -5,7 +5,7 @@ Feature: CRUD resend notification When I set the body as: """ { - "channelId": 8, + "channelId": 510, "priority": "HIGH", "recipients": ["#general"], "subject": "test API", @@ -14,7 +14,7 @@ Feature: CRUD resend notification """ When I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' Scenario: resend a notification without param @@ -23,10 +23,10 @@ Feature: CRUD resend notification When I execute the request to the endpoint Then I expect a '200' status code - - Scenario: resend a notification with param - Given sleep - Given I make a 'POST' request to '/notifications/events/$id/resend' with: - | recipient | #general | - When I execute the request to the endpoint - Then I expect a '200' status code +# +# Scenario: resend a notification with param +# Given sleep +# Given I make a 'POST' request to '/notifications/events/$id/resend' with: +# | recipient | #general | +# When I execute the request to the endpoint +# Then I expect a '200' status code diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index b91c049..fcbe570 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -25,8 +25,9 @@ @request.body = body end -When(/^I save the id$/) do - $id = JSON.parse(@response.body)['id'] +When(/^I save the '(id)'$/) do |identify| + $id_hash.store(identify, JSON.parse(@response.body)[identify]) + $identifier_name = identify end Then(/^I build the response for "([^"]*)" with$/) do |template, json| @@ -59,7 +60,7 @@ sleep 3 end -And(/^I '(?:GET|POST)' request to '(.+)' until the '(.+)' is '(.+)'$/) do |endpoint, params, value| +And(/^I '(GET|POST)' request to '(.+)' until the '(.+)' is '(.+)'$/) do |endpoint, params, value| time = 0 result_expected = JSON.parse(@response.body)['notification'][params] until result_expected == value diff --git a/features/support/env.rb b/features/support/env.rb index 09c6d43..98c82e7 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -3,7 +3,7 @@ require 'pg' require 'rest-client' require 'yaml' - +$id_hash = {} def find_config_file(filename) root = Pathname.pwd until root.root? diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index 92e2ee1..3c66ed6 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -1,14 +1,14 @@ # This module build endpoint with id and params module EnpointBuilder def self.builder(enpoint) - enpoint.gsub('$id', $id.to_s) + enpoint.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')}" + params = "#{params.gsub('#', '%23')}" point = index.to_i.zero? ? "#{point}?#{params}" : "#{point}&#{params}" end point From 007db7a2f0bce4a0974bc4ee1e2af084cc57bd46 Mon Sep 17 00:00:00 2001 From: Abel Date: Wed, 4 Oct 2017 15:50:51 -0400 Subject: [PATCH 25/85] Improving Response Manager, adding more functional tests --- .../get_channels_params_name.feature | 59 +++++++ .../get_channels_params_type_EMAIL.feature | 32 ++++ .../get_channels_params_type_SLACK.feature | 31 ++++ .../get_channels_params_type_TWITTER.feature | 34 ++++ ...get_channels_params_type_WEB_HOOK.feature} | 6 +- ...negative_get_channels_invalid_type.feature | 158 ++++++++++++++++++ features/step_definitions/common/steps.rb | 15 +- features/support/env.yml | 4 +- features/support/utils/response_manager.rb | 60 ++++++- .../support/utils/templates/channels.json | 10 ++ features/support/utils/templates/error.json | 8 + 11 files changed, 396 insertions(+), 21 deletions(-) create mode 100644 features/functional/get_channels_params_name.feature create mode 100644 features/functional/get_channels_params_type_EMAIL.feature create mode 100644 features/functional/get_channels_params_type_SLACK.feature create mode 100644 features/functional/get_channels_params_type_TWITTER.feature rename features/functional/{get_channels.feature => get_channels_params_type_WEB_HOOK.feature} (82%) create mode 100644 features/functional/negative_get_channels_invalid_type.feature create mode 100644 features/support/utils/templates/channels.json create mode 100644 features/support/utils/templates/error.json diff --git a/features/functional/get_channels_params_name.feature b/features/functional/get_channels_params_name.feature new file mode 100644 index 0000000..5f144d3 --- /dev/null +++ b/features/functional/get_channels_params_name.feature @@ -0,0 +1,59 @@ +@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 + @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/get_channels_params_type_EMAIL.feature b/features/functional/get_channels_params_type_EMAIL.feature new file mode 100644 index 0000000..b094164 --- /dev/null +++ b/features/functional/get_channels_params_type_EMAIL.feature @@ -0,0 +1,32 @@ +@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 + @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 is the same as builded diff --git a/features/functional/get_channels_params_type_SLACK.feature b/features/functional/get_channels_params_type_SLACK.feature new file mode 100644 index 0000000..e840d0e --- /dev/null +++ b/features/functional/get_channels_params_type_SLACK.feature @@ -0,0 +1,31 @@ +@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 + @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 is the same as builded diff --git a/features/functional/get_channels_params_type_TWITTER.feature b/features/functional/get_channels_params_type_TWITTER.feature new file mode 100644 index 0000000..1d1a933 --- /dev/null +++ b/features/functional/get_channels_params_type_TWITTER.feature @@ -0,0 +1,34 @@ +@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 + @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 is the same as builded diff --git a/features/functional/get_channels.feature b/features/functional/get_channels_params_type_WEB_HOOK.feature similarity index 82% rename from features/functional/get_channels.feature rename to features/functional/get_channels_params_type_WEB_HOOK.feature index 3edba4d..1e260fa 100644 --- a/features/functional/get_channels.feature +++ b/features/functional/get_channels_params_type_WEB_HOOK.feature @@ -1,12 +1,12 @@ @functional -Feature: Functional get for channels +Feature: Functional get for channels with params type for WEB_HOOKS Background: Given I make a 'POST' request to '/channels' endpoint When I set the body as: """ { - "name": "AT04-Slack-Demo", + "name": "AT04-Web-Hook-Demo", "type": "WEB_HOOK", "configuration": { "url": "https://hooks.slack.com/services/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" @@ -22,7 +22,7 @@ Feature: Functional get for channels | type | WEB_HOOK | When I execute the request to the endpoint Then I expect a '200' status code - And I build the response for "channel" with + And I build the response for "channels" with """ { "onFail": null diff --git a/features/functional/negative_get_channels_invalid_type.feature b/features/functional/negative_get_channels_invalid_type.feature new file mode 100644 index 0000000..d7ed322 --- /dev/null +++ b/features/functional/negative_get_channels_invalid_type.feature @@ -0,0 +1,158 @@ +@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 + @delete_channel + Scenario: Get channel of type ANOTHER or invalid + Given I make a 'GET' request to '/channels' with: + | type | ANOTHER | + When I execute the request to the endpoint + Then I expect a '400' status code + And I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel of type empty + 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 I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @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 I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @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 + @delete_channel + Scenario: Get channel with correct name and empty ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | AT04-Web-Hook-Demo | + | ignoreCase | | + When I execute the request to the endpoint + Then I expect a '400' status code + And I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel with correct name and invalid ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | AT04-Web-Hook-Demo | + | ignoreCase | a | + When I execute the request to the endpoint + Then I expect a '400' status code + And I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel with empty name and valid ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | | + | ignoreCase | true | + When I execute the request to the endpoint + Then I expect a '400' status code + And I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel with empty name and valid ignoreCase + Given I make a 'GET' request to '/channels' with: + | name | | + | ignoreCase | false | + When I execute the request to the endpoint + Then I expect a '400' status code + And I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded + @delete_channel + Scenario: Get channel with empty name and empty 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 I build the error response with + """ + { + "status": 400, + "error": "Bad Request", + "message": "Bad Request", + "path": "/channels" + } + """ + And The response body is the same as builded diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index b91c049..f8079f9 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -21,7 +21,7 @@ end When(/^I set the body as:$/) do |body| - @body = JSON.parse(body) + @body = body @request.body = body end @@ -30,15 +30,12 @@ end Then(/^I build the response for "([^"]*)" with$/) do |template, json| - ResponseManager.parse_file_to_hash(template) - ResponseManager.replace_in_hash(@body) - ResponseManager.replace_in_hash(JSON.parse(json)) - response_hash = ResponseManager.diff_hash(JSON.parse(@response.body)) - @builded_hash = ResponseManager.replace_in_hash(response_hash) + @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 + # expect(@builded_hash[0].keys).to contain_exactly("id", "name", "type", "configuration", "onFail") puts @builded_hash.to_json puts @response.body end @@ -76,4 +73,8 @@ end end expect(value).to eq result_expected -end \ No newline at end of file +end + +Then(/^I build the error response with$/) do |json| + @builded_hash = ResponseManager.build_error_response('error', json, @response.body) +end diff --git a/features/support/env.yml b/features/support/env.yml index 0adbdf7..4256798 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,7 +1,7 @@ app: - host: + host: http://10.31.2.91 port: - rootPath: + rootPath: /api maxWaitTime: database: diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 7de8f8c..93add4f 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -1,22 +1,64 @@ # Manage the conversion of hashes and string to json module ResponseManager - def self.parse_file_to_hash(filename) - path = "./features/support/utils/templates/#{filename}.json" + def self.parse_file(filename) + base_path = File.dirname(__FILE__) + path = "#{base_path}/templates/#{filename}.json" file = File.read(path) - @template_hash = JSON.parse(file) - @hash = Hash[@template_hash] + @template = JSON.parse(file) + @copy = @template.is_a?(Hash) ? Hash[@template] : [].replace(@template) end def self.replace_in_hash(hash) - @template_hash.each_key do |key| - if !(@template_hash[key].eql? hash[key]) && (hash.key? key) - @hash[key] = hash[key] + @template.each_key do |key| + if !(@template[key].eql? hash[key]) && (hash.key? key) + @copy[key] = hash[key] end end - @hash + @copy end def self.diff_hash(hash) - hash.delete_if { |key| !(@hash[key].eql? @template_hash[key]) } + hash.delete_if { |key| !(@copy[key].eql? @template[key]) } + end + + def self.build_response(filename, request, expected, response) + parse_file(filename) + request = JSON.parse(request) + expected = JSON.parse(expected) + response = JSON.parse(response) + @copy.is_a?(Hash) ? build_with_hash(request, expected, response) : build_with_array(request, expected, response) + end + + def self.build_with_hash(request, expected, response) + replace_in_hash(request) + replace_in_hash(expected) + replace_in_hash(diff_hash(response)) + end + + def self.build_with_array(request, expected, response) + replace_in_array(request) + replace_in_array(expected) + replace_in_array(diff_array(response[0])) + end + + def self.replace_in_array(array) + @template[0].each_key do |key| + if !(@template[0][key].eql? array[key]) && (array.key? key) + @copy[0][key] = array[key] + end + end + @copy + end + + def self.diff_array(hash) + hash.delete_if { |key| !(@copy[0][key].eql? @template[0][key]) } + end + + def self.build_error_response(filename, expected, response) + parse_file(filename) + expected = JSON.parse(expected) + response = JSON.parse(response) + replace_in_hash(expected) + replace_in_hash(diff_hash(response)) end end 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" +} From fc8372368f1d9669b829770e886911495bf921b5 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Wed, 4 Oct 2017 18:53:29 -0400 Subject: [PATCH 26/85] Refactor of the step waiting until the change of a parameter --- features/crud/get_notification.feature | 2 +- features/crud/post_notifications.feature | 27 ++++++++++++++++++----- features/step_definitions/common/steps.rb | 25 ++++++++++++--------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 3caa5f2..0ae4657 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -6,7 +6,7 @@ Feature: GET request for notification endpoint When I set the body as: """ { - "channelId": 353 , + "channelId": 607 , "priority": "NORMAL", "recipients": ["#general"], "subject": "Test", diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index 0ba23f5..4a9c5d3 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -1,12 +1,29 @@ @crud Feature: POST request for notification endpoint + Background: + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "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 + + @delete_channel Scenario Outline: Send a new notification Given I make a 'POST' request to '/notifications' endpoint - When I set the body as: + When I set the body with id: """ { - "channelId": , + "channelId": $id, "priority": "", "recipients": [], "subject": "", @@ -23,8 +40,8 @@ Feature: POST request for notification endpoint } """ Examples: - | channelId | priority | recipients | subject | content | status_code | - | 18 | NORMAL | "#general","main" | Test | A testing message from notifier1 | 200 | - | 18 | NORMAL | "#general" | Test2 | A testing message from notifier2 | 200 | + | priority | recipients | subject | content | status_code | + | NORMAL | "#general","main" | Test1 | A testing message from notifier1 | 200 | + | NORMAL | "#general" | Test2 | A testing message from notifier2 | 200 | diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 289cdd2..20ef97c 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,6 +1,7 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method + EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @@ -9,6 +10,8 @@ Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| expect(@response.code).to eql(status_code_expected.to_i) + # puts @response.code + # puts @response.body end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| @@ -25,6 +28,12 @@ @request.body = body end +When(/^I set the body with id:$/) do |body| + body = body.gsub('$id', $id.to_s) + @body = JSON.parse(body) + @request.body = body +end + When(/^I save the id$/) do $id = JSON.parse(@response.body)['id'] end @@ -60,19 +69,15 @@ end And(/^I make a '(\w+)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| - time = 0 - result_expected = JSON.parse(@response.body)[field][params] - until result_expected == value + $app_max_wait_time.times do + result_expected = JSON.parse(@response.body)[field][params] + break if result_expected == value sleep 1 - time += 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] - if time <= $maxWaitTime.to_i - break - end + end - expect(value).to eq result_expected -end \ No newline at end of file +end From 515fd970b9069d8eb3f9a860192172a6f4d10239 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Wed, 4 Oct 2017 19:04:06 -0400 Subject: [PATCH 27/85] Delete spaces --- features/step_definitions/common/steps.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 20ef97c..36254b0 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -73,11 +73,9 @@ result_expected = JSON.parse(@response.body)[field][params] break if result_expected == value sleep 1 - steps %{ And I make a '#{method}' request to '#{endpoint}' endpoint And I execute the request to the endpoint } - end end From 0ba5f6775e89e479d53449a11de2d498c192e3cd Mon Sep 17 00:00:00 2001 From: yuryver Date: Wed, 4 Oct 2017 21:15:17 -0400 Subject: [PATCH 28/85] implement dynamic enpoint and wait time --- .../crud/post_resend_notification.feature | 14 +++---- features/step_definitions/common/steps.rb | 41 +++++++++++++------ features/support/env.yml | 8 ++-- features/support/utils/enpoint_builder.rb | 2 +- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature index 533d657..b5e5467 100644 --- a/features/crud/post_resend_notification.feature +++ b/features/crud/post_resend_notification.feature @@ -16,15 +16,13 @@ Feature: CRUD resend notification Then I expect a '200' status code And I save the 'id' - Scenario: resend a notification without param - And I make a 'POST' request to '/notifications/events/$id/resend' endpoint - When I execute the request to the endpoint + Given I make a 'POST' request to '/notifications/events/$id/resend' until that 'status' is 'RE_SEND' Then I expect a '200' status code - 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 expect a '200' status code +# 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 expect a '200' status code diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 27eac23..700ad1d 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,10 +1,12 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method + puts EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) + # puts @response end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| @@ -25,9 +27,9 @@ @request.body = body end -When(/^I save the '(id)'$/) do |identify| - $id_hash.store(identify, JSON.parse(@response.body)[identify]) - $identifier_name = identify +When(/^I save the '(\w+)'$/) do |name| + $id_hash.store(name, JSON.parse(@response.body)[name]) + $identifier_name = name end Then(/^I build the response for "([^"]*)" with$/) do |template, json| @@ -41,7 +43,7 @@ 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 + # puts @response.body end Then(/^I capture the response to the endpoint$/) do @@ -60,20 +62,33 @@ sleep 3 end -And(/^I make a '(\w+)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| - time = 0 - result_expected = JSON.parse(@response.body)[field][params] - until result_expected == value +And(/^I make a '(GET|POST)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| + endpoint = EnpointBuilder.builder(endpoint) + puts $app_max_wait_time + $app_max_wait_time.times do + steps %{ + And I make a '#{method}' request to '#{endpoint}' endpoint + And I execute the request to the endpoint + } + puts @response.empty? sleep 1 - time += 1 + end + value == JSON.parse(@response.body)[field][params] +end + + +And(/^I make a '(GET|POST)' request to '(.+)' until that '(.+)' is '(.+)'$/) do |method, endpoint, params, value| + endpoint = EnpointBuilder.builder(endpoint) + $app_max_wait_time.times do 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] - if time <= $maxWaitTime.to_i + if !@response.empty? && value == JSON.parse(@response.body)[params] break end + sleep 1 end - expect(value).to eq result_expected -end \ No newline at end of file +end + + diff --git a/features/support/env.yml b/features/support/env.yml index 0adbdf7..881ca37 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: - port: - rootPath: - maxWaitTime: + host: http://10.31.2.91 + port: 6161 + rootPath: /api + maxWaitTime: 5 database: connection: diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index 3c66ed6..62f6341 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -1,7 +1,7 @@ # This module build endpoint with id and params module EnpointBuilder def self.builder(enpoint) - enpoint.gsub('$id', $id_hash[$identifier_name].to_s) + enpoint.gsub("$#{$identifier_name}", $id_hash[$identifier_name].to_s) end def self.param(endpoint, param) From a9c4a0ad358308758cb11568db92ef747b09c124 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Thu, 5 Oct 2017 13:35:20 -0400 Subject: [PATCH 29/85] Refactor code - Post notifications --- features/crud/post_notifications.feature | 9 ++------ features/step_definitions/common/steps.rb | 28 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index 4a9c5d3..0f5659b 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -2,22 +2,18 @@ Feature: POST request for notification endpoint Background: - Given I make a 'POST' request to '/channels' endpoint - When I set the body as: + Given I create a Channel with the body as: """ { - "name": "AT04-Slack-Demo-for-Notifications", + "name": "AT04-Slack-Demo-for-Notifications561", "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 - @delete_channel Scenario Outline: Send a new notification Given I make a 'POST' request to '/notifications' endpoint When I set the body with id: @@ -42,6 +38,5 @@ Feature: POST request for notification endpoint Examples: | priority | recipients | subject | content | status_code | | NORMAL | "#general","main" | Test1 | A testing message from notifier1 | 200 | - | NORMAL | "#general" | Test2 | A testing message from notifier2 | 200 | diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 88e1bec..8b99cc0 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -9,9 +9,9 @@ end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| + puts @response.code + puts @response.body expect(@response.code).to eql(status_code_expected.to_i) - # puts @response.code - # puts @response.body end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| @@ -24,6 +24,8 @@ end When(/^I set the body as:$/) do |body| + p body.class + p body @body = body @request.body = body end @@ -36,6 +38,7 @@ When(/^I save the id$/) do $id = JSON.parse(@response.body)['id'] + p $id end Then(/^I build the response for "([^"]*)" with$/) do |template, json| @@ -81,3 +84,24 @@ Then(/^I build the error response with$/) do |json| @builded_hash = ResponseManager.build_error_response('error', json, @response.body) end + +Given(/^I create a Channel with the body as:$/) do |body| + steps %{ + Given I make a 'POST' request to '/channels' endpoint + When I set the body as: + """ + #{body} + """ + And I execute the request to the endpoint + Then I expect a '200' status code + } +end + + +Then(/^I delete the channel create$/) do |body| + enpoint ='/channels/$id' + enpoint.gsub('$id', $id.to_s) + request = ApiRequest.new(enpoint) + request.method = 'DELETE' + RequestManager.execute_request(request) +end From 62ffb4c44893cb04053b389762c6938cb1dfacb3 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Thu, 5 Oct 2017 13:36:26 -0400 Subject: [PATCH 30/85] Code Fix - Post notifications CRUD --- features/crud/post_notifications.feature | 2 +- features/step_definitions/common/steps.rb | 4 +--- features/support/utils/templates/notification.json | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index 0f5659b..ca8abb8 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -5,7 +5,7 @@ Feature: POST request for notification endpoint Given I create a Channel with the body as: """ { - "name": "AT04-Slack-Demo-for-Notifications561", + "name": "AT04-Slack-Demo-for-Notifications564", "type": "SLACK", "configuration": { "url": "https://hooks.slack.com/services/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" diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 8b99cc0..d6d0500 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -24,15 +24,13 @@ end When(/^I set the body as:$/) do |body| - p body.class - p body @body = body @request.body = body end When(/^I set the body with id:$/) do |body| body = body.gsub('$id', $id.to_s) - @body = JSON.parse(body) + @body = body @request.body = body end diff --git a/features/support/utils/templates/notification.json b/features/support/utils/templates/notification.json index 88955e8..397f0a5 100644 --- a/features/support/utils/templates/notification.json +++ b/features/support/utils/templates/notification.json @@ -3,7 +3,7 @@ "channelId": "integer", "priority": "string", "status": "string", - "recipients": ["string"], + "recipients": [], "attachments": "boolean", "content": "string", "templateId": "boolean" From b43b9ba28729d6d31490584a751abec024c9ea68 Mon Sep 17 00:00:00 2001 From: yuryver Date: Thu, 5 Oct 2017 15:15:49 -0400 Subject: [PATCH 31/85] corrections resend notification --- features/crud/get_notification.feature | 4 ++-- .../crud/post_resend_notification.feature | 22 ++++++++++++------- features/step_definitions/common/steps.rb | 17 ++++---------- features/support/hooks/hooks.rb | 5 ----- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 3e2a258..f09cd87 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -18,8 +18,8 @@ Feature: GET request for notification endpoint And I save the 'id' of 'notification' Scenario: Get notification by id - Given I make a 'GET' request to '/notifications/$id' endpoint - When I execute the request to the endpoint +# Given I make a 'GET' request to '/notifications/$id' 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' diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature index 9fafb33..1d73d55 100644 --- a/features/crud/post_resend_notification.feature +++ b/features/crud/post_resend_notification.feature @@ -6,7 +6,7 @@ Feature: CRUD resend notification When I set the body as: """ { - "name": "Chanel test resendas", + "name": "Chanel test resend AS:", "type": "SLACK", "configuration": { "url": "https://hooks.slack.com/services/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" @@ -24,20 +24,26 @@ Feature: CRUD resend notification "priority": "HIGH", "recipients": ["#general"], "subject": "test API", - "content": "Hi there, The JCN team is making a demo about Notifier RESEND." + "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' until that 'status' is 'DELIVERED' + 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 -# 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 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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 229fddf..5630ca4 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -5,12 +5,9 @@ When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) - # puts @response end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| - puts @response.code - puts @response.body expect(@response.code).to eql(status_code_expected.to_i) end @@ -29,7 +26,6 @@ end When(/^I set the body with id:$/) do |body| - puts $id_hash[$identifier_name] body = body.gsub('$id', $id_hash[$identifier_name].to_s) @body = body @request.body = body @@ -39,8 +35,6 @@ # $identifier_name = name $identifier_name = "#{type}_#{name}" $id_hash.store($identifier_name, JSON.parse(@response.body)[name]) - puts $id_hash[$identifier_name] - p $id_hash end Then(/^I build the response for "([^"]*)" with$/) do |template, json| @@ -49,9 +43,6 @@ Then(/^The response body is the same as builded$/) do expect(@builded_hash.to_json).to eq @response.body - # expect(@builded_hash[0].keys).to contain_exactly("id", "name", "type", "configuration", "onFail") - puts @builded_hash.to_json - # puts @response.body end Then(/^I capture the response to the endpoint$/) do @@ -66,21 +57,21 @@ expect(@response.body).to eq '' end -And(/^I make a '(\w+)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| +And(/^I make a '(GET)' request to '(.+)' until the field '(.+)' at '(.+)' is '(.+)'$/) do |method, endpoint, field, params, value| $app_max_wait_time.times do - @result_expected = JSON.parse(@response.body)[field][params] - break if @result_expected == value 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 -And(/^I make a '(GET|POST)' request to '(.+)' until that '(.+)' is '(.+)'$/) do |method, endpoint, params, value| +And(/^I make a '(GET)' request to '(.+)' until that '(.+)' is '(.+)'$/) do |method, endpoint, params, value| endpoint = EnpointBuilder.builder(endpoint) $app_max_wait_time.times do steps %{ diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb index d2610f5..80e4765 100644 --- a/features/support/hooks/hooks.rb +++ b/features/support/hooks/hooks.rb @@ -1,11 +1,6 @@ # Delete channel After('@delete_channel') do - puts "/////////////////////////// HOOKS ///////////////////" - p $id_hash enpoint = "/channels/#{$id_hash['channels_id'].to_s}" - # EnpointBuilder.builder('/channels/$id') - puts "////////////////////////////////////////////" - puts enpoint request = ApiRequest.new(enpoint) request.method = 'DELETE' RequestManager.execute_request(request) From 8eb6aa5df1cb5d2f6bfec46466dc4a613c69a1da Mon Sep 17 00:00:00 2001 From: yuryver Date: Thu, 5 Oct 2017 15:20:04 -0400 Subject: [PATCH 32/85] corrections name --- features/crud/post_notifications.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index aa389ab..f02de3c 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -5,7 +5,7 @@ Feature: POST request for notification endpoint Given I create a Channel with the body as: """ { - "name": "AT04-Slack-Demo-for-Notifications89assasas88", + "name": "AT04-Slack-Demo-for-Notifications", "type": "SLACK", "configuration": { "url": "https://hooks.slack.com/services/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" From 1eba5ee9218cb3dd8b4741b75a84d1a529099094 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 5 Oct 2017 15:42:57 -0400 Subject: [PATCH 33/85] Increasing Functional Post Channels --- features/crud/post_channel.feature | 75 ----------- ...negative_get_channels_invalid_type.feature | 123 +++++------------- .../functional/negative_post_channels.feature | 0 features/functional/post_channel.feature | 60 +++++++++ features/step_definitions/common/steps.rb | 19 ++- features/support/env.rb | 5 + features/support/env.yml | 6 +- 7 files changed, 118 insertions(+), 170 deletions(-) create mode 100644 features/functional/negative_post_channels.feature create mode 100644 features/functional/post_channel.feature diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index 5f88e73..446afd1 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -23,78 +23,3 @@ Feature: Post request for channels endpoint } """ And The response body is the same as builded - @delete_channel - Scenario: Create a new channel - Given I make a 'POST' request to '/channels' endpoint - And I set the body as: - """ - { - "name": "AT04-WebHook-Demo", - "type": "WEB_HOOK", - "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 - And I build the response for "channel" with - """ - { - "onFail": null - } - """ - And The response body is the same as builded - - @delete_channel - Scenario: Create a new channel - Given I make a 'POST' request to '/channels' endpoint - And I set the body as: - """ - { - "name": "AT04-Email-Demo", - "type": "EMAIL", - "configuration":{ - "mail.from":"example@jalasoft.com", - "mail.host":"127.0.0.1" - } - } - """ - When I execute the request to the endpoint - Then I expect a '200' status code - And I save the id - And I build the response for "channel" with - """ - { - "onFail": null - } - """ - And The response body is the same as builded - - @delete_channel - Scenario: Create a new channel - Given I make a 'POST' request to '/channels' endpoint - And 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" - } - } - """ - When I execute the request to the endpoint - Then I expect a '200' status code - And I save the id - And I build the response for "channel" with - """ - { - "onFail": null - } - """ - And The response body is the same as builded diff --git a/features/functional/negative_get_channels_invalid_type.feature b/features/functional/negative_get_channels_invalid_type.feature index d7ed322..d22c22a 100644 --- a/features/functional/negative_get_channels_invalid_type.feature +++ b/features/functional/negative_get_channels_invalid_type.feature @@ -17,53 +17,42 @@ Feature: Negative request get channels with invalid type Then I expect a '200' status code And I save the id @delete_channel - Scenario: Get channel of type ANOTHER or invalid + Scenario Outline: Get channel of invalid and empty type Given I make a 'GET' request to '/channels' with: - | type | ANOTHER | + | type | | When I execute the request to the endpoint Then I expect a '400' status code - And I build the error response with + And the response body contains excluding 'timestamp': """ { "status": 400, "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", "message": "Bad Request", "path": "/channels" } """ - And The response body is the same as builded - @delete_channel - Scenario: Get channel of type empty - 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 I build the error response with - """ - { - "status": 400, - "error": "Bad Request", - "message": "Bad Request", - "path": "/channels" - } - """ - And The response body is the same as builded + 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 I build the error response with + And the response body contains: """ { "status": 400, "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", "message": "Bad Request", "path": "/channels" } """ - And The response body is the same as builded @delete_channel Scenario: Get channel with nonexistent name Given I make a 'GET' request to '/channels' with: @@ -71,88 +60,46 @@ Feature: Negative request get channels with invalid type 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 - @delete_channel - Scenario: Get channel with correct name and empty ignoreCase - Given I make a 'GET' request to '/channels' with: - | name | AT04-Web-Hook-Demo | - | ignoreCase | | - When I execute the request to the endpoint - Then I expect a '400' status code - And I build the error response with - """ - { - "status": 400, - "error": "Bad Request", - "message": "Bad Request", - "path": "/channels" - } - """ - And The response body is the same as builded - @delete_channel - Scenario: Get channel with correct name and invalid ignoreCase - Given I make a 'GET' request to '/channels' with: - | name | AT04-Web-Hook-Demo | - | ignoreCase | a | - When I execute the request to the endpoint - Then I expect a '400' status code - And I build the error response with + And the response body contains: """ - { - "status": 400, - "error": "Bad Request", - "message": "Bad Request", - "path": "/channels" - } - """ - And The response body is the same as builded - @delete_channel - Scenario: Get channel with empty name and valid ignoreCase - Given I make a 'GET' request to '/channels' with: - | name | | - | ignoreCase | true | - When I execute the request to the endpoint - Then I expect a '400' status code - And I build the error response with - """ - { - "status": 400, - "error": "Bad Request", - "message": "Bad Request", - "path": "/channels" - } """ - And The response body is the same as builded @delete_channel - Scenario: Get channel with empty name and valid ignoreCase + Scenario Outline: Get channel with invalid name and ignoreCase Given I make a 'GET' request to '/channels' with: - | name | | - | ignoreCase | false | + | name | | + | ignoreCase | | When I execute the request to the endpoint Then I expect a '400' status code - And I build the error response with + And the response body contains: """ { "status": 400, "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", "message": "Bad Request", "path": "/channels" } """ - And The response body is the same as builded + Examples: + | Name | Case | + | AT04-Web-Hook-Demo | | + | AT04-Web-Hook-Demo | a | + | | true | + | | | + | | false | + @delete_channel - Scenario: Get channel with empty name and empty ignoreCase + Scenario Outline: Get channel with nonexistent name and valid ignoreCase Given I make a 'GET' request to '/channels' with: - | name | | - | ignoreCase | | + | name | | + | ignoreCase | | When I execute the request to the endpoint - Then I expect a '400' status code - And I build the error response with + Then I expect a '404' status code + And I expect that the GET response it is empty + And the response body contains: """ - { - "status": 400, - "error": "Bad Request", - "message": "Bad Request", - "path": "/channels" - } """ - And The response body is the same as builded + Examples: + | Name | Case | + | NoTExists | true | + | NoTExists | false | diff --git a/features/functional/negative_post_channels.feature b/features/functional/negative_post_channels.feature new file mode 100644 index 0000000..e69de29 diff --git a/features/functional/post_channel.feature b/features/functional/post_channel.feature new file mode 100644 index 0000000..128f394 --- /dev/null +++ b/features/functional/post_channel.feature @@ -0,0 +1,60 @@ +@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 + 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/services/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" | null | + | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | null | + | AT04-Twitter-Demo | TWITTER | "access_token": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | 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 + 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/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" | https://hooks.slack.com/services/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 | + | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services/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" | https://hooks.slack.com/services/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 | + | 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": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | https://hooks.slack.com/services/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 | diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 88e1bec..e283279 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,17 +1,16 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method - EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) + puts @response.code + puts @response.body end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| expect(@response.code).to eql(status_code_expected.to_i) - # puts @response.code - # puts @response.body end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| @@ -24,6 +23,7 @@ end When(/^I set the body as:$/) do |body| + puts body @body = body @request.body = body end @@ -44,7 +44,6 @@ Then(/^The response body is the same as builded$/) do expect(@builded_hash.to_json).to eq @response.body - # expect(@builded_hash[0].keys).to contain_exactly("id", "name", "type", "configuration", "onFail") puts @builded_hash.to_json puts @response.body end @@ -55,6 +54,7 @@ Then(/^I expect (?:PUT|POST) response is the same as GET response$/) do expect(JSON.parse(@response.body)).to eq JSON.parse(@stored_response) + expect(@response.body).to eq @stored_response end Then(/^I expect that the GET response it is empty$/) do @@ -81,3 +81,14 @@ Then(/^I build the error response with$/) do |json| @builded_hash = ResponseManager.build_error_response('error', json, @response.body) end + +Then(/^the response body contains:$/) do |json| + expect(json).to be_json_eql(@response.body).excluding("timestamp") + puts @response.body + puts json +end +Then(/^the response body contains excluding '([^"]*)':$/) do |exclude, json| + expect(json).to be_json_eql(@response.body).excluding(exclude) + puts @response.body + puts json +end diff --git a/features/support/env.rb b/features/support/env.rb index 09c6d43..4d83944 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,4 +1,5 @@ require 'json' +require 'json_spec/cucumber' require 'pathname' require 'pg' require 'rest-client' @@ -35,3 +36,7 @@ def load_app_config_file(filename) $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 index df3fc48..0adbdf7 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: http://10.31.2.91 + host: port: - rootPath: /api - maxWaitTime: 15 + rootPath: + maxWaitTime: database: connection: From 516b058767d31203c402d85fe700f197d77a1acb Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 5 Oct 2017 16:07:09 -0400 Subject: [PATCH 34/85] Solving empty errors --- .../get_channels_params_name.feature | 2 +- .../get_channels_params_type_EMAIL.feature | 2 +- .../get_channels_params_type_SLACK.feature | 2 +- .../get_channels_params_type_TWITTER.feature | 2 +- .../get_channels_params_type_WEB_HOOK.feature | 2 +- ...negative_get_channels_invalid_type.feature | 10 +++--- .../functional/negative_post_channels.feature | 31 +++++++++++++++++++ features/functional/post_channel.feature | 4 +-- features/smoke/smoke_channels.feature | 6 ---- features/step_definitions/common/steps.rb | 9 ------ 10 files changed, 43 insertions(+), 27 deletions(-) delete mode 100644 features/smoke/smoke_channels.feature diff --git a/features/functional/get_channels_params_name.feature b/features/functional/get_channels_params_name.feature index 5f144d3..10cf40b 100644 --- a/features/functional/get_channels_params_name.feature +++ b/features/functional/get_channels_params_name.feature @@ -15,7 +15,7 @@ Feature: Functional get for channels with params name """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + 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: diff --git a/features/functional/get_channels_params_type_EMAIL.feature b/features/functional/get_channels_params_type_EMAIL.feature index b094164..f097059 100644 --- a/features/functional/get_channels_params_type_EMAIL.feature +++ b/features/functional/get_channels_params_type_EMAIL.feature @@ -16,7 +16,7 @@ Feature: Functional get for channels with params type for EMAIL """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' of 'channels' @delete_channel Scenario: Get channel of type EMAIL Given I make a 'GET' request to '/channels' with: diff --git a/features/functional/get_channels_params_type_SLACK.feature b/features/functional/get_channels_params_type_SLACK.feature index e840d0e..5ca454d 100644 --- a/features/functional/get_channels_params_type_SLACK.feature +++ b/features/functional/get_channels_params_type_SLACK.feature @@ -15,7 +15,7 @@ Feature: Functional get for channels with params type for SLACK """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' of 'channels' @delete_channel Scenario: Get channel of type SLACK Given I make a 'GET' request to '/channels' with: diff --git a/features/functional/get_channels_params_type_TWITTER.feature b/features/functional/get_channels_params_type_TWITTER.feature index 1d1a933..71cd783 100644 --- a/features/functional/get_channels_params_type_TWITTER.feature +++ b/features/functional/get_channels_params_type_TWITTER.feature @@ -18,7 +18,7 @@ Feature: Functional get for channels with params type for TWITTER """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' of 'channels' @delete_channel Scenario: Get channel of type TWITTER Given I make a 'GET' request to '/channels' with: diff --git a/features/functional/get_channels_params_type_WEB_HOOK.feature b/features/functional/get_channels_params_type_WEB_HOOK.feature index 1e260fa..552ed69 100644 --- a/features/functional/get_channels_params_type_WEB_HOOK.feature +++ b/features/functional/get_channels_params_type_WEB_HOOK.feature @@ -15,7 +15,7 @@ Feature: Functional get for channels with params type for WEB_HOOKS """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + 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: diff --git a/features/functional/negative_get_channels_invalid_type.feature b/features/functional/negative_get_channels_invalid_type.feature index d22c22a..99d6398 100644 --- a/features/functional/negative_get_channels_invalid_type.feature +++ b/features/functional/negative_get_channels_invalid_type.feature @@ -15,7 +15,7 @@ Feature: Negative request get channels with invalid type """ And I execute the request to the endpoint Then I expect a '200' status code - And I save the id + 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: @@ -43,7 +43,7 @@ Feature: Negative request get channels with invalid type | name | | When I execute the request to the endpoint Then I expect a '400' status code - And the response body contains: + And the response body contains excluding 'timestamp': """ { "status": 400, @@ -60,7 +60,7 @@ Feature: Negative request get channels with invalid type 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: + And the response body contains excluding 'timestamp': """ """ @delete_channel @@ -70,7 +70,7 @@ Feature: Negative request get channels with invalid type | ignoreCase | | When I execute the request to the endpoint Then I expect a '400' status code - And the response body contains: + And the response body contains excluding 'timestamp': """ { "status": 400, @@ -96,7 +96,7 @@ Feature: Negative request get channels with invalid type 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: + And the response body contains excluding 'timestamp': """ """ Examples: diff --git a/features/functional/negative_post_channels.feature b/features/functional/negative_post_channels.feature index e69de29..7c5da3b 100644 --- a/features/functional/negative_post_channels.feature +++ b/features/functional/negative_post_channels.feature @@ -0,0 +1,31 @@ +# @functional +# Scenario: Negative responses after making a post request +# @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": "", +# "type": "", +# "configuration": { +# +# }, +# "onFail": "" +# } +# """ +# When I execute the request to the endpoint +# Then I expect a '400' 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/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" | https://hooks.slack.com/services/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 | +# | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services/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" | https://hooks.slack.com/services/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 | +# | 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": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | https://hooks.slack.com/services/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 | diff --git a/features/functional/post_channel.feature b/features/functional/post_channel.feature index 128f394..37796ae 100644 --- a/features/functional/post_channel.feature +++ b/features/functional/post_channel.feature @@ -15,7 +15,7 @@ Feature: Post request for channels endpoint """ When I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' of 'channels' And I build the response for "channel" with """ { @@ -45,7 +45,7 @@ Feature: Post request for channels endpoint """ When I execute the request to the endpoint Then I expect a '200' status code - And I save the id + And I save the 'id' of 'channels' And I build the response for "channel" with """ { diff --git a/features/smoke/smoke_channels.feature b/features/smoke/smoke_channels.feature deleted file mode 100644 index d5d0b11..0000000 --- a/features/smoke/smoke_channels.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature:Smoke Test Channels - - Scenario:Get all Channels - Given I make a 'GET' request to '/channels' - When I execute the request - Then I expect a '200' status code diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 86219d0..c19751f 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -5,8 +5,6 @@ When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) - puts @response.code - puts @response.body end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| @@ -23,7 +21,6 @@ end When(/^I set the body as:$/) do |body| - puts body @body = body @request.body = body end @@ -102,12 +99,6 @@ } end -Then(/^the response body contains:$/) do |json| - expect(json).to be_json_eql(@response.body).excluding("timestamp") - puts @response.body - puts json -end - Then(/^the response body contains excluding '([^"]*)':$/) do |exclude, json| expect(json).to be_json_eql(@response.body).excluding(exclude) puts @response.body From e84ade2e6ad1bdb95008b9e1e00b7ad0f36e2b81 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Thu, 5 Oct 2017 17:53:42 -0400 Subject: [PATCH 35/85] Improved Get notifications --- features/crud/get_notification.feature | 38 ++++++++++++++++++-------- features/support/env.yml | 6 ++-- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index f09cd87..fdb0ef1 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -1,22 +1,36 @@ @crud Feature: GET request for notification endpoint - Background: - Given I make a 'POST' request to '/notifications' endpoint + Background: Send a notification + Given I make a 'POST' request to '/channels' endpoint When I set the body as: - """ - { - "channelId": 607 , - "priority": "NORMAL", - "recipients": ["#general"], - "subject": "Test", - "content": "A testing message from notifier" - } - """ + """ + { + "name": "AT04-Slack-Demo-for-Notifications", + "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": $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 diff --git a/features/support/env.yml b/features/support/env.yml index 0adbdf7..ed58f55 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: + host: http://10.31.2.91/ port: - rootPath: - maxWaitTime: + rootPath: /api + maxWaitTime: 15 database: connection: From 81da7bad9618989cd9441186a39d10a947bd6fc4 Mon Sep 17 00:00:00 2001 From: yuryver Date: Thu, 5 Oct 2017 18:18:52 -0400 Subject: [PATCH 36/85] advanced functional testing templates --- .../get_template_id_has_been_deleted.feature | 22 ++++++++++++++ .../get_template_with_same_name.feature | 28 ++++++++++++++++++ .../template/get_templates_invalid_id.feature | 15 ++++++++++ .../put_template_id_has_been_deleted.feature | 29 +++++++++++++++++++ .../functional/template/put_templates.feature | 17 +++++++++++ features/step_definitions/common/steps.rb | 1 + 6 files changed, 112 insertions(+) create mode 100644 features/functional/template/get_template_id_has_been_deleted.feature create mode 100644 features/functional/template/get_template_with_same_name.feature create mode 100644 features/functional/template/get_templates_invalid_id.feature create mode 100644 features/functional/template/put_template_id_has_been_deleted.feature create mode 100644 features/functional/template/put_templates.feature diff --git a/features/functional/template/get_template_id_has_been_deleted.feature b/features/functional/template/get_template_id_has_been_deleted.feature new file mode 100644 index 0000000..931c137 --- /dev/null +++ b/features/functional/template/get_template_id_has_been_deleted.feature @@ -0,0 +1,22 @@ +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 + + Scenario: Send a new template with the same name + 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 diff --git a/features/functional/template/get_template_with_same_name.feature b/features/functional/template/get_template_with_same_name.feature new file mode 100644 index 0000000..084723f --- /dev/null +++ b/features/functional/template/get_template_with_same_name.feature @@ -0,0 +1,28 @@ +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' + + Scenario: Send a new template with the same name + Given I make a 'PUT' 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' + diff --git a/features/functional/template/get_templates_invalid_id.feature b/features/functional/template/get_templates_invalid_id.feature new file mode 100644 index 0000000..c0eb546 --- /dev/null +++ b/features/functional/template/get_templates_invalid_id.feature @@ -0,0 +1,15 @@ +Feature: Functional get for templates with ID + + Scenario Outline: Send a new template + Given I make a 'GET' request to '/api/templates/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + + Examples: + | id | status_code | description | + | yruadasd | 404 | Send an invalid id (letters) | + | asd13asd | 404 | Send an invalid id (letters and number) | + | 1 | 404 | Send a non-exist id | + | | 404 | Send an empty id | + | -3 | 404 | Send an id less or equals to 0 | + | 00045 | 404 | Send an id with zeros by front | diff --git a/features/functional/template/put_template_id_has_been_deleted.feature b/features/functional/template/put_template_id_has_been_deleted.feature new file mode 100644 index 0000000..9d58422 --- /dev/null +++ b/features/functional/template/put_template_id_has_been_deleted.feature @@ -0,0 +1,29 @@ +Feature: Functional put 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 + + Scenario: Send a new template with the same name + 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 diff --git a/features/functional/template/put_templates.feature b/features/functional/template/put_templates.feature new file mode 100644 index 0000000..934175f --- /dev/null +++ b/features/functional/template/put_templates.feature @@ -0,0 +1,17 @@ +Feature: Functional post for templates with ID + + Scenario Outline: Send a new template + Given I make a 'PUT' request to '/api/templates/' endpoint + When I execute the request to the endpoint + Then I expect a '' status code + + Examples: + | id | status_code | description | + | yruadasd | 404 | Send an invalid id (letters) | + | asd13asd | 404 | Send an invalid id (letters and number) | + | 1 | 404 | Send a non-exist id | + | | 404 | Send an empty id | + | -3 | 404 | Send an id less or equals to 0 | + | 00045 | 404 | Send an id with zeros by front | + + diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 5630ca4..7ef1367 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -5,6 +5,7 @@ When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) + puts @response end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| From f1e14d417d372029470e8837172e84d74013eab4 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Thu, 5 Oct 2017 19:56:28 -0400 Subject: [PATCH 37/85] Code fix --- features/crud/get_notification.feature | 8 +- features/crud/post_notifications.feature | 5 +- .../negative_post_notification.feature | 125 ++++++++++++++++++ features/step_definitions/common/steps.rb | 14 -- 4 files changed, 130 insertions(+), 22 deletions(-) create mode 100644 features/functional/negative_post_notification.feature diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index fdb0ef1..347d8e5 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -2,8 +2,7 @@ Feature: GET request for notification endpoint Background: Send a notification - Given I make a 'POST' request to '/channels' endpoint - When I set the body as: + Given I create a Channel with the body as: """ { "name": "AT04-Slack-Demo-for-Notifications", @@ -13,8 +12,6 @@ Feature: GET request for notification endpoint } } """ - 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: @@ -30,10 +27,9 @@ Feature: GET request for notification endpoint 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 make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index f02de3c..90325ed 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -1,7 +1,7 @@ @crud Feature: POST request for notification endpoint - Background: + Background: Create a Channel Given I create a Channel with the body as: """ { @@ -38,5 +38,6 @@ Feature: POST request for notification endpoint """ Examples: | priority | recipients | subject | content | status_code | - | NORMAL | "#general","main" | Test1 | A testing message from notifier1 | 200 | + | NORMAL | "#general" | Test1 | A testing message from notifier1 | 200 | + | NORMAL | "#general","main" | Test2 | A testing message from notifier2 | 200 | diff --git a/features/functional/negative_post_notification.feature b/features/functional/negative_post_notification.feature new file mode 100644 index 0000000..3f5fef1 --- /dev/null +++ b/features/functional/negative_post_notification.feature @@ -0,0 +1,125 @@ +Feature: Negative responses after making a post request + + Background: + Given I create a Channel with the 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 the channel id parameter + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with 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": "channelId", + "code": "channelId.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | + | NORMAL | "#general","main" | Test1 | A testing message from notifier | + + @delete_channel + Scenario Outline: Send a new notification without the recipients parameter + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $id, + "priority": "", + "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": "NotEmpty", + "defaultMessage": "may not be empty" + }, + { + "field": "recipients", + "code": "recipients.valid", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | subject | content | + | NORMAL | Test1 | A testing message from notifier | + + @delete_channel + Scenario Outline: Send a new notification with the empty recipients parameter + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $id, + "recipients": [], + "priority": "", + "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 + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | + | NORMAL | "" | Test1 | A testing message from notifier | diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c19751f..ed4e34c 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -73,20 +73,6 @@ expect(value).to eq @result_expected end -And(/^I make a '(GET)' request to '(.+)' until that '(.+)' is '(.+)'$/) do |method, endpoint, params, value| - endpoint = EnpointBuilder.builder(endpoint) - $app_max_wait_time.times do - steps %{ - And I make a '#{method}' request to '#{endpoint}' endpoint - And I execute the request to the endpoint - } - if @response.empty? && value == JSON.parse(@response.body)[params] - break - end - sleep 1 - end -end - Given(/^I create a Channel with the body as:$/) do |body| steps %{ Given I make a 'POST' request to '/channels' endpoint From 6ac83afc4628c9d2dbd7a782bbcbb41884378757 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Fri, 6 Oct 2017 14:59:37 -0400 Subject: [PATCH 38/85] Adding negatives features for Notifications --- features/crud/get_notification.feature | 2 +- features/crud/post_notifications.feature | 2 +- .../negative_post_notification.feature | 13 +-- ...ive_post_notification_empty_params.feature | 92 +++++++++++++++++++ features/step_definitions/common/steps.rb | 7 +- features/support/env.yml | 2 +- 6 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 features/functional/negative_post_notification_empty_params.feature diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 347d8e5..a45d003 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -2,7 +2,7 @@ Feature: GET request for notification endpoint Background: Send a notification - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04-Slack-Demo-for-Notifications", diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index 90325ed..12618a2 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -2,7 +2,7 @@ Feature: POST request for notification endpoint Background: Create a Channel - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04-Slack-Demo-for-Notifications", diff --git a/features/functional/negative_post_notification.feature b/features/functional/negative_post_notification.feature index 3f5fef1..79d7f60 100644 --- a/features/functional/negative_post_notification.feature +++ b/features/functional/negative_post_notification.feature @@ -1,7 +1,7 @@ Feature: Negative responses after making a post request - Background: - Given I create a Channel with the body as: + Background: Create a Channel + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04-Slack-Demo-for-Notifications", @@ -14,9 +14,9 @@ Feature: Negative responses after making a post request And I save the 'id' of 'channels' @delete_channel - Scenario Outline: Send a new notification without the channel id parameter + Scenario Outline: Send a new notification without the "id channel" parameter Given I make a 'POST' request to '/notifications' endpoint - When I set the body with id: + When I set the body as: """ { "priority": "", @@ -49,7 +49,7 @@ Feature: Negative responses after making a post request | NORMAL | "#general","main" | Test1 | A testing message from notifier | @delete_channel - Scenario Outline: Send a new notification without the recipients parameter + Scenario Outline: Send a new notification without the "recipients" parameter Given I make a 'POST' request to '/notifications' endpoint When I set the body with id: """ @@ -89,7 +89,7 @@ Feature: Negative responses after making a post request | NORMAL | Test1 | A testing message from notifier | @delete_channel - Scenario Outline: Send a new notification with the empty recipients parameter + Scenario Outline: Send a new notification with the "empty recipients" parameter Given I make a 'POST' request to '/notifications' endpoint When I set the body with id: """ @@ -123,3 +123,4 @@ Feature: Negative responses after making a post request Examples: | priority | recipients | subject | content | | NORMAL | "" | Test1 | A testing message from notifier | + diff --git a/features/functional/negative_post_notification_empty_params.feature b/features/functional/negative_post_notification_empty_params.feature new file mode 100644 index 0000000..eb9b57a --- /dev/null +++ b/features/functional/negative_post_notification_empty_params.feature @@ -0,0 +1,92 @@ +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 the parameter + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $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": "", + "code": "", + "defaultMessage": + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | priority | recipients | subject | content | field | code | default_message | + | NORMAL | "#general" | | A testing message from notifier | subject | subject.required | null | + | NORMAL | "#general" | Test | | content | content.required | null | + + @delete_channel + Scenario Outline: Send a new notification without subject and content parameter + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $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" | | | diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index ed4e34c..3c0e5e0 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -9,6 +9,7 @@ Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| expect(@response.code).to eql(status_code_expected.to_i) + p @request.body end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| @@ -73,15 +74,15 @@ expect(value).to eq @result_expected end -Given(/^I create a Channel with the body as:$/) do |body| +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 '/channels' endpoint + 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 '200' status code + Then I expect a '#{status}' status code } end diff --git a/features/support/env.yml b/features/support/env.yml index ed58f55..df3fc48 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,5 +1,5 @@ app: - host: http://10.31.2.91/ + host: http://10.31.2.91 port: rootPath: /api maxWaitTime: 15 From 6b6d3ebf2dfe46269d448e8b2b916011a4287e76 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Fri, 6 Oct 2017 15:58:58 -0400 Subject: [PATCH 39/85] Improved negative test for Notifications --- .../negative_post_notification.feature | 36 ---- ...post_notification_empty_parameters.feature | 191 ++++++++++++++++++ ...ive_post_notification_empty_params.feature | 92 --------- features/support/env.yml | 6 +- 4 files changed, 194 insertions(+), 131 deletions(-) create mode 100644 features/functional/negative_post_notification_empty_parameters.feature delete mode 100644 features/functional/negative_post_notification_empty_params.feature diff --git a/features/functional/negative_post_notification.feature b/features/functional/negative_post_notification.feature index 79d7f60..da979e1 100644 --- a/features/functional/negative_post_notification.feature +++ b/features/functional/negative_post_notification.feature @@ -88,39 +88,3 @@ Feature: Negative responses after making a post request | priority | subject | content | | NORMAL | Test1 | A testing message from notifier | - @delete_channel - Scenario Outline: Send a new notification with the "empty recipients" parameter - Given I make a 'POST' request to '/notifications' endpoint - When I set the body with id: - """ - { - "channelId": $id, - "recipients": [], - "priority": "", - "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 - } - ], - "message": "Bad Request", - "path": "/notifications" - } - """ - Examples: - | priority | recipients | subject | content | - | NORMAL | "" | Test1 | A testing message from notifier | - diff --git a/features/functional/negative_post_notification_empty_parameters.feature b/features/functional/negative_post_notification_empty_parameters.feature new file mode 100644 index 0000000..5863147 --- /dev/null +++ b/features/functional/negative_post_notification_empty_parameters.feature @@ -0,0 +1,191 @@ +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 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 | + | $id | NORMAL | | Test | A testing message from notifier | recipients | recipients.valid | + | $id | NORMAL | #general | | A testing message from notifier | subject | subject.required | + | $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": $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": $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/negative_post_notification_empty_params.feature b/features/functional/negative_post_notification_empty_params.feature deleted file mode 100644 index eb9b57a..0000000 --- a/features/functional/negative_post_notification_empty_params.feature +++ /dev/null @@ -1,92 +0,0 @@ -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 the parameter - Given I make a 'POST' request to '/notifications' endpoint - When I set the body with id: - """ - { - "channelId": $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": "", - "code": "", - "defaultMessage": - } - ], - "message": "Bad Request", - "path": "/notifications" - } - """ - Examples: - | priority | recipients | subject | content | field | code | default_message | - | NORMAL | "#general" | | A testing message from notifier | subject | subject.required | null | - | NORMAL | "#general" | Test | | content | content.required | null | - - @delete_channel - Scenario Outline: Send a new notification without subject and content parameter - Given I make a 'POST' request to '/notifications' endpoint - When I set the body with id: - """ - { - "channelId": $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" | | | diff --git a/features/support/env.yml b/features/support/env.yml index df3fc48..0adbdf7 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: http://10.31.2.91 + host: port: - rootPath: /api - maxWaitTime: 15 + rootPath: + maxWaitTime: database: connection: From df872a996baaea3ebddb0a1e5018594aca1c49ba Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Fri, 6 Oct 2017 16:43:15 -0400 Subject: [PATCH 40/85] Improved CRUD --- ...post_notification_empty_parameters.feature | 2 +- features/smoke/channels.feature | 6 ---- features/smoke/channels_templates.feature | 11 ++++++ features/smoke/notification.feature | 6 ---- features/smoke/specific_channel.feature | 24 +++++++++++-- features/smoke/specific_notification.feature | 35 +++++++++++++++++++ features/smoke/specific_template.feature | 21 +++++++++-- features/smoke/templates.feature | 6 ---- 8 files changed, 86 insertions(+), 25 deletions(-) delete mode 100644 features/smoke/channels.feature create mode 100644 features/smoke/channels_templates.feature delete mode 100644 features/smoke/notification.feature create mode 100644 features/smoke/specific_notification.feature delete mode 100644 features/smoke/templates.feature diff --git a/features/functional/negative_post_notification_empty_parameters.feature b/features/functional/negative_post_notification_empty_parameters.feature index 5863147..83c92c7 100644 --- a/features/functional/negative_post_notification_empty_parameters.feature +++ b/features/functional/negative_post_notification_empty_parameters.feature @@ -1,4 +1,4 @@ -Feature: Negative responses after making a post request +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: diff --git a/features/smoke/channels.feature b/features/smoke/channels.feature deleted file mode 100644 index fccda6c..0000000 --- a/features/smoke/channels.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature:Channels - - 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 \ 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..d4d819b --- /dev/null +++ b/features/smoke/channels_templates.feature @@ -0,0 +1,11 @@ +@smoke +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/notification.feature b/features/smoke/notification.feature deleted file mode 100644 index 0ec7070..0000000 --- a/features/smoke/notification.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature:Specific Notification - - Scenario: Get a specific Notification - Given I make a 'GET' request to '/notifications/3e8d2814-f298-4474-8767-a69fb3d4bcb2' 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_channel.feature b/features/smoke/specific_channel.feature index b42286c..640dbab 100644 --- a/features/smoke/specific_channel.feature +++ b/features/smoke/specific_channel.feature @@ -1,6 +1,24 @@ -Feature:Specific Channels +@smoke +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/1' endpoint + 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 \ No newline at end of file + 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..15906c8 --- /dev/null +++ b/features/smoke/specific_notification.feature @@ -0,0 +1,35 @@ +@smoke +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": $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 index c1f3509..3fdfeef 100644 --- a/features/smoke/specific_template.feature +++ b/features/smoke/specific_template.feature @@ -1,6 +1,21 @@ -Feature:Specific Template +@smoke +Feature: Specific Template - Scenario: Get a specific Template - Given I make a 'GET' request to '/templates/1' endpoint + 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/smoke/templates.feature b/features/smoke/templates.feature deleted file mode 100644 index 6f5067e..0000000 --- a/features/smoke/templates.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature:Templates - - 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 \ No newline at end of file From 5a89cde450ece20a84cd88aa9c9a0de90511db88 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Fri, 6 Oct 2017 17:04:53 -0400 Subject: [PATCH 41/85] Delete unnecessary puts --- features/step_definitions/common/steps.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 3c0e5e0..bee8c22 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -9,7 +9,6 @@ Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| expect(@response.code).to eql(status_code_expected.to_i) - p @request.body end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| From 288828e80d84d8c0cc4e588d016b41d7521c9a1f Mon Sep 17 00:00:00 2001 From: Abel Date: Fri, 6 Oct 2017 17:32:22 -0400 Subject: [PATCH 42/85] Adding get, post and put functional test for channels --- .../negative_get_channels_by_id.feature | 32 ++++++++ ...negative_get_channels_invalid_type.feature | 2 +- .../functional/negative_post_channels.feature | 79 +++++++++++-------- .../negative_post_channels_invalid.feature | 47 +++++++++++ .../negative_post_channels_required.feature | 36 +++++++++ .../negative_post_channels_twitter.feature | 50 ++++++++++++ .../functional/negative_put_channels.feature | 59 ++++++++++++++ .../negative_put_channels_invalid.feature | 58 ++++++++++++++ .../negative_put_channels_required.feature | 47 +++++++++++ .../negative_put_channels_twitter.feature | 62 +++++++++++++++ features/functional/put_channels.feature | 54 +++++++++++++ features/step_definitions/common/steps.rb | 9 ++- features/support/hooks/hooks.rb | 4 +- 13 files changed, 504 insertions(+), 35 deletions(-) create mode 100644 features/functional/negative_get_channels_by_id.feature create mode 100644 features/functional/negative_post_channels_invalid.feature create mode 100644 features/functional/negative_post_channels_required.feature create mode 100644 features/functional/negative_post_channels_twitter.feature create mode 100644 features/functional/negative_put_channels.feature create mode 100644 features/functional/negative_put_channels_invalid.feature create mode 100644 features/functional/negative_put_channels_required.feature create mode 100644 features/functional/negative_put_channels_twitter.feature create mode 100644 features/functional/put_channels.feature diff --git a/features/functional/negative_get_channels_by_id.feature b/features/functional/negative_get_channels_by_id.feature new file mode 100644 index 0000000..62a9bf3 --- /dev/null +++ b/features/functional/negative_get_channels_by_id.feature @@ -0,0 +1,32 @@ +@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/negative_get_channels_invalid_type.feature b/features/functional/negative_get_channels_invalid_type.feature index 99d6398..f89462d 100644 --- a/features/functional/negative_get_channels_invalid_type.feature +++ b/features/functional/negative_get_channels_invalid_type.feature @@ -96,7 +96,7 @@ Feature: Negative request get channels with invalid type 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': + And the response body contains excluding '': """ """ Examples: diff --git a/features/functional/negative_post_channels.feature b/features/functional/negative_post_channels.feature index 7c5da3b..bff2f8a 100644 --- a/features/functional/negative_post_channels.feature +++ b/features/functional/negative_post_channels.feature @@ -1,31 +1,48 @@ -# @functional -# Scenario: Negative responses after making a post request -# @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": "", -# "type": "", -# "configuration": { -# -# }, -# "onFail": "" -# } -# """ -# When I execute the request to the endpoint -# Then I expect a '400' 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/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" | https://hooks.slack.com/services/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 | -# | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services/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" | https://hooks.slack.com/services/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 | -# | 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": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | https://hooks.slack.com/services/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 | +@functional +Feature: Negative responses after making a post request + @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": "", + "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": [ + + ], + "message": "Bad Request", + "path": "/channels" + } + """ + 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/negative_post_channels_invalid.feature b/features/functional/negative_post_channels_invalid.feature new file mode 100644 index 0000000..500d321 --- /dev/null +++ b/features/functional/negative_post_channels_invalid.feature @@ -0,0 +1,47 @@ +@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/negative_post_channels_required.feature b/features/functional/negative_post_channels_required.feature new file mode 100644 index 0000000..dc4e753 --- /dev/null +++ b/features/functional/negative_post_channels_required.feature @@ -0,0 +1,36 @@ +@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/negative_post_channels_twitter.feature b/features/functional/negative_post_channels_twitter.feature new file mode 100644 index 0000000..a72b098 --- /dev/null +++ b/features/functional/negative_post_channels_twitter.feature @@ -0,0 +1,50 @@ +@functional +Feature: Negativo 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": [ + + ], + "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/negative_put_channels.feature b/features/functional/negative_put_channels.feature new file mode 100644 index 0000000..0da2af4 --- /dev/null +++ b/features/functional/negative_put_channels.feature @@ -0,0 +1,59 @@ +@functional +Feature: Negative responses after making a put request + Background: + Given I create a Channel with the 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/negative_put_channels_invalid.feature b/features/functional/negative_put_channels_invalid.feature new file mode 100644 index 0000000..f3189bb --- /dev/null +++ b/features/functional/negative_put_channels_invalid.feature @@ -0,0 +1,58 @@ +@functional +Feature: Negative responses after making a put request + Background: + Given I create a Channel with the 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/negative_put_channels_required.feature b/features/functional/negative_put_channels_required.feature new file mode 100644 index 0000000..ab41dab --- /dev/null +++ b/features/functional/negative_put_channels_required.feature @@ -0,0 +1,47 @@ +@functional +Feature: Negative responses after making a post request + Background: + Given I create a Channel with the 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/negative_put_channels_twitter.feature b/features/functional/negative_put_channels_twitter.feature new file mode 100644 index 0000000..28bb46f --- /dev/null +++ b/features/functional/negative_put_channels_twitter.feature @@ -0,0 +1,62 @@ +@functional +Feature: Negative responses after making a put request + Background: + Given I create a Channel with the 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/put_channels.feature b/features/functional/put_channels.feature new file mode 100644 index 0000000..0956782 --- /dev/null +++ b/features/functional/put_channels.feature @@ -0,0 +1,54 @@ +@functional +Feature: Puts request for channels endpoint + + Background: + Given I create a Channel with the 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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c19751f..801b1ba 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -52,8 +52,9 @@ end Then(/^I expect (?:PUT|POST) response is the same as GET response$/) do - expect(JSON.parse(@response.body)).to eq JSON.parse(@stored_response) expect(@response.body).to eq @stored_response + puts @response.body + puts @stored_response end Then(/^I expect that the GET response it is empty$/) do @@ -101,6 +102,12 @@ 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 diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb index 80e4765..c7e3323 100644 --- a/features/support/hooks/hooks.rb +++ b/features/support/hooks/hooks.rb @@ -1,7 +1,7 @@ # Delete channel After('@delete_channel') do - enpoint = "/channels/#{$id_hash['channels_id'].to_s}" - request = ApiRequest.new(enpoint) + endpoint = "/channels/#{$id_hash['channels_id']}" + request = ApiRequest.new(endpoint) request.method = 'DELETE' RequestManager.execute_request(request) end From 31f6f73290e467de74a18ed5b6a8983a56add34c Mon Sep 17 00:00:00 2001 From: yuryver Date: Fri, 6 Oct 2017 17:49:41 -0400 Subject: [PATCH 43/85] functional templates --- .../delete_template_invalid_id.feature | 30 +++++ .../get_template_id_has_been_deleted.feature | 22 ---- .../get_template_with_same_name.feature | 28 ----- .../template/get_templates_invalid_id.feature | 28 ++++- .../template/put_template_with_param.feature | 105 ++++++++++++++++++ .../functional/template/put_templates.feature | 35 ++++-- ...e => template_id_has_been_deleted.feature} | 19 +++- features/support/hooks/hooks.rb | 9 ++ 8 files changed, 210 insertions(+), 66 deletions(-) create mode 100644 features/functional/template/delete_template_invalid_id.feature delete mode 100644 features/functional/template/get_template_id_has_been_deleted.feature delete mode 100644 features/functional/template/get_template_with_same_name.feature create mode 100644 features/functional/template/put_template_with_param.feature rename features/functional/template/{put_template_id_has_been_deleted.feature => template_id_has_been_deleted.feature} (59%) diff --git a/features/functional/template/delete_template_invalid_id.feature b/features/functional/template/delete_template_invalid_id.feature new file mode 100644 index 0000000..d8e34d9 --- /dev/null +++ b/features/functional/template/delete_template_invalid_id.feature @@ -0,0 +1,30 @@ +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' + + @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 | + | 000$id | 200 | Send an id with zeros by front | + | 0 | 404 | Send an id 0 | diff --git a/features/functional/template/get_template_id_has_been_deleted.feature b/features/functional/template/get_template_id_has_been_deleted.feature deleted file mode 100644 index 931c137..0000000 --- a/features/functional/template/get_template_id_has_been_deleted.feature +++ /dev/null @@ -1,22 +0,0 @@ -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 - - Scenario: Send a new template with the same name - 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 diff --git a/features/functional/template/get_template_with_same_name.feature b/features/functional/template/get_template_with_same_name.feature deleted file mode 100644 index 084723f..0000000 --- a/features/functional/template/get_template_with_same_name.feature +++ /dev/null @@ -1,28 +0,0 @@ -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' - - Scenario: Send a new template with the same name - Given I make a 'PUT' 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' - diff --git a/features/functional/template/get_templates_invalid_id.feature b/features/functional/template/get_templates_invalid_id.feature index c0eb546..3e63926 100644 --- a/features/functional/template/get_templates_invalid_id.feature +++ b/features/functional/template/get_templates_invalid_id.feature @@ -1,15 +1,31 @@ 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' + + @delete_templates Scenario Outline: Send a new template - Given I make a 'GET' request to '/api/templates/' endpoint + 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 | - | yruadasd | 404 | Send an invalid id (letters) | - | asd13asd | 404 | Send an invalid id (letters and number) | + | 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 | - | | 404 | Send an empty id | + | | 200 | Send an empty id | | -3 | 404 | Send an id less or equals to 0 | - | 00045 | 404 | Send an id with zeros by front | + | 000$id | 200 | Send an id with zeros by front | + | 0 | 404 | Send an id 0 | + diff --git a/features/functional/template/put_template_with_param.feature b/features/functional/template/put_template_with_param.feature new file mode 100644 index 0000000..9ac837e --- /dev/null +++ b/features/functional/template/put_template_with_param.feature @@ -0,0 +1,105 @@ +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' + + @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 + + @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 \ No newline at end of file diff --git a/features/functional/template/put_templates.feature b/features/functional/template/put_templates.feature index 934175f..932cfec 100644 --- a/features/functional/template/put_templates.feature +++ b/features/functional/template/put_templates.feature @@ -1,17 +1,38 @@ 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' + + @delete_templates Scenario Outline: Send a new template - Given I make a 'PUT' request to '/api/templates/' endpoint + 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 | - | yruadasd | 404 | Send an invalid id (letters) | - | asd13asd | 404 | Send an invalid id (letters and number) | + | DIKJAS | 400 | Send an invalid id (letters) | + | asd13asd | 400 | Send an invalid id (letters and number) | | 1 | 404 | Send a non-exist id | - | | 404 | Send an empty id | + | | 405 | Send an empty id | | -3 | 404 | Send an id less or equals to 0 | - | 00045 | 404 | Send an id with zeros by front | - - + | 000$id | 200 | Send an id with zeros by front | + | 0 | 404 | Send an id 0 | diff --git a/features/functional/template/put_template_id_has_been_deleted.feature b/features/functional/template/template_id_has_been_deleted.feature similarity index 59% rename from features/functional/template/put_template_id_has_been_deleted.feature rename to features/functional/template/template_id_has_been_deleted.feature index 9d58422..607aa2b 100644 --- a/features/functional/template/put_template_id_has_been_deleted.feature +++ b/features/functional/template/template_id_has_been_deleted.feature @@ -1,4 +1,4 @@ -Feature: Functional put for templates with ID +Feature: Functional get for templates with ID Background: create a new template Given I make a 'POST' request to '/templates' endpoint @@ -16,7 +16,20 @@ Feature: Functional put for templates with ID When I execute the request to the endpoint Then I expect a '200' status code - Scenario: Send a new template with the same name + @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: """ @@ -26,4 +39,4 @@ Feature: Functional put for templates with ID } """ When I execute the request to the endpoint - Then I expect a '404' status code + Then I expect a '404' status code \ No newline at end of file diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb index 80e4765..902b177 100644 --- a/features/support/hooks/hooks.rb +++ b/features/support/hooks/hooks.rb @@ -5,3 +5,12 @@ request.method = 'DELETE' RequestManager.execute_request(request) end + +# Delete templates +After('@delete_templates') do + enpoint = "/templates/#{$id_hash['templates_id'].to_s}" + request = ApiRequest.new(enpoint) + request.method = 'DELETE' + RequestManager.execute_request(request) +end + From 48a156470346d7f010b650b404506aa8c1ae2d99 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Fri, 6 Oct 2017 21:53:40 +0000 Subject: [PATCH 44/85] adding generated reports --- Gemfile | 1 + Gemfile.lock | 1 + Rakefile | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 Rakefile diff --git a/Gemfile b/Gemfile index d82d173..8c9bb5e 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gem 'cucumber' gem 'json' gem 'json_spec' gem 'pg' +gem 'rake' gem 'report_builder' gem 'rest-client' gem 'rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 2fa33f0..3c2002a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,6 +81,7 @@ DEPENDENCIES json json_spec pg + rake report_builder rest-client rspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..9ea1273 --- /dev/null +++ b/Rakefile @@ -0,0 +1,27 @@ +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 + + From eee045390499e6e9b126ce02e7a08bcc73b0cd36 Mon Sep 17 00:00:00 2001 From: Abel Date: Fri, 6 Oct 2017 18:05:59 -0400 Subject: [PATCH 45/85] Fixing missing steps --- features/functional/negative_put_channels.feature | 2 +- features/functional/negative_put_channels_invalid.feature | 2 +- features/functional/negative_put_channels_required.feature | 2 +- features/functional/negative_put_channels_twitter.feature | 2 +- features/functional/put_channels.feature | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/features/functional/negative_put_channels.feature b/features/functional/negative_put_channels.feature index 0da2af4..29ea587 100644 --- a/features/functional/negative_put_channels.feature +++ b/features/functional/negative_put_channels.feature @@ -1,7 +1,7 @@ @functional Feature: Negative responses after making a put request Background: - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04_Old_Name", diff --git a/features/functional/negative_put_channels_invalid.feature b/features/functional/negative_put_channels_invalid.feature index f3189bb..ec2490d 100644 --- a/features/functional/negative_put_channels_invalid.feature +++ b/features/functional/negative_put_channels_invalid.feature @@ -1,7 +1,7 @@ @functional Feature: Negative responses after making a put request Background: - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04_Old_Name", diff --git a/features/functional/negative_put_channels_required.feature b/features/functional/negative_put_channels_required.feature index ab41dab..e4c6a4c 100644 --- a/features/functional/negative_put_channels_required.feature +++ b/features/functional/negative_put_channels_required.feature @@ -1,7 +1,7 @@ @functional Feature: Negative responses after making a post request Background: - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04_Old_Name", diff --git a/features/functional/negative_put_channels_twitter.feature b/features/functional/negative_put_channels_twitter.feature index 28bb46f..711bff8 100644 --- a/features/functional/negative_put_channels_twitter.feature +++ b/features/functional/negative_put_channels_twitter.feature @@ -1,7 +1,7 @@ @functional Feature: Negative responses after making a put request Background: - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04_Old_Name", diff --git a/features/functional/put_channels.feature b/features/functional/put_channels.feature index 0956782..62621f4 100644 --- a/features/functional/put_channels.feature +++ b/features/functional/put_channels.feature @@ -2,7 +2,7 @@ Feature: Puts request for channels endpoint Background: - Given I create a Channel with the body as: + Given I create a 'channel' with status code '200' and body as: """ { "name": "AT04_Old_Name", From 5152bceabe44ad2d7d86915cf0c823a5df7cd0f5 Mon Sep 17 00:00:00 2001 From: yuryver Date: Fri, 6 Oct 2017 18:10:41 -0400 Subject: [PATCH 46/85] corrections rubocop --- features/step_definitions/common/steps.rb | 1 - features/support/hooks/hooks.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 11c14a0..406fc1d 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -5,7 +5,6 @@ When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) - puts @response end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb index 259f3e7..35c26f1 100644 --- a/features/support/hooks/hooks.rb +++ b/features/support/hooks/hooks.rb @@ -8,8 +8,8 @@ # Delete templates After('@delete_templates') do - enpoint = "/templates/#{$id_hash['templates_id'].to_s}" - request = ApiRequest.new(enpoint) + endpoint = "/templates/#{$id_hash['templates_id']}" + request = ApiRequest.new(endpoint) request.method = 'DELETE' RequestManager.execute_request(request) end From 90833ce9e0f7aea167158c48d913d7bf6b05c58c Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Fri, 6 Oct 2017 22:37:58 +0000 Subject: [PATCH 47/85] adding tags --- features/crud/delete_template.feature | 1 + features/crud/get_template.feature | 1 + features/crud/get_templates.feature | 1 + features/crud/post_template.feature | 1 + features/crud/put_template.feature | 1 + reports/.gitignore | 0 reports/all/.gitignore | 0 reports/crud/.gitignore | 0 reports/functional/.gitignore | 0 reports/smoke/.gitignore | 0 10 files changed, 5 insertions(+) create mode 100644 reports/.gitignore create mode 100644 reports/all/.gitignore create mode 100644 reports/crud/.gitignore create mode 100644 reports/functional/.gitignore create mode 100644 reports/smoke/.gitignore diff --git a/features/crud/delete_template.feature b/features/crud/delete_template.feature index 5c16da2..37bd97f 100644 --- a/features/crud/delete_template.feature +++ b/features/crud/delete_template.feature @@ -1,3 +1,4 @@ +@crud Feature: delete template Background: diff --git a/features/crud/get_template.feature b/features/crud/get_template.feature index 5bda104..77aa92d 100644 --- a/features/crud/get_template.feature +++ b/features/crud/get_template.feature @@ -1,3 +1,4 @@ +@crud Feature: get specific template Background: diff --git a/features/crud/get_templates.feature b/features/crud/get_templates.feature index 18791e1..0654555 100644 --- a/features/crud/get_templates.feature +++ b/features/crud/get_templates.feature @@ -1,3 +1,4 @@ +@crud Feature: get templates Scenario: Get all templates diff --git a/features/crud/post_template.feature b/features/crud/post_template.feature index 56b8e51..fd6dd8a 100644 --- a/features/crud/post_template.feature +++ b/features/crud/post_template.feature @@ -1,3 +1,4 @@ +@crud Feature: template Scenario: create a new template diff --git a/features/crud/put_template.feature b/features/crud/put_template.feature index a26da14..637ea8c 100644 --- a/features/crud/put_template.feature +++ b/features/crud/put_template.feature @@ -1,3 +1,4 @@ +@crud Feature: template Background: 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 From 3ce33c0ddf410096babc680c7ebe61042e374894 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Sat, 7 Oct 2017 16:20:08 +0000 Subject: [PATCH 48/85] adding negatives functional channels features --- .../get_channels_params_name.feature | 2 +- .../get_channels_params_type_EMAIL.feature | 2 +- .../get_channels_params_type_SLACK.feature | 2 +- .../get_channels_params_type_TWITTER.feature | 2 +- .../get_channels_params_type_WEB_HOOK.feature | 2 +- ...ve_delete_channel_invalid_endpoint.feature | 44 +++++++++++++++++++ ...negative_delete_channel_invalid_id.feature | 38 ++++++++++++++++ .../negative_get_channels_by_id.feature | 2 +- ...negative_get_channels_invalid_type.feature | 2 +- .../negative_post_channels.feature | 2 +- .../negative_post_channels_invalid.feature | 2 +- .../negative_post_channels_required.feature | 2 +- .../negative_post_channels_twitter.feature | 2 +- .../negative_put_channels.feature | 2 +- .../negative_put_channels_invalid.feature | 2 +- .../negative_put_channels_required.feature | 2 +- .../negative_put_channels_twitter.feature | 2 +- .../{ => channels}/post_channel.feature | 2 +- .../{ => channels}/put_channels.feature | 2 +- .../negative_post_notification.feature | 1 + ...post_notification_empty_parameters.feature | 1 + .../delete_template_invalid_id.feature | 1 + .../get_templates_invalid_id.feature | 1 + .../put_template_with_param.feature | 1 + .../put_templates.feature | 1 + .../template_id_has_been_deleted.feature | 1 + features/smoke/channels_templates.feature | 2 +- features/smoke/specific_channel.feature | 2 +- features/smoke/specific_notification.feature | 2 +- features/smoke/specific_template.feature | 2 +- features/support/env.yml | 7 +-- 31 files changed, 114 insertions(+), 24 deletions(-) rename features/functional/{ => channels}/get_channels_params_name.feature (99%) rename features/functional/{ => channels}/get_channels_params_type_EMAIL.feature (98%) rename features/functional/{ => channels}/get_channels_params_type_SLACK.feature (98%) rename features/functional/{ => channels}/get_channels_params_type_TWITTER.feature (98%) rename features/functional/{ => channels}/get_channels_params_type_WEB_HOOK.feature (98%) create mode 100644 features/functional/channels/negative_delete_channel_invalid_endpoint.feature create mode 100644 features/functional/channels/negative_delete_channel_invalid_id.feature rename features/functional/{ => channels}/negative_get_channels_by_id.feature (98%) rename features/functional/{ => channels}/negative_get_channels_invalid_type.feature (99%) rename features/functional/{ => channels}/negative_post_channels.feature (99%) rename features/functional/{ => channels}/negative_post_channels_invalid.feature (98%) rename features/functional/{ => channels}/negative_post_channels_required.feature (98%) rename features/functional/{ => channels}/negative_post_channels_twitter.feature (99%) rename features/functional/{ => channels}/negative_put_channels.feature (99%) rename features/functional/{ => channels}/negative_put_channels_invalid.feature (98%) rename features/functional/{ => channels}/negative_put_channels_required.feature (99%) rename features/functional/{ => channels}/negative_put_channels_twitter.feature (99%) rename features/functional/{ => channels}/post_channel.feature (99%) rename features/functional/{ => channels}/put_channels.feature (99%) rename features/functional/{ => notifications}/negative_post_notification.feature (99%) rename features/functional/{ => notifications}/negative_post_notification_empty_parameters.feature (99%) rename features/functional/{template => templates}/delete_template_invalid_id.feature (98%) rename features/functional/{template => templates}/get_templates_invalid_id.feature (98%) rename features/functional/{template => templates}/put_template_with_param.feature (99%) rename features/functional/{template => templates}/put_templates.feature (98%) rename features/functional/{template => templates}/template_id_has_been_deleted.feature (98%) diff --git a/features/functional/get_channels_params_name.feature b/features/functional/channels/get_channels_params_name.feature similarity index 99% rename from features/functional/get_channels_params_name.feature rename to features/functional/channels/get_channels_params_name.feature index 10cf40b..84397b7 100644 --- a/features/functional/get_channels_params_name.feature +++ b/features/functional/channels/get_channels_params_name.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Functional get for channels with params name Background: diff --git a/features/functional/get_channels_params_type_EMAIL.feature b/features/functional/channels/get_channels_params_type_EMAIL.feature similarity index 98% rename from features/functional/get_channels_params_type_EMAIL.feature rename to features/functional/channels/get_channels_params_type_EMAIL.feature index f097059..a48c205 100644 --- a/features/functional/get_channels_params_type_EMAIL.feature +++ b/features/functional/channels/get_channels_params_type_EMAIL.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Functional get for channels with params type for EMAIL Background: diff --git a/features/functional/get_channels_params_type_SLACK.feature b/features/functional/channels/get_channels_params_type_SLACK.feature similarity index 98% rename from features/functional/get_channels_params_type_SLACK.feature rename to features/functional/channels/get_channels_params_type_SLACK.feature index 5ca454d..2c01828 100644 --- a/features/functional/get_channels_params_type_SLACK.feature +++ b/features/functional/channels/get_channels_params_type_SLACK.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Functional get for channels with params type for SLACK Background: diff --git a/features/functional/get_channels_params_type_TWITTER.feature b/features/functional/channels/get_channels_params_type_TWITTER.feature similarity index 98% rename from features/functional/get_channels_params_type_TWITTER.feature rename to features/functional/channels/get_channels_params_type_TWITTER.feature index 71cd783..ed269a1 100644 --- a/features/functional/get_channels_params_type_TWITTER.feature +++ b/features/functional/channels/get_channels_params_type_TWITTER.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Functional get for channels with params type for TWITTER Background: diff --git a/features/functional/get_channels_params_type_WEB_HOOK.feature b/features/functional/channels/get_channels_params_type_WEB_HOOK.feature similarity index 98% rename from features/functional/get_channels_params_type_WEB_HOOK.feature rename to features/functional/channels/get_channels_params_type_WEB_HOOK.feature index 552ed69..138fb6c 100644 --- a/features/functional/get_channels_params_type_WEB_HOOK.feature +++ b/features/functional/channels/get_channels_params_type_WEB_HOOK.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Functional get for channels with params type for WEB_HOOKS Background: 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..77c0099 --- /dev/null +++ b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature @@ -0,0 +1,44 @@ +@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' + + + 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 '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 | + | chanel | + | chanels | + | channel | + | CHANNELS | + | channelll | + | | + | chanel24!@#$@!# | + 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..2079111 --- /dev/null +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -0,0 +1,38 @@ +@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 '400' status code + And the response body contains excluding 'timestamp': + """ + { + "timestamp": 1507390985776, + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels/" +} + """ + Examples: + | Id | + | abc | + | !@$ | + | SDDF | + | 070./ | + | 4*]@!# | + | AMct | + | 510@ | + | 510. | + | 510.1 | + | 510.a | + | 51#$ | + | 610.M | + | . | + | 1170 | + | | + + + diff --git a/features/functional/negative_get_channels_by_id.feature b/features/functional/channels/negative_get_channels_by_id.feature similarity index 98% rename from features/functional/negative_get_channels_by_id.feature rename to features/functional/channels/negative_get_channels_by_id.feature index 62a9bf3..a3fb4e4 100644 --- a/features/functional/negative_get_channels_by_id.feature +++ b/features/functional/channels/negative_get_channels_by_id.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a get request by id Scenario Outline: Can't find a channel by id with invalid params diff --git a/features/functional/negative_get_channels_invalid_type.feature b/features/functional/channels/negative_get_channels_invalid_type.feature similarity index 99% rename from features/functional/negative_get_channels_invalid_type.feature rename to features/functional/channels/negative_get_channels_invalid_type.feature index f89462d..5e845c4 100644 --- a/features/functional/negative_get_channels_invalid_type.feature +++ b/features/functional/channels/negative_get_channels_invalid_type.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative request get channels with invalid type Background: diff --git a/features/functional/negative_post_channels.feature b/features/functional/channels/negative_post_channels.feature similarity index 99% rename from features/functional/negative_post_channels.feature rename to features/functional/channels/negative_post_channels.feature index bff2f8a..058da99 100644 --- a/features/functional/negative_post_channels.feature +++ b/features/functional/channels/negative_post_channels.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a post request @delete_channel Scenario Outline: Create a new channel for WebHook, Email and Twitter with invalid params diff --git a/features/functional/negative_post_channels_invalid.feature b/features/functional/channels/negative_post_channels_invalid.feature similarity index 98% rename from features/functional/negative_post_channels_invalid.feature rename to features/functional/channels/negative_post_channels_invalid.feature index 500d321..9cfdb74 100644 --- a/features/functional/negative_post_channels_invalid.feature +++ b/features/functional/channels/negative_post_channels_invalid.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a post request @delete_channel Scenario Outline: Create a new channel with invalid or empty params diff --git a/features/functional/negative_post_channels_required.feature b/features/functional/channels/negative_post_channels_required.feature similarity index 98% rename from features/functional/negative_post_channels_required.feature rename to features/functional/channels/negative_post_channels_required.feature index dc4e753..067bb92 100644 --- a/features/functional/negative_post_channels_required.feature +++ b/features/functional/channels/negative_post_channels_required.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a post request @delete_channel Scenario Outline: Create a new channel without required params diff --git a/features/functional/negative_post_channels_twitter.feature b/features/functional/channels/negative_post_channels_twitter.feature similarity index 99% rename from features/functional/negative_post_channels_twitter.feature rename to features/functional/channels/negative_post_channels_twitter.feature index a72b098..048875b 100644 --- a/features/functional/negative_post_channels_twitter.feature +++ b/features/functional/channels/negative_post_channels_twitter.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negativo responses after making a post request @delete_channel Scenario Outline: Create a new channel for Twitter with invalid params diff --git a/features/functional/negative_put_channels.feature b/features/functional/channels/negative_put_channels.feature similarity index 99% rename from features/functional/negative_put_channels.feature rename to features/functional/channels/negative_put_channels.feature index 29ea587..bb8df86 100644 --- a/features/functional/negative_put_channels.feature +++ b/features/functional/channels/negative_put_channels.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a put request Background: Given I create a 'channel' with status code '200' and body as: diff --git a/features/functional/negative_put_channels_invalid.feature b/features/functional/channels/negative_put_channels_invalid.feature similarity index 98% rename from features/functional/negative_put_channels_invalid.feature rename to features/functional/channels/negative_put_channels_invalid.feature index ec2490d..9359fa4 100644 --- a/features/functional/negative_put_channels_invalid.feature +++ b/features/functional/channels/negative_put_channels_invalid.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a put request Background: Given I create a 'channel' with status code '200' and body as: diff --git a/features/functional/negative_put_channels_required.feature b/features/functional/channels/negative_put_channels_required.feature similarity index 99% rename from features/functional/negative_put_channels_required.feature rename to features/functional/channels/negative_put_channels_required.feature index e4c6a4c..575a515 100644 --- a/features/functional/negative_put_channels_required.feature +++ b/features/functional/channels/negative_put_channels_required.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a post request Background: Given I create a 'channel' with status code '200' and body as: diff --git a/features/functional/negative_put_channels_twitter.feature b/features/functional/channels/negative_put_channels_twitter.feature similarity index 99% rename from features/functional/negative_put_channels_twitter.feature rename to features/functional/channels/negative_put_channels_twitter.feature index 711bff8..3a38983 100644 --- a/features/functional/negative_put_channels_twitter.feature +++ b/features/functional/channels/negative_put_channels_twitter.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Negative responses after making a put request Background: Given I create a 'channel' with status code '200' and body as: diff --git a/features/functional/post_channel.feature b/features/functional/channels/post_channel.feature similarity index 99% rename from features/functional/post_channel.feature rename to features/functional/channels/post_channel.feature index 37796ae..114621b 100644 --- a/features/functional/post_channel.feature +++ b/features/functional/channels/post_channel.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Post request for channels endpoint @delete_channel Scenario Outline: Create a new channel for WebHook, Email and Twitter diff --git a/features/functional/put_channels.feature b/features/functional/channels/put_channels.feature similarity index 99% rename from features/functional/put_channels.feature rename to features/functional/channels/put_channels.feature index 62621f4..35ed6ac 100644 --- a/features/functional/put_channels.feature +++ b/features/functional/channels/put_channels.feature @@ -1,4 +1,4 @@ -@functional +@all @functional Feature: Puts request for channels endpoint Background: diff --git a/features/functional/negative_post_notification.feature b/features/functional/notifications/negative_post_notification.feature similarity index 99% rename from features/functional/negative_post_notification.feature rename to features/functional/notifications/negative_post_notification.feature index da979e1..56fa2fb 100644 --- a/features/functional/negative_post_notification.feature +++ b/features/functional/notifications/negative_post_notification.feature @@ -1,3 +1,4 @@ +@all @functional Feature: Negative responses after making a post request Background: Create a Channel diff --git a/features/functional/negative_post_notification_empty_parameters.feature b/features/functional/notifications/negative_post_notification_empty_parameters.feature similarity index 99% rename from features/functional/negative_post_notification_empty_parameters.feature rename to features/functional/notifications/negative_post_notification_empty_parameters.feature index 83c92c7..518886d 100644 --- a/features/functional/negative_post_notification_empty_parameters.feature +++ b/features/functional/notifications/negative_post_notification_empty_parameters.feature @@ -1,3 +1,4 @@ +@all @functional Feature: Negative responses after making a post request with empty parameters. Background: Create a Channel diff --git a/features/functional/template/delete_template_invalid_id.feature b/features/functional/templates/delete_template_invalid_id.feature similarity index 98% rename from features/functional/template/delete_template_invalid_id.feature rename to features/functional/templates/delete_template_invalid_id.feature index d8e34d9..5173450 100644 --- a/features/functional/template/delete_template_invalid_id.feature +++ b/features/functional/templates/delete_template_invalid_id.feature @@ -1,3 +1,4 @@ +@all @functional Feature: Functional get for templates with ID Background: create a new template diff --git a/features/functional/template/get_templates_invalid_id.feature b/features/functional/templates/get_templates_invalid_id.feature similarity index 98% rename from features/functional/template/get_templates_invalid_id.feature rename to features/functional/templates/get_templates_invalid_id.feature index 3e63926..0c83fa7 100644 --- a/features/functional/template/get_templates_invalid_id.feature +++ b/features/functional/templates/get_templates_invalid_id.feature @@ -1,3 +1,4 @@ +@functional @all Feature: Functional get for templates with ID Background: create a new template diff --git a/features/functional/template/put_template_with_param.feature b/features/functional/templates/put_template_with_param.feature similarity index 99% rename from features/functional/template/put_template_with_param.feature rename to features/functional/templates/put_template_with_param.feature index 9ac837e..f897a86 100644 --- a/features/functional/template/put_template_with_param.feature +++ b/features/functional/templates/put_template_with_param.feature @@ -1,3 +1,4 @@ +@functional @all Feature: Functional put for notification with several name param Background: create a new template diff --git a/features/functional/template/put_templates.feature b/features/functional/templates/put_templates.feature similarity index 98% rename from features/functional/template/put_templates.feature rename to features/functional/templates/put_templates.feature index 932cfec..da58074 100644 --- a/features/functional/template/put_templates.feature +++ b/features/functional/templates/put_templates.feature @@ -1,3 +1,4 @@ +@functional @all Feature: Functional post for templates with ID diff --git a/features/functional/template/template_id_has_been_deleted.feature b/features/functional/templates/template_id_has_been_deleted.feature similarity index 98% rename from features/functional/template/template_id_has_been_deleted.feature rename to features/functional/templates/template_id_has_been_deleted.feature index 607aa2b..ba0dc82 100644 --- a/features/functional/template/template_id_has_been_deleted.feature +++ b/features/functional/templates/template_id_has_been_deleted.feature @@ -1,3 +1,4 @@ +@functional @all Feature: Functional get for templates with ID Background: create a new template diff --git a/features/smoke/channels_templates.feature b/features/smoke/channels_templates.feature index d4d819b..48c91b5 100644 --- a/features/smoke/channels_templates.feature +++ b/features/smoke/channels_templates.feature @@ -1,4 +1,4 @@ -@smoke +@smoke @all Feature: Channels and Templates Scenario Outline: Get all diff --git a/features/smoke/specific_channel.feature b/features/smoke/specific_channel.feature index 640dbab..f9f0205 100644 --- a/features/smoke/specific_channel.feature +++ b/features/smoke/specific_channel.feature @@ -1,4 +1,4 @@ -@smoke +@smoke @all Feature: Specific Channels Background: Create a Channel diff --git a/features/smoke/specific_notification.feature b/features/smoke/specific_notification.feature index 15906c8..d0d382c 100644 --- a/features/smoke/specific_notification.feature +++ b/features/smoke/specific_notification.feature @@ -1,4 +1,4 @@ -@smoke +@smoke @all Feature: Specific Notification Background: Create a notification diff --git a/features/smoke/specific_template.feature b/features/smoke/specific_template.feature index 3fdfeef..b5e7cd2 100644 --- a/features/smoke/specific_template.feature +++ b/features/smoke/specific_template.feature @@ -1,4 +1,4 @@ -@smoke +@smoke @all Feature: Specific Template Background: Create a Template diff --git a/features/support/env.yml b/features/support/env.yml index 0adbdf7..b335891 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,9 @@ app: - host: + host: http://10.31.2.91 port: - rootPath: - maxWaitTime: + rootPath: /api + maxWaitTime: 15 + database: connection: From 598d0e00471f10ff162bd6c4b711234d80030d1f Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Sat, 7 Oct 2017 16:38:07 +0000 Subject: [PATCH 49/85] adding tags --- features/crud/delete_channel.feature | 2 +- features/crud/delete_template.feature | 2 +- features/crud/get_channels.feature | 2 +- features/crud/get_notification.feature | 2 +- features/crud/get_template.feature | 2 +- features/crud/get_templates.feature | 2 +- features/crud/post_channel.feature | 2 +- features/crud/post_notifications.feature | 2 +- features/crud/post_resend_notification.feature | 2 +- features/crud/post_template.feature | 2 +- features/crud/put_channel.feature | 2 +- features/crud/put_template.feature | 2 +- features/support/env.yml | 6 +++--- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/features/crud/delete_channel.feature b/features/crud/delete_channel.feature index de830cd..626089b 100644 --- a/features/crud/delete_channel.feature +++ b/features/crud/delete_channel.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: CRUD for channels Background: diff --git a/features/crud/delete_template.feature b/features/crud/delete_template.feature index 37bd97f..775f012 100644 --- a/features/crud/delete_template.feature +++ b/features/crud/delete_template.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: delete template Background: diff --git a/features/crud/get_channels.feature b/features/crud/get_channels.feature index ceae948..e918432 100644 --- a/features/crud/get_channels.feature +++ b/features/crud/get_channels.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: CRUD for channels Background: diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index a45d003..428bb5a 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: GET request for notification endpoint Background: Send a notification diff --git a/features/crud/get_template.feature b/features/crud/get_template.feature index 77aa92d..ed9aef1 100644 --- a/features/crud/get_template.feature +++ b/features/crud/get_template.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: get specific template Background: diff --git a/features/crud/get_templates.feature b/features/crud/get_templates.feature index 0654555..b177c65 100644 --- a/features/crud/get_templates.feature +++ b/features/crud/get_templates.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: get templates Scenario: Get all templates diff --git a/features/crud/post_channel.feature b/features/crud/post_channel.feature index a637578..6a6173f 100644 --- a/features/crud/post_channel.feature +++ b/features/crud/post_channel.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: Post request for channels endpoint @delete_channel Scenario: Create a new channel diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index 12618a2..b7f6f39 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: POST request for notification endpoint Background: Create a Channel diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature index 1d73d55..02e4a11 100644 --- a/features/crud/post_resend_notification.feature +++ b/features/crud/post_resend_notification.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: CRUD resend notification Background: send a notification diff --git a/features/crud/post_template.feature b/features/crud/post_template.feature index fd6dd8a..d656eea 100644 --- a/features/crud/post_template.feature +++ b/features/crud/post_template.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: template Scenario: create a new template diff --git a/features/crud/put_channel.feature b/features/crud/put_channel.feature index b1a6c39..ffc591c 100644 --- a/features/crud/put_channel.feature +++ b/features/crud/put_channel.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: CRUD for channels Background: diff --git a/features/crud/put_template.feature b/features/crud/put_template.feature index 637ea8c..81a217b 100644 --- a/features/crud/put_template.feature +++ b/features/crud/put_template.feature @@ -1,4 +1,4 @@ -@crud +@all @crud Feature: template Background: diff --git a/features/support/env.yml b/features/support/env.yml index b335891..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: http://10.31.2.91 + host: port: - rootPath: /api - maxWaitTime: 15 + rootPath: + maxWaitTime: database: From a0a7f8867b9565d66a055a2ee22a462b324a78fc Mon Sep 17 00:00:00 2001 From: yuryver Date: Sat, 7 Oct 2017 15:15:58 -0400 Subject: [PATCH 50/85] corrections functional testing for templates --- ...egative_delete_template_invalid_id.feature | 38 ++++++ .../negative_get_templates_invalid_id.feature | 39 ++++++ .../negative_put_template_with_param.feature | 125 ++++++++++++++++++ .../negative_put_templates_invalid_id.feature | 45 +++++++ .../template_has_been_deleted.feature | 43 ++++++ .../template_with_front_zeros.feature | 65 +++++++++ .../support/utils/templates/template.json | 7 + 7 files changed, 362 insertions(+) create mode 100644 features/functional/templates/negative_delete_template_invalid_id.feature create mode 100644 features/functional/templates/negative_get_templates_invalid_id.feature create mode 100644 features/functional/templates/negative_put_template_with_param.feature create mode 100644 features/functional/templates/negative_put_templates_invalid_id.feature create mode 100644 features/functional/templates/template_has_been_deleted.feature create mode 100644 features/functional/templates/template_with_front_zeros.feature create mode 100644 features/support/utils/templates/template.json 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_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_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/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/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 From a3aea3d3feb9846cc83db35a2d8b4cd44f7365d3 Mon Sep 17 00:00:00 2001 From: yuryver Date: Sat, 7 Oct 2017 17:33:42 -0400 Subject: [PATCH 51/85] delete duplicates --- .../delete_template_invalid_id.feature | 31 ----- .../get_templates_invalid_id.feature | 32 ------ .../templates/put_template_with_param.feature | 106 ------------------ .../templates/put_templates.feature | 39 ------- .../template_id_has_been_deleted.feature | 43 ------- 5 files changed, 251 deletions(-) delete mode 100644 features/functional/templates/delete_template_invalid_id.feature delete mode 100644 features/functional/templates/get_templates_invalid_id.feature delete mode 100644 features/functional/templates/put_template_with_param.feature delete mode 100644 features/functional/templates/put_templates.feature delete mode 100644 features/functional/templates/template_id_has_been_deleted.feature diff --git a/features/functional/templates/delete_template_invalid_id.feature b/features/functional/templates/delete_template_invalid_id.feature deleted file mode 100644 index 5173450..0000000 --- a/features/functional/templates/delete_template_invalid_id.feature +++ /dev/null @@ -1,31 +0,0 @@ -@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' - - @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 | - | 000$id | 200 | Send an id with zeros by front | - | 0 | 404 | Send an id 0 | diff --git a/features/functional/templates/get_templates_invalid_id.feature b/features/functional/templates/get_templates_invalid_id.feature deleted file mode 100644 index 0c83fa7..0000000 --- a/features/functional/templates/get_templates_invalid_id.feature +++ /dev/null @@ -1,32 +0,0 @@ -@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' - - @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 | - | 000$id | 200 | Send an id with zeros by front | - | 0 | 404 | Send an id 0 | - diff --git a/features/functional/templates/put_template_with_param.feature b/features/functional/templates/put_template_with_param.feature deleted file mode 100644 index f897a86..0000000 --- a/features/functional/templates/put_template_with_param.feature +++ /dev/null @@ -1,106 +0,0 @@ -@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' - - @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 - - @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 \ No newline at end of file diff --git a/features/functional/templates/put_templates.feature b/features/functional/templates/put_templates.feature deleted file mode 100644 index da58074..0000000 --- a/features/functional/templates/put_templates.feature +++ /dev/null @@ -1,39 +0,0 @@ -@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' - - @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 | - | 000$id | 200 | Send an id with zeros by front | - | 0 | 404 | Send an id 0 | diff --git a/features/functional/templates/template_id_has_been_deleted.feature b/features/functional/templates/template_id_has_been_deleted.feature deleted file mode 100644 index ba0dc82..0000000 --- a/features/functional/templates/template_id_has_been_deleted.feature +++ /dev/null @@ -1,43 +0,0 @@ -@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 From c51c6b08bcaa11180f87136b59d656745c9cb6dd Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Sat, 7 Oct 2017 17:40:36 -0400 Subject: [PATCH 52/85] Code Fix- CRUD Notificatcion --- features/crud/get_notification.feature | 15 ++-- features/crud/post_notifications.feature | 17 +++-- .../post_notification_for_SLACK.feature | 72 +++++++++++++++++++ .../post_notification_for_TWITTER.feature | 47 ++++++++++++ .../post_notification_for_WEB_HOOK.feature | 44 ++++++++++++ features/step_definitions/common/steps.rb | 7 ++ .../support/utils/templates/notification.json | 3 +- ....json => notification_status_history.json} | 0 8 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 features/functional/notifications/post_notification_for_SLACK.feature create mode 100644 features/functional/notifications/post_notification_for_TWITTER.feature create mode 100644 features/functional/notifications/post_notification_for_WEB_HOOK.feature rename features/support/utils/templates/{notificationStatusHistory.json => notification_status_history.json} (100%) diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 428bb5a..f3da71c 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -30,8 +30,15 @@ Feature: GET request for notification endpoint @delete_channel Scenario: Get notification by id - Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' - - - + 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/post_notifications.feature b/features/crud/post_notifications.feature index b7f6f39..46e8880 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -20,24 +20,27 @@ Feature: POST request for notification endpoint When I set the body with id: """ { - "channelId": $id, - "priority": "", - "recipients": [], + "channelId": $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 | "#general","main" | Test2 | A testing message from notifier2 | 200 | + | 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/functional/notifications/post_notification_for_SLACK.feature b/features/functional/notifications/post_notification_for_SLACK.feature new file mode 100644 index 0000000..c00553f --- /dev/null +++ b/features/functional/notifications/post_notification_for_SLACK.feature @@ -0,0 +1,72 @@ +@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 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": $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 | + + @delete_channel + Scenario Outline: Send a new notification without subject + Given I make a 'POST' request to '/notifications' endpoint + When I set the body with id: + """ + { + "channelId": $id, + "priority": "", + "recipients": [""], + "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 | content | status_code | + | HIGH | #general | A testing message from notifier 1 | 200 | + | NORMAL | #main | A testing message from notifier 2 | 200 | \ No newline at end of file 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..169485e --- /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": $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..45b1594 --- /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": $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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 406fc1d..74c3969 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,10 +1,13 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method + p EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) + p @response + p @response.code end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| @@ -38,6 +41,10 @@ end Then(/^I build the response for "([^"]*)" with$/) do |template, json| + p "Json Recuperado" + p @body + p "Json Response" + p @response.body @builded_hash = ResponseManager.build_response(template, @body, json, @response.body) end diff --git a/features/support/utils/templates/notification.json b/features/support/utils/templates/notification.json index 397f0a5..ac66993 100644 --- a/features/support/utils/templates/notification.json +++ b/features/support/utils/templates/notification.json @@ -3,7 +3,8 @@ "channelId": "integer", "priority": "string", "status": "string", - "recipients": [], + "recipients": ["string"], + "subject": "string", "attachments": "boolean", "content": "string", "templateId": "boolean" diff --git a/features/support/utils/templates/notificationStatusHistory.json b/features/support/utils/templates/notification_status_history.json similarity index 100% rename from features/support/utils/templates/notificationStatusHistory.json rename to features/support/utils/templates/notification_status_history.json From ed4827325e5892e894055fab74ae60ba314df02c Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Sat, 7 Oct 2017 21:45:05 +0000 Subject: [PATCH 53/85] adding negatives --- ...negative_delete_channel_invalid_id.feature | 42 ++++++------- .../get_templates_params_name.feature | 62 +++++++++++++++++++ ...ive_get_templates_invalid_endpoint.feature | 40 ++++++++++++ 3 files changed, 122 insertions(+), 22 deletions(-) create mode 100644 features/functional/templates/get_templates_params_name.feature create mode 100644 features/functional/templates/negative_get_templates_invalid_endpoint.feature diff --git a/features/functional/channels/negative_delete_channel_invalid_id.feature b/features/functional/channels/negative_delete_channel_invalid_id.feature index 2079111..098c9c7 100644 --- a/features/functional/channels/negative_delete_channel_invalid_id.feature +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -4,35 +4,33 @@ 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 '400' status code - And the response body contains excluding 'timestamp': + Then I expect a '' status code + And excluding 'timestamp' and 'message' the response body contains: """ { - "timestamp": 1507390985776, - "status": 400, - "error": "Bad Request", + "status": , + "error": "", "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", - "message": "Bad Request", "path": "/channels/" } """ Examples: - | Id | - | abc | - | !@$ | - | SDDF | - | 070./ | - | 4*]@!# | - | AMct | - | 510@ | - | 510. | - | 510.1 | - | 510.a | - | 51#$ | - | 610.M | - | . | - | 1170 | - | | + | Id | status_code | error | + | abc | 400 | Bad Request | + | !@$ | 400 | Bad Request | + | SDDF | 400 | Bad Request | + | 070./ | 400 | Bad Request | + | 4*]@!# | 400 | Bad Request | + | AMct | 400 | Bad Request | + | 510@ | 400 | Bad Request | + | 510. | 404 | Not found | + | 510.1 | 404 | Not found | + | 510.a | 404 | Not found | + | 51#$ | 404 | Not found | + | 610.M | 404 | Not found | + | . | 400 | Bad Request | + | 1170 | 404 | Not found | + | | 405 | Method Not Allowed | 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..6327b51 --- /dev/null +++ b/features/functional/templates/get_templates_params_name.feature @@ -0,0 +1,62 @@ +@all @functional +Feature: get templates with params name + + Scenario: 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' + + + + 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 + """ + { + "description": null + } + """ + And The response body is the same as builded + + + 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": "Nueva Alerta. Severidad: [${Severity}]", + "description": null + } + """ + And The response body is the same as builded + + @delete_channel + 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": "Nueva Alerta. Severidad: [${Severity}]", + "description": null + } + """ + And The response body is the same as builded 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..3af0852 --- /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' + + + 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!@#$@!| From 83fa01677b8f345bc63c0f2c05da9b4453ea95ca Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Sat, 7 Oct 2017 22:16:04 +0000 Subject: [PATCH 54/85] adding negative features --- .../get_templates_params_name.feature | 14 ++++++------ ...ive_get_templates_invalid_endpoint.feature | 2 +- .../templates/negative_post_templates.feature | 22 +++++++++++++++++++ .../templates/post_template.feature | 20 +++++++++++++++++ 4 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 features/functional/templates/negative_post_templates.feature create mode 100644 features/functional/templates/post_template.feature diff --git a/features/functional/templates/get_templates_params_name.feature b/features/functional/templates/get_templates_params_name.feature index 6327b51..e554d91 100644 --- a/features/functional/templates/get_templates_params_name.feature +++ b/features/functional/templates/get_templates_params_name.feature @@ -1,7 +1,7 @@ @all @functional Feature: get templates with params name - Scenario: create a new template + Background: : create a new template Given I make a 'POST' request to '/templates' endpoint When I set the body as: """ @@ -14,8 +14,7 @@ Feature: get templates with params name 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 | @@ -24,12 +23,13 @@ Feature: get templates with params name 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 | @@ -39,13 +39,13 @@ Feature: get templates with params name And I build the response for "templates" with """ { - "subjectTemplate": "Nueva Alerta. Severidad: [${Severity}]", + "subjectTemplate": null, "description": null } """ And The response body is the same as builded - @delete_channel + @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 | @@ -55,7 +55,7 @@ Feature: get templates with params name And I build the response for "templates" with """ { - "subjectTemplate": "Nueva Alerta. Severidad: [${Severity}]", + "subjectTemplate": null, "description": null } """ diff --git a/features/functional/templates/negative_get_templates_invalid_endpoint.feature b/features/functional/templates/negative_get_templates_invalid_endpoint.feature index 3af0852..d7b2f1d 100644 --- a/features/functional/templates/negative_get_templates_invalid_endpoint.feature +++ b/features/functional/templates/negative_get_templates_invalid_endpoint.feature @@ -14,7 +14,7 @@ Feature: get templates with invalid 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 diff --git a/features/functional/templates/negative_post_templates.feature b/features/functional/templates/negative_post_templates.feature new file mode 100644 index 0000000..caf3f5e --- /dev/null +++ b/features/functional/templates/negative_post_templates.feature @@ -0,0 +1,22 @@ +Feature: created template + + Scenario Outline: create a new template with invalid name params + Given I make a 'POST' request to '/templates' endpoint + When I set the body as: + """ + { + "name": "", + "subjectTemplate": template1, + "contentTemplate": "This is a new complete template.", + "description": template + } + """ + + + Examples: + |name| + | | + | longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg | + | sho | + | #"$"#$#%gfht7 …-56 | + | . | \ No newline at end of file diff --git a/features/functional/templates/post_template.feature b/features/functional/templates/post_template.feature new file mode 100644 index 0000000..0d4598b --- /dev/null +++ b/features/functional/templates/post_template.feature @@ -0,0 +1,20 @@ +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": template1, + "contentTemplate": "This is a new complete template.", + "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 From af6154b8544717b59228a09869fa06b957ef4605 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Sat, 7 Oct 2017 19:03:10 -0400 Subject: [PATCH 55/85] Adding Scenario Notifications for Slack --- .../post_notification_for_SLACK.feature | 30 +++++++++---------- features/support/env.yml | 6 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/features/functional/notifications/post_notification_for_SLACK.feature b/features/functional/notifications/post_notification_for_SLACK.feature index c00553f..8d10fa3 100644 --- a/features/functional/notifications/post_notification_for_SLACK.feature +++ b/features/functional/notifications/post_notification_for_SLACK.feature @@ -15,15 +15,13 @@ Feature: Functional post for Notification for SLACK And I save the 'id' of 'channels' @delete_channel - Scenario Outline: Send a new notification with the two different priorities + 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": $id, - "priority": "", - "recipients": [""], - "subject": "", + "channelId": $id, + "recipients": [""], "content": "" } """ @@ -33,25 +31,26 @@ Feature: Functional post for Notification for SLACK And I build the response for "notification" with """ { + "subject": null, "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 | + | recipients | content | status_code | + | #general | A testing message from notifier 1 | 200 | @delete_channel - Scenario Outline: Send a new notification without subject + 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": $id, - "priority": "", - "recipients": [""], + "channelId": $id, + "priority": "", + "recipients": [""], + "subject": "", "content": "" } """ @@ -67,6 +66,7 @@ Feature: Functional post for Notification for SLACK """ Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' Examples: - | priority | recipients | content | status_code | - | HIGH | #general | A testing message from notifier 1 | 200 | - | NORMAL | #main | A testing message from notifier 2 | 200 | \ No newline at end of file + | 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/support/env.yml b/features/support/env.yml index 46aadf9..5035db6 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: + host: http://10.31.2.91/ port: - rootPath: - maxWaitTime: + rootPath: api/ + maxWaitTime: 15 database: From ec3643317fe3cb91ebf37b766f29c8b32d3261d0 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Sat, 7 Oct 2017 19:56:23 -0400 Subject: [PATCH 56/85] Adding Scenario Notifications for Slack - Multple recipients --- .../post_notification_for_SLACK.feature | 60 ++++++++++++++----- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/features/functional/notifications/post_notification_for_SLACK.feature b/features/functional/notifications/post_notification_for_SLACK.feature index 8d10fa3..e183b84 100644 --- a/features/functional/notifications/post_notification_for_SLACK.feature +++ b/features/functional/notifications/post_notification_for_SLACK.feature @@ -28,14 +28,6 @@ Feature: Functional post for Notification for SLACK 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 - """ - { - "subject": null, - "attachments": null, - "templateId": null - } - """ Then I make a 'GET' request to '/notifications/$id' until the field 'notification' at 'status' is 'DELIVERED' Examples: | recipients | content | status_code | @@ -57,16 +49,54 @@ Feature: Functional post for Notification for SLACK 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 | + @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 | + | "$id" | #general | A testing message from notifier 1 | + | $id.5 | #general | A testing message from notifier 2 | + | $id.435 | #general | A testing message from notifier 3 | + | $id.645 | #general | A testing message from notifier 4 | + | $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": $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 | From 8ff8f932c4e808035f98daf40bd2f9270d85eecc Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Sat, 7 Oct 2017 20:10:38 -0400 Subject: [PATCH 57/85] Adding Negative Test-Notification-Send notification without parameters --- ...post_notification_empty_parameters.feature | 4 +- ...ost_notification_withoutParameters.feature | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 features/functional/notifications/negative_post_notification_withoutParameters.feature diff --git a/features/functional/notifications/negative_post_notification_empty_parameters.feature b/features/functional/notifications/negative_post_notification_empty_parameters.feature index 518886d..1f8c7b6 100644 --- a/features/functional/notifications/negative_post_notification_empty_parameters.feature +++ b/features/functional/notifications/negative_post_notification_empty_parameters.feature @@ -20,7 +20,7 @@ Feature: Negative responses after making a post request with empty parameters. When I set the body with id: """ { - "channelId": , + "channelId": "", "priority": "", "recipients": [""], "subject": "", @@ -48,7 +48,7 @@ Feature: Negative responses after making a post request with empty parameters. """ Examples: | channelId | priority | recipients | subject | content | field | code | - | "" | NORMAL | #general | Test | A testing message from notifier | channelId | channelId.required | + | | NORMAL | #general | Test | A testing message from notifier | channelId | channelId.required | | $id | NORMAL | | Test | A testing message from notifier | recipients | recipients.valid | | $id | NORMAL | #general | | A testing message from notifier | subject | subject.required | | $id | NORMAL | #general | Test | | content | content.required | diff --git a/features/functional/notifications/negative_post_notification_withoutParameters.feature b/features/functional/notifications/negative_post_notification_withoutParameters.feature new file mode 100644 index 0000000..e394af0 --- /dev/null +++ b/features/functional/notifications/negative_post_notification_withoutParameters.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': + """the "id channel" + { + "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": $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": $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 From 92bc107ea4e1ffa7f4df71af9b23e84d6ca82f05 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Sat, 7 Oct 2017 20:47:06 -0400 Subject: [PATCH 58/85] Adding Negative Test-Notification-Send notification invalid endpoint --- ...post_notification_invalid_endpoint.feature | 46 +++++++++++++++++++ ...t_notification_without_parameters.feature} | 0 2 files changed, 46 insertions(+) create mode 100644 features/functional/notifications/negative_post_notification_invalid_endpoint.feature rename features/functional/notifications/{negative_post_notification_withoutParameters.feature => negative_post_notification_without_parameters.feature} (100%) 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..2564483 --- /dev/null +++ b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature @@ -0,0 +1,46 @@ +@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": $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_withoutParameters.feature b/features/functional/notifications/negative_post_notification_without_parameters.feature similarity index 100% rename from features/functional/notifications/negative_post_notification_withoutParameters.feature rename to features/functional/notifications/negative_post_notification_without_parameters.feature From e26ba7d88187b106d67a975acf19bc1051eb75de Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 10:21:21 -0400 Subject: [PATCH 59/85] Adding Negative Test -Notification-Send with nonexistent priority --- ...post_notification_invalid_endpoint.feature | 15 ++-- ...egative_post_notification_priority.feature | 82 +++++++++++++++++++ ...st_notification_without_parameters.feature | 2 +- features/step_definitions/common/steps.rb | 7 -- features/support/env.yml | 6 +- 5 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 features/functional/notifications/negative_post_notification_priority.feature diff --git a/features/functional/notifications/negative_post_notification_invalid_endpoint.feature b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature index 2564483..5df64ed 100644 --- a/features/functional/notifications/negative_post_notification_invalid_endpoint.feature +++ b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature @@ -37,10 +37,11 @@ Feature: Post Notification with invalid endpoint } """ 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 | + | 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_priority.feature b/features/functional/notifications/negative_post_notification_priority.feature new file mode 100644 index 0000000..5e8b9aa --- /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": $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": $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 index e394af0..956cd02 100644 --- a/features/functional/notifications/negative_post_notification_without_parameters.feature +++ b/features/functional/notifications/negative_post_notification_without_parameters.feature @@ -30,7 +30,7 @@ Feature: Negative responses after making a post request And I execute the request to the endpoint Then I expect a '400' status code And the response body contains excluding 'timestamp': - """the "id channel" + """ { "status": 400, "error": "Bad Request", diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 74c3969..406fc1d 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,13 +1,10 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) @request.method = method - p EnpointBuilder.builder(endpoint) end When(/^I execute the request to the endpoint$/) do @response = RequestManager.execute_request(@request) - p @response - p @response.code end Then(/^I expect a '(\d+)' status code$/) do |status_code_expected| @@ -41,10 +38,6 @@ end Then(/^I build the response for "([^"]*)" with$/) do |template, json| - p "Json Recuperado" - p @body - p "Json Response" - p @response.body @builded_hash = ResponseManager.build_response(template, @body, json, @response.body) end diff --git a/features/support/env.yml b/features/support/env.yml index 5035db6..5647893 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: http://10.31.2.91/ + host: port: - rootPath: api/ - maxWaitTime: 15 + rootPath: + maxWaitTime: database: From 062dcefec3c16f7d069353c6d1f66df5470c81ff Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 14:38:55 -0400 Subject: [PATCH 60/85] Adding Negative Test -Get Notification --- .../negative_get_notification.feature | 76 +++++++++++++++++++ features/support/env.yml | 4 +- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 features/functional/notifications/negative_get_notification.feature diff --git a/features/functional/notifications/negative_get_notification.feature b/features/functional/notifications/negative_get_notification.feature new file mode 100644 index 0000000..d34b764 --- /dev/null +++ b/features/functional/notifications/negative_get_notification.feature @@ -0,0 +1,76 @@ +@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": $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 | diff --git a/features/support/env.yml b/features/support/env.yml index 5647893..3440394 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,8 +1,8 @@ app: - host: + host: port: rootPath: - maxWaitTime: + maxWaitTime: database: From d6ad6fb081710d4b45c9e018492fc528e4cfa07f Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 18:47:55 +0000 Subject: [PATCH 61/85] improve negatives features --- ...negative_delete_channel_invalid_id.feature | 16 +++-- .../get_templates_params_name.feature | 62 ------------------- .../templates/negative_post_templates.feature | 22 ------- features/step_definitions/common/steps.rb | 10 +++ features/support/utils/request_manager.rb | 9 +++ features/support/utils/response_manager.rb | 4 +- .../support/utils/templates/templates.json | 9 +++ 7 files changed, 40 insertions(+), 92 deletions(-) delete mode 100644 features/functional/templates/get_templates_params_name.feature delete mode 100644 features/functional/templates/negative_post_templates.feature create mode 100644 features/support/utils/templates/templates.json diff --git a/features/functional/channels/negative_delete_channel_invalid_id.feature b/features/functional/channels/negative_delete_channel_invalid_id.feature index 098c9c7..73c84e4 100644 --- a/features/functional/channels/negative_delete_channel_invalid_id.feature +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -6,14 +6,16 @@ Feature: Negative responses after making a delete request by invalid id When I execute the request to the endpoint Then I expect a '' status code And excluding 'timestamp' and 'message' the response body contains: + """ { "status": , "error": "", "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", "path": "/channels/" -} + } """ + Examples: | Id | status_code | error | | abc | 400 | Bad Request | @@ -21,16 +23,18 @@ Feature: Negative responses after making a delete request by invalid id | SDDF | 400 | Bad Request | | 070./ | 400 | Bad Request | | 4*]@!# | 400 | Bad Request | + | *]@!# | 400 | Bad Request | | AMct | 400 | Bad Request | | 510@ | 400 | Bad Request | - | 510. | 404 | Not found | - | 510.1 | 404 | Not found | - | 510.a | 404 | Not found | - | 51#$ | 404 | Not found | - | 610.M | 404 | Not found | + | 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 | | 1170 | 404 | Not found | | | 405 | Method Not Allowed | + | .345 | 400 | Bad Request | diff --git a/features/functional/templates/get_templates_params_name.feature b/features/functional/templates/get_templates_params_name.feature deleted file mode 100644 index e554d91..0000000 --- a/features/functional/templates/get_templates_params_name.feature +++ /dev/null @@ -1,62 +0,0 @@ -@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 diff --git a/features/functional/templates/negative_post_templates.feature b/features/functional/templates/negative_post_templates.feature deleted file mode 100644 index caf3f5e..0000000 --- a/features/functional/templates/negative_post_templates.feature +++ /dev/null @@ -1,22 +0,0 @@ -Feature: created template - - Scenario Outline: create a new template with invalid name params - Given I make a 'POST' request to '/templates' endpoint - When I set the body as: - """ - { - "name": "", - "subjectTemplate": template1, - "contentTemplate": "This is a new complete template.", - "description": template - } - """ - - - Examples: - |name| - | | - | longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg | - | sho | - | #"$"#$#%gfht7 …-56 | - | . | \ No newline at end of file diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 406fc1d..34e1551 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -97,3 +97,13 @@ puts json puts @response.body end + +Then(/^excluding '([^"]*)' and '(.*)' and '(.*)' the response body contains:$/) do |exclude1, exclude2, exclude3, json| + expect(json).to be_json_eql(@response.body).excluding(exclude1, exclude2, exclude3) + puts json + puts @response.body +end + +Then (/^I generate '(\w+)' letter (\d+) times and save$/) do |letter, n| + $word = RequestManager.generator(letter,3) +end diff --git a/features/support/utils/request_manager.rb b/features/support/utils/request_manager.rb index 1ae6fc6..93fd6eb 100644 --- a/features/support/utils/request_manager.rb +++ b/features/support/utils/request_manager.rb @@ -8,4 +8,13 @@ def self.execute_request(api_request) rescue RestClient::ExceptionWithResponse => error error.response end + + def self.generator l,n + cad = "" + n.times do + cad += l.to_s + end + return cad + end end + diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 93add4f..619e50b 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -30,8 +30,8 @@ def self.build_response(filename, request, expected, response) end def self.build_with_hash(request, expected, response) - replace_in_hash(request) - replace_in_hash(expected) + puts replace_in_hash(request) + puts replace_in_hash(expected) replace_in_hash(diff_hash(response)) end 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 From 2a060d53ad3a63bf5a4251016e722801199e4818 Mon Sep 17 00:00:00 2001 From: yuryver Date: Mon, 9 Oct 2017 14:50:29 -0400 Subject: [PATCH 62/85] complete notification with template and dynamic builder body --- features/crud/get_notification.feature | 2 +- features/crud/post_notifications.feature | 2 +- .../crud/post_resend_notification.feature | 4 +- .../negative_post_notification.feature | 2 +- ...post_notification_empty_parameters.feature | 4 +- .../post_notification_with_template.feature | 51 +++++++++++++++++++ features/smoke/specific_notification.feature | 2 +- features/step_definitions/common/steps.rb | 5 +- features/support/utils/body_builder.rb | 9 ++++ 9 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 features/functional/notifications/post_notification_with_template.feature create mode 100644 features/support/utils/body_builder.rb diff --git a/features/crud/get_notification.feature b/features/crud/get_notification.feature index 428bb5a..3666516 100644 --- a/features/crud/get_notification.feature +++ b/features/crud/get_notification.feature @@ -17,7 +17,7 @@ Feature: GET request for notification endpoint When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#general"], "subject": "Test API", diff --git a/features/crud/post_notifications.feature b/features/crud/post_notifications.feature index b7f6f39..eeb7667 100644 --- a/features/crud/post_notifications.feature +++ b/features/crud/post_notifications.feature @@ -20,7 +20,7 @@ Feature: POST request for notification endpoint When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [], "subject": "", diff --git a/features/crud/post_resend_notification.feature b/features/crud/post_resend_notification.feature index 02e4a11..69b76ae 100644 --- a/features/crud/post_resend_notification.feature +++ b/features/crud/post_resend_notification.feature @@ -6,7 +6,7 @@ Feature: CRUD resend notification When I set the body as: """ { - "name": "Chanel test resend AS:", + "name": "Channel test resend AS:", "type": "SLACK", "configuration": { "url": "https://hooks.slack.com/services/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" @@ -20,7 +20,7 @@ Feature: CRUD resend notification When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#general"], "subject": "test API", diff --git a/features/functional/notifications/negative_post_notification.feature b/features/functional/notifications/negative_post_notification.feature index 56fa2fb..99ab7e4 100644 --- a/features/functional/notifications/negative_post_notification.feature +++ b/features/functional/notifications/negative_post_notification.feature @@ -55,7 +55,7 @@ Feature: Negative responses after making a post request When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "subject": "", "content": "" diff --git a/features/functional/notifications/negative_post_notification_empty_parameters.feature b/features/functional/notifications/negative_post_notification_empty_parameters.feature index 518886d..393b6ab 100644 --- a/features/functional/notifications/negative_post_notification_empty_parameters.feature +++ b/features/functional/notifications/negative_post_notification_empty_parameters.feature @@ -59,7 +59,7 @@ Feature: Negative responses after making a post request with empty parameters. When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", @@ -100,7 +100,7 @@ Feature: Negative responses after making a post request with empty parameters. When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", 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..2a3ea0f --- /dev/null +++ b/features/functional/notifications/post_notification_with_template.feature @@ -0,0 +1,51 @@ +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/smoke/specific_notification.feature b/features/smoke/specific_notification.feature index d0d382c..bdfe17e 100644 --- a/features/smoke/specific_notification.feature +++ b/features/smoke/specific_notification.feature @@ -17,7 +17,7 @@ Feature: Specific Notification When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#general"], "subject": "Test API", diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 406fc1d..39d81aa 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -26,9 +26,8 @@ end When(/^I set the body with id:$/) do |body| - body = body.gsub('$id', $id_hash[$identifier_name].to_s) - @body = body - @request.body = body + @body = BodyBuilder.builder(body) + @request.body = BodyBuilder.builder(body) end When(/^I save the '(\w+)' of '(channels|notification|templates)'$/) do |name, type| 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 From 55754c1aeceabe9d6c8e0c3c8bef51931f32016e Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 19:10:11 +0000 Subject: [PATCH 63/85] adding negatives templates features --- .../get_templates_params_name.feature | 30 +++++++++++++++++++ features/support/env.yml | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 features/functional/templates/get_templates_params_name.feature 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..ca70f55 --- /dev/null +++ b/features/functional/templates/get_templates_params_name.feature @@ -0,0 +1,30 @@ +@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 diff --git a/features/support/env.yml b/features/support/env.yml index 5647893..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -2,7 +2,7 @@ app: host: port: rootPath: - maxWaitTime: + maxWaitTime: database: From 253968e23298d94a05acb97ac28ea1cf8b00e50c Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 20:12:22 +0000 Subject: [PATCH 64/85] adding negative features with params --- .../get_templates_params_name.feature | 34 +++++++++++++ .../negative_get_templates_params.feature | 48 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 features/functional/templates/negative_get_templates_params.feature diff --git a/features/functional/templates/get_templates_params_name.feature b/features/functional/templates/get_templates_params_name.feature index ca70f55..22e1dc8 100644 --- a/features/functional/templates/get_templates_params_name.feature +++ b/features/functional/templates/get_templates_params_name.feature @@ -28,3 +28,37 @@ Feature: get templates with params name } """ 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_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 From d03e922b257130d4ed7f80ee16a30d5fa4b58abc Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 21:33:34 +0000 Subject: [PATCH 65/85] adding generator of words --- ...tive_post_templates_invalid_params.feature | 37 +++++++++++++++++++ features/step_definitions/common/steps.rb | 12 ++++-- features/support/env.yml | 2 +- features/support/utils/request_manager.rb | 4 +- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 features/functional/templates/negative_post_templates_invalid_params.feature diff --git a/features/functional/templates/negative_post_templates_invalid_params.feature b/features/functional/templates/negative_post_templates_invalid_params.feature new file mode 100644 index 0000000..93cfcd0 --- /dev/null +++ b/features/functional/templates/negative_post_templates_invalid_params.feature @@ -0,0 +1,37 @@ +Feature: created template + + Scenario: create a new template with invalid or empty params + Given I make a 'POST' request to '/templates' endpoint + When I generate 'a' letter 257 times and save + 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" + } + """ + + + diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 55bce16..0c9afc8 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -25,9 +25,11 @@ @request.body = body end -When(/^I set the body with id:$/) do |body| + +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| @@ -52,8 +54,8 @@ Then(/^I expect (?:PUT|POST) response is the same as GET response$/) do expect(@response.body).to eq @stored_response - puts @response.body - puts @stored_response + @response.body + @stored_response end Then(/^I expect that the GET response it is empty$/) do @@ -89,6 +91,7 @@ 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| @@ -104,5 +107,6 @@ end Then (/^I generate '(\w+)' letter (\d+) times and save$/) do |letter, n| - $word = RequestManager.generator(letter,3) + $id_hash.store('name', RequestManager.generator(letter,n)) + puts $id_hash end diff --git a/features/support/env.yml b/features/support/env.yml index 46aadf9..3440394 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,5 +1,5 @@ app: - host: + host: port: rootPath: maxWaitTime: diff --git a/features/support/utils/request_manager.rb b/features/support/utils/request_manager.rb index 93fd6eb..181f702 100644 --- a/features/support/utils/request_manager.rb +++ b/features/support/utils/request_manager.rb @@ -11,10 +11,10 @@ def self.execute_request(api_request) def self.generator l,n cad = "" - n.times do + n.to_i.times do cad += l.to_s end - return cad + cad end end From 97688e677efe6d7dfc5a5859761e240114766e44 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 17:36:45 -0400 Subject: [PATCH 66/85] Adding Negative Test - Resend Notifications --- .../negative_post_resend_notification.feature | 72 +++++++++++++++++++ .../post_resend_notification.feature | 72 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 features/functional/notifications/negative_post_resend_notification.feature create mode 100644 features/functional/notifications/post_resend_notification.feature 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..46c45ba --- /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": $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_resend_notification.feature b/features/functional/notifications/post_resend_notification.feature new file mode 100644 index 0000000..fc29cd2 --- /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": $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 'DELIVERED' + + @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 | From 4dc942c3073c6eade1b5edc7ac1d780234682c31 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 21:43:55 +0000 Subject: [PATCH 67/85] adding post templates --- Rakefile | 6 ------ features/step_definitions/common/steps.rb | 6 ++---- features/support/env.yml | 2 +- features/support/hooks/hooks.rb | 1 - features/support/utils/enpoint_builder.rb | 2 +- features/support/utils/request_manager.rb | 7 +++---- features/support/utils/response_manager.rb | 4 ++-- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Rakefile b/Rakefile index 9ea1273..8677a84 100644 --- a/Rakefile +++ b/Rakefile @@ -3,15 +3,11 @@ 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| @@ -23,5 +19,3 @@ task :rhtml, [:tag] do |t, args| end ReportBuilder.build_report end - - diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 0c9afc8..c0379ac 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -25,7 +25,6 @@ @request.body = body end - When(/^I set the body with (?:\w+):$/) do |body| @body = BodyBuilder.builder(body) @request.body = BodyBuilder.builder(body) @@ -91,7 +90,6 @@ 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| @@ -106,7 +104,7 @@ puts @response.body end -Then (/^I generate '(\w+)' letter (\d+) times and save$/) do |letter, n| - $id_hash.store('name', RequestManager.generator(letter,n)) +Then(/^I generate '(\w+)' letter (\d+) times and save$/) do |letter, n| + $id_hash.store('name', RequestManager.generator(letter, n)) puts $id_hash end diff --git a/features/support/env.yml b/features/support/env.yml index 3440394..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,5 +1,5 @@ app: - host: + host: port: rootPath: maxWaitTime: diff --git a/features/support/hooks/hooks.rb b/features/support/hooks/hooks.rb index 35c26f1..25dae27 100644 --- a/features/support/hooks/hooks.rb +++ b/features/support/hooks/hooks.rb @@ -13,4 +13,3 @@ request.method = 'DELETE' RequestManager.execute_request(request) end - diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/enpoint_builder.rb index e0acd8b..755142e 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/enpoint_builder.rb @@ -1,7 +1,7 @@ # This module build endpoint with id and params module EnpointBuilder def self.builder(enpoint) - enpoint.gsub("$id", $id_hash[$identifier_name].to_s) + enpoint.gsub("$id", $id_hash[$identifier_name].to_s) end def self.param(endpoint, param) diff --git a/features/support/utils/request_manager.rb b/features/support/utils/request_manager.rb index 181f702..53d4e1c 100644 --- a/features/support/utils/request_manager.rb +++ b/features/support/utils/request_manager.rb @@ -9,12 +9,11 @@ def self.execute_request(api_request) error.response end - def self.generator l,n - cad = "" + def self.generator(l, n) + cad = '' n.to_i.times do cad += l.to_s end - cad + cad end end - diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 619e50b..8d55e62 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -18,7 +18,7 @@ def self.replace_in_hash(hash) end def self.diff_hash(hash) - hash.delete_if { |key| !(@copy[key].eql? @template[key]) } + hash.delete_if {|key| !(@copy[key].eql? @template[key])} end def self.build_response(filename, request, expected, response) @@ -51,7 +51,7 @@ def self.replace_in_array(array) end def self.diff_array(hash) - hash.delete_if { |key| !(@copy[0][key].eql? @template[0][key]) } + hash.delete_if {|key| !(@copy[0][key].eql? @template[0][key])} end def self.build_error_response(filename, expected, response) From 45eda1714e3faf6a234959a6a71caf5fcea4b139 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 18:05:19 -0400 Subject: [PATCH 68/85] Changing a state --- .../functional/notifications/post_resend_notification.feature | 2 +- features/support/env.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/functional/notifications/post_resend_notification.feature b/features/functional/notifications/post_resend_notification.feature index fc29cd2..1474fed 100644 --- a/features/functional/notifications/post_resend_notification.feature +++ b/features/functional/notifications/post_resend_notification.feature @@ -43,7 +43,7 @@ Feature: Functional post for Resend Notification } """ 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' + 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. diff --git a/features/support/env.yml b/features/support/env.yml index 3440394..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -1,5 +1,5 @@ app: - host: + host: port: rootPath: maxWaitTime: From 0dd7843f73620becbab89a8ae3ae4fa551763c40 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 22:12:01 +0000 Subject: [PATCH 69/85] fix a feature and adding tags --- .../post_notification_with_template.feature | 1 + .../negative_post_templates_invalid_params.feature | 1 + features/functional/templates/post_template.feature | 10 ++++++---- features/support/env.yml | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/features/functional/notifications/post_notification_with_template.feature b/features/functional/notifications/post_notification_with_template.feature index 2a3ea0f..12287c6 100644 --- a/features/functional/notifications/post_notification_with_template.feature +++ b/features/functional/notifications/post_notification_with_template.feature @@ -1,3 +1,4 @@ +@all @functional Feature: Negative post notification with templates diff --git a/features/functional/templates/negative_post_templates_invalid_params.feature b/features/functional/templates/negative_post_templates_invalid_params.feature index 93cfcd0..670cdb5 100644 --- a/features/functional/templates/negative_post_templates_invalid_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_params.feature @@ -1,3 +1,4 @@ +@all @functional Feature: created template Scenario: create a new template with invalid or empty params diff --git a/features/functional/templates/post_template.feature b/features/functional/templates/post_template.feature index 0d4598b..6f1cda9 100644 --- a/features/functional/templates/post_template.feature +++ b/features/functional/templates/post_template.feature @@ -1,14 +1,15 @@ +@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": template1, - "contentTemplate": "This is a new complete template.", - "description": template + "subjectTemplate": "template", + "contentTemplate": "This is a new complete template by at-04.", + "description": "template" } """ When I execute the request to the endpoint @@ -18,3 +19,4 @@ Feature: created template 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/support/env.yml b/features/support/env.yml index 46aadf9..5647893 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -2,7 +2,7 @@ app: host: port: rootPath: - maxWaitTime: + maxWaitTime: database: From aaddb9ef10f24e84dc3a350591accd321ae45fef Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 18:38:50 -0400 Subject: [PATCH 70/85] Updating --- .../negative_get_notification.feature | 2 +- ..._post_notification_empty_parameters.feature | 10 +++++----- ..._post_notification_invalid_endpoint.feature | 4 ++-- ...negative_post_notification_priority.feature | 4 ++-- ...ost_notification_without_parameters.feature | 10 +++++----- .../negative_post_resend_notification.feature | 2 +- .../post_notification_for_SLACK.feature | 18 +++++++++--------- .../post_notification_for_TWITTER.feature | 2 +- .../post_notification_for_WEB_HOOK.feature | 2 +- .../post_resend_notification.feature | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/features/functional/notifications/negative_get_notification.feature b/features/functional/notifications/negative_get_notification.feature index d34b764..9fb0a80 100644 --- a/features/functional/notifications/negative_get_notification.feature +++ b/features/functional/notifications/negative_get_notification.feature @@ -17,7 +17,7 @@ Feature: GET request for notification endpoint When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#general"], "subject": "Test API", diff --git a/features/functional/notifications/negative_post_notification_empty_parameters.feature b/features/functional/notifications/negative_post_notification_empty_parameters.feature index 03961e9..8ce61c7 100644 --- a/features/functional/notifications/negative_post_notification_empty_parameters.feature +++ b/features/functional/notifications/negative_post_notification_empty_parameters.feature @@ -47,11 +47,11 @@ Feature: Negative responses after making a post request with empty parameters. } """ Examples: - | channelId | priority | recipients | subject | content | field | code | - | | NORMAL | #general | Test | A testing message from notifier | channelId | channelId.required | - | $id | NORMAL | | Test | A testing message from notifier | recipients | recipients.valid | - | $id | NORMAL | #general | | A testing message from notifier | subject | subject.required | - | $id | NORMAL | #general | Test | | content | content.required | + | 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 diff --git a/features/functional/notifications/negative_post_notification_invalid_endpoint.feature b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature index 5df64ed..572a89b 100644 --- a/features/functional/notifications/negative_post_notification_invalid_endpoint.feature +++ b/features/functional/notifications/negative_post_notification_invalid_endpoint.feature @@ -16,11 +16,11 @@ Feature: Post Notification with invalid endpoint @delete_channel Scenario Outline: Can't post a notification with invalid endpoint - Given I make a 'POST' request to '' endpoint + Given I make a 'POST' request to '/' endpoint When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "recipients": [], "content": "" } diff --git a/features/functional/notifications/negative_post_notification_priority.feature b/features/functional/notifications/negative_post_notification_priority.feature index 5e8b9aa..3be6e73 100644 --- a/features/functional/notifications/negative_post_notification_priority.feature +++ b/features/functional/notifications/negative_post_notification_priority.feature @@ -20,7 +20,7 @@ Feature: Negative responses after making a post request When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", @@ -54,7 +54,7 @@ Feature: Negative responses after making a post request When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", diff --git a/features/functional/notifications/negative_post_notification_without_parameters.feature b/features/functional/notifications/negative_post_notification_without_parameters.feature index 956cd02..7702bbb 100644 --- a/features/functional/notifications/negative_post_notification_without_parameters.feature +++ b/features/functional/notifications/negative_post_notification_without_parameters.feature @@ -43,8 +43,8 @@ Feature: Negative responses after making a post request } """ 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": $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": $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 + | 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 index 46c45ba..cc2543a 100644 --- a/features/functional/notifications/negative_post_resend_notification.feature +++ b/features/functional/notifications/negative_post_resend_notification.feature @@ -17,7 +17,7 @@ Feature: Negative responses after making a post request When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#recipient_one","#recipient_two"], "subject": "Test API", diff --git a/features/functional/notifications/post_notification_for_SLACK.feature b/features/functional/notifications/post_notification_for_SLACK.feature index e183b84..06af0b7 100644 --- a/features/functional/notifications/post_notification_for_SLACK.feature +++ b/features/functional/notifications/post_notification_for_SLACK.feature @@ -20,7 +20,7 @@ Feature: Functional post for Notification for SLACK When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "recipients": [""], "content": "" } @@ -39,7 +39,7 @@ Feature: Functional post for Notification for SLACK When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", @@ -71,12 +71,12 @@ Feature: Functional post for Notification for SLACK 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 | - | "$id" | #general | A testing message from notifier 1 | - | $id.5 | #general | A testing message from notifier 2 | - | $id.435 | #general | A testing message from notifier 3 | - | $id.645 | #general | A testing message from notifier 4 | - | $id.999 | #general | A testing message from notifier 5 | + | 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 @@ -84,7 +84,7 @@ Feature: Functional post for Notification for SLACK When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "recipients": [], "content": "" } diff --git a/features/functional/notifications/post_notification_for_TWITTER.feature b/features/functional/notifications/post_notification_for_TWITTER.feature index 169485e..7d0763a 100644 --- a/features/functional/notifications/post_notification_for_TWITTER.feature +++ b/features/functional/notifications/post_notification_for_TWITTER.feature @@ -23,7 +23,7 @@ Feature: Functional post for Notification for TWITTER When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", diff --git a/features/functional/notifications/post_notification_for_WEB_HOOK.feature b/features/functional/notifications/post_notification_for_WEB_HOOK.feature index 45b1594..805626b 100644 --- a/features/functional/notifications/post_notification_for_WEB_HOOK.feature +++ b/features/functional/notifications/post_notification_for_WEB_HOOK.feature @@ -20,7 +20,7 @@ Feature: Functional post for Notification for WEB-HOOK When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "", "recipients": [""], "subject": "", diff --git a/features/functional/notifications/post_resend_notification.feature b/features/functional/notifications/post_resend_notification.feature index 1474fed..dd1dfb3 100644 --- a/features/functional/notifications/post_resend_notification.feature +++ b/features/functional/notifications/post_resend_notification.feature @@ -17,7 +17,7 @@ Feature: Functional post for Resend Notification When I set the body with id: """ { - "channelId": $id, + "channelId": $channels_id, "priority": "HIGH", "recipients": ["#recipient_one","#recipient_two"], "subject": "Test API", From e5a0a7da7a62c6aa47af29a131af6300755e8f08 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Mon, 9 Oct 2017 22:47:04 +0000 Subject: [PATCH 71/85] adding negative post feature --- ...tive_post_templates_invalid_params.feature | 44 +++++++++++++++++++ features/support/env.yml | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/features/functional/templates/negative_post_templates_invalid_params.feature b/features/functional/templates/negative_post_templates_invalid_params.feature index 670cdb5..94cdbc1 100644 --- a/features/functional/templates/negative_post_templates_invalid_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_params.feature @@ -35,4 +35,48 @@ Feature: created template """ + @delete_channel + 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 'channels' + 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 | + | tr | + | "sd" | + | "" | + | $ | + | 1 | + | #$%&/( | + | . | + | 1234 | + | "%&(()=&$#!" | + diff --git a/features/support/env.yml b/features/support/env.yml index 5647893..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -2,7 +2,7 @@ app: host: port: rootPath: - maxWaitTime: + maxWaitTime: database: From a0b6f65f2ceb84dd2bf7ff22874aee83cffb6e3a Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 00:48:40 +0000 Subject: [PATCH 72/85] adding templates features --- ...e_post_templates_invalid_name_params.feature} | 16 ++++++++++------ features/step_definitions/common/steps.rb | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) rename features/functional/templates/{negative_post_templates_invalid_params.feature => negative_post_templates_invalid_name_params.feature} (92%) diff --git a/features/functional/templates/negative_post_templates_invalid_params.feature b/features/functional/templates/negative_post_templates_invalid_name_params.feature similarity index 92% rename from features/functional/templates/negative_post_templates_invalid_params.feature rename to features/functional/templates/negative_post_templates_invalid_name_params.feature index 94cdbc1..2c0eed7 100644 --- a/features/functional/templates/negative_post_templates_invalid_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_name_params.feature @@ -1,7 +1,7 @@ @all @functional Feature: created template - Scenario: create a new template with invalid or empty params + 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 And I set the body with name: @@ -51,7 +51,6 @@ Feature: created template Then I expect a '400' status code And I save the 'id' of 'channels' And excluding 'timestamp' and 'exception' the response body contains: - """ { "status": 400, @@ -65,18 +64,23 @@ Feature: created template ], "message": "Bad Request", "path": "/templates" -} + } """ + Examples: | Name | | tr | | "sd" | - | "" | + | " " | | $ | | 1 | | #$%&/( | | . | - | 1234 | - | "%&(()=&$#!" | + | | + | a | + + + + diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c0379ac..27ef5bd 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -104,7 +104,7 @@ puts @response.body end -Then(/^I generate '(\w+)' letter (\d+) times and save$/) do |letter, n| - $id_hash.store('name', RequestManager.generator(letter, n)) +Then(/^I generate '(\w+)' letter (\d+) times and save for '(\w+)' field$/) do |letter, n, field| + $id_hash.store('field', RequestManager.generator(letter, n)) puts $id_hash end From c524596986085973ecf7d275afb1645c938ab389 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 00:50:27 +0000 Subject: [PATCH 73/85] adding negative features --- ...es_invalid_content_template_params.feature | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 features/functional/templates/negative_post_templates_invalid_content_template_params.feature 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..fbac3b4 --- /dev/null +++ b/features/functional/templates/negative_post_templates_invalid_content_template_params.feature @@ -0,0 +1,85 @@ +@all @functional +Feature: created template + + 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": "name", + "code": "Size", + "defaultMessage": "size must be between 4 and 256" + } + ], + "message": "Bad Request", + "path": "/templates" + } + """ + + + @delete_channel + 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 'channels' + 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 | + | tr | + | "sd" | + | " " | + | $ | + | 1 | + | #$%&/( | + | . | + | | + | a | + + + + + From 8719f007ee2a720c3a9143058a2762bfaf8f8746 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Mon, 9 Oct 2017 21:35:23 -0400 Subject: [PATCH 74/85] Adding Negative Test -Get Notification with invalid id and invalid parameters --- .../negative_get_notification.feature | 99 +++++++++++++++++++ .../negative_post_notification.feature | 91 ----------------- ...st_notification_invalid_parameters.feature | 50 ++++++++++ 3 files changed, 149 insertions(+), 91 deletions(-) delete mode 100644 features/functional/notifications/negative_post_notification.feature create mode 100644 features/functional/notifications/negative_post_notification_invalid_parameters.feature diff --git a/features/functional/notifications/negative_get_notification.feature b/features/functional/notifications/negative_get_notification.feature index 9fb0a80..4045adb 100644 --- a/features/functional/notifications/negative_get_notification.feature +++ b/features/functional/notifications/negative_get_notification.feature @@ -74,3 +74,102 @@ Feature: GET request for notification endpoint | 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_post_notification.feature b/features/functional/notifications/negative_post_notification.feature deleted file mode 100644 index 99ab7e4..0000000 --- a/features/functional/notifications/negative_post_notification.feature +++ /dev/null @@ -1,91 +0,0 @@ -@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 the "id channel" parameter - Given I make a 'POST' request to '/notifications' endpoint - When I set the body as: - """ - { - "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 - } - ], - "message": "Bad Request", - "path": "/notifications" - } - """ - Examples: - | priority | recipients | subject | content | - | NORMAL | "#general","main" | Test1 | A testing message from notifier | - - @delete_channel - Scenario Outline: Send a new notification without the "recipients" parameter - Given I make a 'POST' request to '/notifications' endpoint - When I set the body with id: - """ - { - "channelId": $channels_id, - "priority": "", - "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": "NotEmpty", - "defaultMessage": "may not be empty" - }, - { - "field": "recipients", - "code": "recipients.valid", - "defaultMessage": null - } - ], - "message": "Bad Request", - "path": "/notifications" - } - """ - Examples: - | priority | subject | content | - | NORMAL | Test1 | A testing message from notifier | - 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 | + From adc00fbf874bc4b080ec375d1e2c70e454638e77 Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 10 Oct 2017 10:29:00 -0400 Subject: [PATCH 75/85] Refactoring response manager and features --- features/crud/get_all_channels.feature | 30 +++ features/crud/get_templates.feature | 24 ++- .../get_channels_params_type_EMAIL.feature | 2 +- .../get_channels_params_type_SLACK.feature | 2 +- .../get_channels_params_type_TWITTER.feature | 2 +- .../get_channels_params_type_WEB_HOOK.feature | 4 +- ...ve_delete_channel_invalid_endpoint.feature | 3 +- ...negative_delete_channel_invalid_id.feature | 15 +- .../negative_get_channels_by_id.feature | 16 +- ...negative_get_channels_invalid_type.feature | 2 +- .../channels/negative_post_channels.feature | 163 ++++++++++++-- .../negative_post_channels_twitter.feature | 198 ++++++++++++++++-- .../functional/channels/post_channel.feature | 18 +- features/step_definitions/common/steps.rb | 6 + features/support/env.yml | 2 +- features/support/utils/response_manager.rb | 63 +++--- 16 files changed, 445 insertions(+), 105 deletions(-) create mode 100644 features/crud/get_all_channels.feature 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_templates.feature b/features/crud/get_templates.feature index b177c65..55e0fba 100644 --- a/features/crud/get_templates.feature +++ b/features/crud/get_templates.feature @@ -1,8 +1,30 @@ @all @crud Feature: get templates + # 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 expect that the GET response it is empty + 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 expect that the GET response it is empty \ No newline at end of file + And I build the response for "templates" with + """ + { + "onFail": null + } + """ + And The response body should contain the builded response diff --git a/features/functional/channels/get_channels_params_type_EMAIL.feature b/features/functional/channels/get_channels_params_type_EMAIL.feature index a48c205..2250aed 100644 --- a/features/functional/channels/get_channels_params_type_EMAIL.feature +++ b/features/functional/channels/get_channels_params_type_EMAIL.feature @@ -29,4 +29,4 @@ Feature: Functional get for channels with params type for EMAIL "onFail": null } """ - And The response body is the same as builded + 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 index 2c01828..7a2c437 100644 --- a/features/functional/channels/get_channels_params_type_SLACK.feature +++ b/features/functional/channels/get_channels_params_type_SLACK.feature @@ -28,4 +28,4 @@ Feature: Functional get for channels with params type for SLACK "onFail": null } """ - And The response body is the same as builded + 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 index ed269a1..b0ac15c 100644 --- a/features/functional/channels/get_channels_params_type_TWITTER.feature +++ b/features/functional/channels/get_channels_params_type_TWITTER.feature @@ -31,4 +31,4 @@ Feature: Functional get for channels with params type for TWITTER "onFail": null } """ - And The response body is the same as builded + 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 index 138fb6c..912af83 100644 --- a/features/functional/channels/get_channels_params_type_WEB_HOOK.feature +++ b/features/functional/channels/get_channels_params_type_WEB_HOOK.feature @@ -1,5 +1,5 @@ @all @functional -Feature: Functional get for channels with params type for WEB_HOOKS +Feature: Functional get for all channels Background: Given I make a 'POST' request to '/channels' endpoint @@ -28,4 +28,4 @@ Feature: Functional get for channels with params type for WEB_HOOKS "onFail": null } """ - And The response body is the same as builded + 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 index 77c0099..f025a64 100644 --- a/features/functional/channels/negative_delete_channel_invalid_endpoint.feature +++ b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature @@ -25,11 +25,10 @@ Feature: delete channel And the response body contains excluding 'timestamp': """ { - "timestamp": 1507389627623, "status": 404, "error": "Not Found", "message": "Not Found", - "path": "/api//$id" + "path": "/api//$id" } """ Examples: diff --git a/features/functional/channels/negative_delete_channel_invalid_id.feature b/features/functional/channels/negative_delete_channel_invalid_id.feature index 2079111..e01f2d7 100644 --- a/features/functional/channels/negative_delete_channel_invalid_id.feature +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -7,14 +7,13 @@ Feature: Negative responses after making a delete request by invalid id Then I expect a '400' status code And the response body contains excluding 'timestamp': """ - { - "timestamp": 1507390985776, - "status": 400, - "error": "Bad Request", - "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", - "message": "Bad Request", - "path": "/channels/" -} + { + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", + "message": "Bad Request", + "path": "/channels/" + } """ Examples: | Id | diff --git a/features/functional/channels/negative_get_channels_by_id.feature b/features/functional/channels/negative_get_channels_by_id.feature index a3fb4e4..443613d 100644 --- a/features/functional/channels/negative_get_channels_by_id.feature +++ b/features/functional/channels/negative_get_channels_by_id.feature @@ -16,14 +16,14 @@ Feature: Negative responses after making a get request by id } """ Examples: - | Id | - | abc | - | !@$ | - | 510@ | - | 510. | - | 510.1 | - | 510.a | - | 0510.$ | + | Id | + | abc | + | !@$ | + | 510@ | + | 510. | + | 510.1 | + | 510.a | + | 0510.$ | | 0510.!@#$@!# | Scenario: Can't Find a channel with nonexistent id diff --git a/features/functional/channels/negative_get_channels_invalid_type.feature b/features/functional/channels/negative_get_channels_invalid_type.feature index 5e845c4..bf8c874 100644 --- a/features/functional/channels/negative_get_channels_invalid_type.feature +++ b/features/functional/channels/negative_get_channels_invalid_type.feature @@ -100,6 +100,6 @@ Feature: Negative request get channels with invalid type """ """ Examples: - | Name | Case | + | Name | Case | | NoTExists | true | | NoTExists | false | diff --git a/features/functional/channels/negative_post_channels.feature b/features/functional/channels/negative_post_channels.feature index 058da99..068fea5 100644 --- a/features/functional/channels/negative_post_channels.feature +++ b/features/functional/channels/negative_post_channels.feature @@ -1,12 +1,12 @@ @all @functional Feature: Negative responses after making a post request @delete_channel - Scenario Outline: Create a new channel for WebHook, Email and Twitter with invalid params + 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": "", + "name": "AT04-Slack-or-WebHook-Demo", "type": "", "configuration": { @@ -23,26 +23,151 @@ Feature: Negative responses after making a post request "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: - | 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 } | + | 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_twitter.feature b/features/functional/channels/negative_post_channels_twitter.feature index 048875b..a8d0afe 100644 --- a/features/functional/channels/negative_post_channels_twitter.feature +++ b/features/functional/channels/negative_post_channels_twitter.feature @@ -1,5 +1,5 @@ @all @functional -Feature: Negativo responses after making a post request +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 @@ -26,25 +26,189 @@ Feature: Negativo responses after making a post request "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 | 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 } | +| 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/post_channel.feature b/features/functional/channels/post_channel.feature index 114621b..2ae0bd6 100644 --- a/features/functional/channels/post_channel.feature +++ b/features/functional/channels/post_channel.feature @@ -24,10 +24,10 @@ Feature: Post request for channels endpoint """ And The response body is the same as builded Examples: - | Name | Type | Configuration | OnFail | - | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services/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" | null | - | AT04-Email-Demo | EMAIL | "mail.from":"example@jalasoft.com", "mail.host":"127.0.0.1" | null | - | AT04-Twitter-Demo | TWITTER | "access_token": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | null | + | 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 @@ -53,8 +53,8 @@ Feature: Post request for channels endpoint """ And The response body is the same as builded Examples: - | Name | Type | Configuration | OnFail | - | AT04-Slack-Demo | SLACK | "url": "https://hooks.slack.com/services/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" | https://hooks.slack.com/services/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 | - | AT04-WebHook-Demo | WEB_HOOK | "url": "https://hooks.slack.com/services/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" | https://hooks.slack.com/services/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 | - | 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": "912661821122805760-7NTyIrDHEeoa534SduWW3TQLBUaQzLm", "consumer_key": "KHjTQXRMRMO5N87oOVS7mR8lf", "consumer_secret": "LKj4G8C9FvokkBeBTrc120qKIl2oMbwLJdUYUqqkIQJIRKlHzO", "access_token_secret": "W47sYHdMXafd9kZK77aUEmnXaOIZDuJTrWGsV8DuPJNm8" | https://hooks.slack.com/services/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 | + | 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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 406fc1d..d5e84ff 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -97,3 +97,9 @@ puts json puts @response.body 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/support/env.yml b/features/support/env.yml index 5647893..46aadf9 100644 --- a/features/support/env.yml +++ b/features/support/env.yml @@ -2,7 +2,7 @@ app: host: port: rootPath: - maxWaitTime: + maxWaitTime: database: diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 93add4f..95f04df 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -8,50 +8,36 @@ def self.parse_file(filename) @copy = @template.is_a?(Hash) ? Hash[@template] : [].replace(@template) end - def self.replace_in_hash(hash) - @template.each_key do |key| - if !(@template[key].eql? hash[key]) && (hash.key? key) - @copy[key] = hash[key] + 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_hash(hash) - hash.delete_if { |key| !(@copy[key].eql? @template[key]) } + 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) - request = JSON.parse(request) - expected = JSON.parse(expected) - response = JSON.parse(response) - @copy.is_a?(Hash) ? build_with_hash(request, expected, response) : build_with_array(request, expected, response) - end - - def self.build_with_hash(request, expected, response) - replace_in_hash(request) - replace_in_hash(expected) - replace_in_hash(diff_hash(response)) - end - - def self.build_with_array(request, expected, response) - replace_in_array(request) - replace_in_array(expected) - replace_in_array(diff_array(response[0])) - end - - def self.replace_in_array(array) - @template[0].each_key do |key| - if !(@template[0][key].eql? array[key]) && (array.key? key) - @copy[0][key] = array[key] - end + 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.diff_array(hash) - hash.delete_if { |key| !(@copy[0][key].eql? @template[0][key]) } end def self.build_error_response(filename, expected, response) @@ -61,4 +47,13 @@ def self.build_error_response(filename, expected, response) replace_in_hash(expected) replace_in_hash(diff_hash(response)) 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 From 23398e1e51af7f8aa3b5749efb18eb1619742842 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Tue, 10 Oct 2017 10:34:45 -0400 Subject: [PATCH 76/85] Adding Negative Test Notifications-Incorrect request --- ...ive_notification_incorrect_request.feature | 45 ++++++++++++++++ .../negative_post_notification.feature | 53 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 features/functional/notifications/negative_notification_incorrect_request.feature create mode 100644 features/functional/notifications/negative_post_notification.feature 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..2feb440 --- /dev/null +++ b/features/functional/notifications/negative_post_notification.feature @@ -0,0 +1,53 @@ +@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 recipient greater than 256 characters + Given I make a 'POST' request to '/notifications' endpoint + And I generate 'a' letter times and save + When I set the body with id: + """ + { + "channelId": $channels_id, + "recipients": [""], + "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": "recipients", + "code": "Size", + "defaultMessage": "size must be between 4 and 22" + } + ], + "message": "Bad Request", + "path": "/notifications" + } + """ + Examples: + | recipients | content | number_of_letters | + | $name | A testing message from notifier 1 | 256 | + | $name | A testing message from notifier 1 | 257 | + | $name | A testing message from notifier 1 | 300 | From f07f580b47ce172edf5dca5a447f5fb2fc217d43 Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 10 Oct 2017 10:42:48 -0400 Subject: [PATCH 77/85] Adding get templates crud --- features/crud/get_templates.feature | 5 ----- 1 file changed, 5 deletions(-) diff --git a/features/crud/get_templates.feature b/features/crud/get_templates.feature index 55e0fba..7ca20e8 100644 --- a/features/crud/get_templates.feature +++ b/features/crud/get_templates.feature @@ -1,11 +1,6 @@ @all @crud Feature: get templates - # 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 expect that the GET response it is empty Background: Background: Given I create a 'template' with status code '201' and body as: From c06c8ccaaf854cf11302c950b68d729b1716ae66 Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 14:57:08 +0000 Subject: [PATCH 78/85] adding negative post features --- ...es_invalid_content_template_params.feature | 85 ----------- ...post_templates_invalid_name_params.feature | 132 +++++++++++++++--- features/step_definitions/common/steps.rb | 2 +- 3 files changed, 117 insertions(+), 102 deletions(-) delete mode 100644 features/functional/templates/negative_post_templates_invalid_content_template_params.feature 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 deleted file mode 100644 index fbac3b4..0000000 --- a/features/functional/templates/negative_post_templates_invalid_content_template_params.feature +++ /dev/null @@ -1,85 +0,0 @@ -@all @functional -Feature: created template - - 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": "name", - "code": "Size", - "defaultMessage": "size must be between 4 and 256" - } - ], - "message": "Bad Request", - "path": "/templates" - } - """ - - - @delete_channel - 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 'channels' - 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 | - | tr | - | "sd" | - | " " | - | $ | - | 1 | - | #$%&/( | - | . | - | | - | a | - - - - - diff --git a/features/functional/templates/negative_post_templates_invalid_name_params.feature b/features/functional/templates/negative_post_templates_invalid_name_params.feature index 2c0eed7..282ef7b 100644 --- a/features/functional/templates/negative_post_templates_invalid_name_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_name_params.feature @@ -1,9 +1,9 @@ @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 + When I generate 'a' letter 257 times and save for 'name' field And I set the body with name: """ { @@ -35,7 +35,7 @@ Feature: created template """ - @delete_channel + @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: @@ -49,38 +49,138 @@ Feature: created template """ When I execute the request to the endpoint Then I expect a '400' status code - And I save the 'id' of 'channels' + And I save the 'id' of 'templates' And excluding 'timestamp' and 'exception' the response body contains: """ - { +{ + "timestamp": 1507646361153, "status": 400, "error": "Bad Request", - "errors": [ - { - "field": "name", - "code": "Size", - "defaultMessage": "size must be between 4 and 256" - } - ], + "exception": "org.springframework.http.converter.HttpMessageNotReadableException", "message": "Bad Request", "path": "/templates" - } +} """ Examples: | Name | | tr | - | "sd" | - | " " | | $ | - | 1 | | #$%&/( | | . | | | | 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': + + """ + { + "timestamp": 1507643158967, + "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: + """ +{ + "timestamp": 1507646423470, + "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" +} + + """ + + 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: + """ +{ + "timestamp": 1507646653193, + "status": 400, + "error": "Bad Request", + "exception": "org.springframework.web.bind.MethodArgumentNotValidException", + "errors": [ + { + "field": "name", + "code": "name.required", + "defaultMessage": null + } + ], + "message": "Bad Request", + "path": "/templates" +} + """ diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 27ef5bd..c1c27fc 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -105,6 +105,6 @@ 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)) + $id_hash.store(field, RequestManager.generator(letter, n)) puts $id_hash end From 60bcb17293111e87b0ea333ba83eab270cf0f47d Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 16:01:37 +0000 Subject: [PATCH 79/85] fix some features --- ...ve_delete_channel_invalid_endpoint.feature | 6 +- ...negative_delete_channel_invalid_id.feature | 69 ++++++++++++------- ...post_templates_invalid_name_params.feature | 7 -- features/step_definitions/common/steps.rb | 2 +- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/features/functional/channels/negative_delete_channel_invalid_endpoint.feature b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature index 77c0099..e9fe40c 100644 --- a/features/functional/channels/negative_delete_channel_invalid_endpoint.feature +++ b/features/functional/channels/negative_delete_channel_invalid_endpoint.feature @@ -21,15 +21,13 @@ Feature: 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 '200' status code - And the response body contains excluding 'timestamp': + Then I expect a '404' status code + And excluding 'timestamp' and 'path' the response body contains: """ { - "timestamp": 1507389627623, "status": 404, "error": "Not Found", "message": "Not Found", - "path": "/api//$id" } """ Examples: diff --git a/features/functional/channels/negative_delete_channel_invalid_id.feature b/features/functional/channels/negative_delete_channel_invalid_id.feature index 73c84e4..cf7b2a2 100644 --- a/features/functional/channels/negative_delete_channel_invalid_id.feature +++ b/features/functional/channels/negative_delete_channel_invalid_id.feature @@ -5,36 +5,55 @@ Feature: Negative responses after making a delete request by invalid id 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 'message' the response body contains: + And excluding 'timestamp' and 'path' the response body contains: """ - { - "status": , - "error": "", - "exception": "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException", - "path": "/channels/" - } + { + "status": 400, + "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 | - | 4*]@!# | 400 | Bad Request | - | *]@!# | 400 | Bad Request | - | AMct | 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 | - | 1170 | 404 | Not found | - | | 405 | Method Not Allowed | - | .345 | 400 | Bad Request | + | 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/templates/negative_post_templates_invalid_name_params.feature b/features/functional/templates/negative_post_templates_invalid_name_params.feature index 282ef7b..7bb750d 100644 --- a/features/functional/templates/negative_post_templates_invalid_name_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_name_params.feature @@ -53,10 +53,8 @@ Feature: created template And excluding 'timestamp' and 'exception' the response body contains: """ { - "timestamp": 1507646361153, "status": 400, "error": "Bad Request", - "exception": "org.springframework.http.converter.HttpMessageNotReadableException", "message": "Bad Request", "path": "/templates" } @@ -90,7 +88,6 @@ Feature: created template """ { - "timestamp": 1507643158967, "status": 400, "error": "Bad Request", "exception": "org.springframework.web.bind.MethodArgumentNotValidException", @@ -125,10 +122,8 @@ Feature: created template And excluding 'timestamp' and 'exception' the response body contains: """ { - "timestamp": 1507646423470, "status": 400, "error": "Bad Request", - "exception": "org.springframework.web.bind.MethodArgumentNotValidException", "errors": [ { "field": "name", @@ -168,10 +163,8 @@ Feature: created template And excluding 'timestamp' and 'exception' the response body contains: """ { - "timestamp": 1507646653193, "status": 400, "error": "Bad Request", - "exception": "org.springframework.web.bind.MethodArgumentNotValidException", "errors": [ { "field": "name", diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c1c27fc..c6734f3 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -106,5 +106,5 @@ Then(/^I generate '(\w+)' letter (\d+) times and save for '(\w+)' field$/) do |letter, n, field| $id_hash.store(field, RequestManager.generator(letter, n)) - puts $id_hash + $id_hash end From 9c7b2fe4b33f7e7b2b1abe2f8c9839569aeec19c Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 16:05:53 +0000 Subject: [PATCH 80/85] delete methods --- features/step_definitions/common/steps.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/features/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index c6734f3..6df9e96 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -98,13 +98,6 @@ puts @response.body end -Then(/^excluding '([^"]*)' and '(.*)' and '(.*)' the response body contains:$/) do |exclude1, exclude2, exclude3, json| - expect(json).to be_json_eql(@response.body).excluding(exclude1, exclude2, exclude3) - 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)) - $id_hash end From dd5104eb5bb83a7f7ef425a8b1e1790c71d6572c Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 16:30:59 +0000 Subject: [PATCH 81/85] adding negative post feature --- ...es_invalid_content_template_params.feature | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 features/functional/templates/negative_post_templates_invalid_content_template_params.feature 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..24a5667 --- /dev/null +++ b/features/functional/templates/negative_post_templates_invalid_content_template_params.feature @@ -0,0 +1,112 @@ +@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" + } + """ From 28ec183eace71060f5dd53c7729930d13208a3df Mon Sep 17 00:00:00 2001 From: CynthiaTerrazas Date: Tue, 10 Oct 2017 16:41:15 +0000 Subject: [PATCH 82/85] adding negative feature --- ...es_invalid_content_template_params.feature | 32 +++++++++++++++++++ features/step_definitions/common/steps.rb | 4 +-- ...enpoint_builder.rb => endpoint_builder.rb} | 6 ++-- features/support/utils/response_manager.rb | 4 +-- 4 files changed, 39 insertions(+), 7 deletions(-) rename features/support/utils/{enpoint_builder.rb => endpoint_builder.rb} (77%) 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 index 24a5667..322348c 100644 --- a/features/functional/templates/negative_post_templates_invalid_content_template_params.feature +++ b/features/functional/templates/negative_post_templates_invalid_content_template_params.feature @@ -110,3 +110,35 @@ Feature: created template "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/step_definitions/common/steps.rb b/features/step_definitions/common/steps.rb index 6df9e96..51d14b8 100644 --- a/features/step_definitions/common/steps.rb +++ b/features/step_definitions/common/steps.rb @@ -1,5 +1,5 @@ Given(/^I make a '(\w+)' request to '(.+)' endpoint$/) do |method, endpoint| - @request = ApiRequest.new(EnpointBuilder.builder(endpoint)) + @request = ApiRequest.new(EndpointBuilder.builder(endpoint)) @request.method = method end @@ -12,7 +12,7 @@ end And(/^I make a '(PUT|POST|GET)' request to '(.+)' with:$/) do |method, endpoint, param| - @request = ApiRequest.new(EnpointBuilder.param(endpoint, param.raw)) + @request = ApiRequest.new(EndpointBuilder.param(endpoint, param.raw)) @request.method = method end diff --git a/features/support/utils/enpoint_builder.rb b/features/support/utils/endpoint_builder.rb similarity index 77% rename from features/support/utils/enpoint_builder.rb rename to features/support/utils/endpoint_builder.rb index 755142e..ec850ab 100644 --- a/features/support/utils/enpoint_builder.rb +++ b/features/support/utils/endpoint_builder.rb @@ -1,7 +1,7 @@ # This module build endpoint with id and params -module EnpointBuilder - def self.builder(enpoint) - enpoint.gsub("$id", $id_hash[$identifier_name].to_s) +module EndpointBuilder + def self.builder(endpoint) + endpoint.gsub('$id', $id_hash[$identifier_name].to_s) end def self.param(endpoint, param) diff --git a/features/support/utils/response_manager.rb b/features/support/utils/response_manager.rb index 8d55e62..619e50b 100644 --- a/features/support/utils/response_manager.rb +++ b/features/support/utils/response_manager.rb @@ -18,7 +18,7 @@ def self.replace_in_hash(hash) end def self.diff_hash(hash) - hash.delete_if {|key| !(@copy[key].eql? @template[key])} + hash.delete_if { |key| !(@copy[key].eql? @template[key]) } end def self.build_response(filename, request, expected, response) @@ -51,7 +51,7 @@ def self.replace_in_array(array) end def self.diff_array(hash) - hash.delete_if {|key| !(@copy[0][key].eql? @template[0][key])} + hash.delete_if { |key| !(@copy[0][key].eql? @template[0][key]) } end def self.build_error_response(filename, expected, response) From e7e2caf80407cfc4f3369d9d36310d044022a3b7 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Tue, 10 Oct 2017 13:23:15 -0400 Subject: [PATCH 83/85] Adding Negative Test Notifications --- .../negative_post_notification.feature | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/features/functional/notifications/negative_post_notification.feature b/features/functional/notifications/negative_post_notification.feature index 2feb440..21bb257 100644 --- a/features/functional/notifications/negative_post_notification.feature +++ b/features/functional/notifications/negative_post_notification.feature @@ -1,5 +1,5 @@ @all @functional -Feature: Negative responses after making a post request . +Feature: Negative responses after making a post request Background: Create a Channel Given I create a 'channel' with status code '200' and body as: @@ -15,7 +15,7 @@ Feature: Negative responses after making a post request . And I save the 'id' of 'channels' @delete_channel @bug - Scenario Outline: Send a new notification with a recipient greater than 256 characters + Scenario Outline: Send a new notification with a parameter greater than 256 characters Given I make a 'POST' request to '/notifications' endpoint And I generate 'a' letter times and save When I set the body with id: @@ -23,6 +23,7 @@ Feature: Negative responses after making a post request . { "channelId": $channels_id, "recipients": [""], + "subject": "", "content": "" } """ @@ -37,9 +38,9 @@ Feature: Negative responses after making a post request . "exception": "org.springframework.web.bind.MethodArgumentNotValidException", "errors": [ { - "field": "recipients", + "field": "", "code": "Size", - "defaultMessage": "size must be between 4 and 22" + "defaultMessage": "" } ], "message": "Bad Request", @@ -47,7 +48,8 @@ Feature: Negative responses after making a post request . } """ Examples: - | recipients | content | number_of_letters | - | $name | A testing message from notifier 1 | 256 | - | $name | A testing message from notifier 1 | 257 | - | $name | A testing message from notifier 1 | 300 | + | recipients | subject | content | number_of_letters | field | default_message | + | $name | Test | A testing message from notifier 1 | 256 | recipients | size must be between 1 and 22 | + | $name | Test | A testing message from notifier 1 | 257 | recipients | size must be between 1 and 22 | + | $name | Test | A testing message from notifier 1 | 300 | recipients | size must be between 1 and 22 | + | #general | $name | A testing message from notifier 1 | 300 | subject | size must be between 0 and 255 | From 34bb9de7520979715ba75269527a02c89835b5b4 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Tue, 10 Oct 2017 13:44:19 -0400 Subject: [PATCH 84/85] Code Fix - Negative Test --- .../notifications/negative_post_notification.feature | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/features/functional/notifications/negative_post_notification.feature b/features/functional/notifications/negative_post_notification.feature index 21bb257..29c7176 100644 --- a/features/functional/notifications/negative_post_notification.feature +++ b/features/functional/notifications/negative_post_notification.feature @@ -17,7 +17,7 @@ Feature: Negative responses after making a post request @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 - And I generate 'a' letter times and save + When I generate 'a' letter times and save for 'value' field When I set the body with id: """ { @@ -49,7 +49,7 @@ Feature: Negative responses after making a post request """ Examples: | recipients | subject | content | number_of_letters | field | default_message | - | $name | Test | A testing message from notifier 1 | 256 | recipients | size must be between 1 and 22 | - | $name | Test | A testing message from notifier 1 | 257 | recipients | size must be between 1 and 22 | - | $name | Test | A testing message from notifier 1 | 300 | recipients | size must be between 1 and 22 | - | #general | $name | A testing message from notifier 1 | 300 | subject | size must be between 0 and 255 | + | $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 | From 8b5fa29fe9202b66571c364cc8d1eb5f03fdd5b5 Mon Sep 17 00:00:00 2001 From: OvidioMiranda Date: Tue, 10 Oct 2017 13:54:15 -0400 Subject: [PATCH 85/85] Fixing Feature Post Channel --- features/functional/channels/post_channel.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/functional/channels/post_channel.feature b/features/functional/channels/post_channel.feature index 2ae0bd6..4eab5ac 100644 --- a/features/functional/channels/post_channel.feature +++ b/features/functional/channels/post_channel.feature @@ -25,7 +25,7 @@ Feature: Post request for channels endpoint 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-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 |