From baf8217a1450568462432a678126187271c34245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Hurtado?= Date: Sat, 17 Aug 2019 10:26:40 +0200 Subject: [PATCH] Added append/success and append/error_unprocessable features --- .../append/error_unprocessable.feature | 45 +++++++++++++++++++ .../features/control/append/success.feature | 35 +++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/spec/test/features/control/append/error_unprocessable.feature b/spec/test/features/control/append/error_unprocessable.feature index e69de29..fdb0d15 100644 --- a/spec/test/features/control/append/error_unprocessable.feature +++ b/spec/test/features/control/append/error_unprocessable.feature @@ -0,0 +1,45 @@ +Feature: Kapow! server reject responses with semantic errors. + Kapow! server will reject to create routes when + it receives a valid json document but not conforming + with the specification. + + Scenario: Error by lack of mandatory fields. + If a request lacks of any of the mandatory fields + the server responds with an error indicating the + missing fields. + + Given I have a running Kapow! server + When I append the route: + | entrypoint | command | + | /bin/sh -c | ls -la / \| response /body | + Then I get unprocessable entity as response code + And I get "Missing Mandatory Field" as response phrase + And I get the following entity as response body: + | missing_mandatory_fields | + | "url_pattern", "method" | + + Scenario: Error by wrong route spec. + If a request contains an invalid expression in the + field url_pattern the server responds with an error. + + Given I have a running Kapow! server + When I append the route: + | method | url_pattern | entrypoint | command | + | GET | +123-- | /bin/sh -c | ls -la / \| response /body | + Then I get unprocessable entity as response code + And I get "Invalid Route Spec" as response phrase + And I get an empty response body + + Scenario: Error by wrong method value. + If a request contains an invalid value in the + field method the server responds with an error. + + Given I have a running Kapow! server + When I append the route: + | method | url_pattern | entrypoint | command | + | AVECES | +123-- | /bin/sh -c | ls -la / \| response /body | + Then I get unprocessable entity as response code + And I get "Invalid Data Type" as response phrase + And I get an empty response body + +... diff --git a/spec/test/features/control/append/success.feature b/spec/test/features/control/append/success.feature index e69de29..ab44a07 100644 --- a/spec/test/features/control/append/success.feature +++ b/spec/test/features/control/append/success.feature @@ -0,0 +1,35 @@ +Feature: Append new routes in Kapow! server. + Append routes allow users to configure the server. New + routes are added to the list of existing routes. + + Scenario: Append the first route. + A fresh server, just started or with all routes removed, + will create a new list of routes. The newly created rule + will be at index 0. + + Given I have a just started Kapow! server + When I append the route: + | method | url_pattern | entrypoint | command | + | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | + Then I get created as response code + And I get "Created" as response phrase + And I get the following entity as response body: + | method | url_pattern | entrypoint | command | index | id | + | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * | + + Scenario: Append another route. + Appending routes on a non empty list will create new routes + at the end of the list. + + Given I have a Kapow! server whith the following routes: + | method | url_pattern | entrypoint | command | + | GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | + | GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + When I append the route: + | method | url_pattern | entrypoint | command | + | GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | + Then I get created as response code + And I get "Created" as response phrase + And I get the following entity as response body: + | method | url_pattern | entrypoint | command | index | id | + | GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 2 | * |