Added features for append/error_malformed, delete/list_order, insert/error_malformed and insert/list_order. Updated append/error_unprocessable and list/success.

This commit is contained in:
Héctor Hurtado
2019-08-20 10:31:14 +02:00
parent 040fc55b39
commit 380eed57d9
7 changed files with 196 additions and 7 deletions
@@ -0,0 +1,25 @@
Feature: Kapow! server reject responses with malformed JSON bodies.
Kapow! server will reject to insert a route when
it receives a malformed json document in the
request body.
Scenario: Error because a malformed JSON document.
If a request comes with an invalid JSON document
the server will respond with a bad request error.
Given I have a running Kapow! server
When I try to insert with this JSON document:
"""
{
"method" "GET",
"url_pattern": /hello,
"entrypoint": null
"command": "echo Hello
World | response /body",
"index": 0,
"id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
}
"""
Then I get bad request as response code
And I get "Malformed JSON" as response phrase
And I get an empty response body
@@ -40,5 +40,3 @@ Feature: Kapow! server reject insert responses with semantic errors.
Then I get unprocessable entity as response code
And I get "Invalid Data Type" as response phrase
And I get an empty response body
...
@@ -0,0 +1,75 @@
Feature: Routes auto-ordering in a Kapow! server.
When inserting routes the server will mantain the
whole set of routes ordered an with consecutive indexes.
Background:
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 |
Scenario: Inserting before the first route.
When inserting before the first route the previous set
will maintain their relative order and their indexes
will be increased by one.
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 |
Then I get 200 as response code
And I get "OK" as response phrase
And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 | * |
When I request a routes listing
Then I get 200 as response code
And I get "OK" as response phrase
And I get a list with the following elements:
| method | url_pattern | entrypoint | command | Index | id |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 0 | * |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 | * |
| GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * |
Scenario: Inserting after the last routes.
When inserting after the last route the previous set
will maintain their relative order and indexes.
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 |
Then I get 200 as response code
And I get "OK" as response phrase
And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 | * |
When I request a routes listing
Then I get 200 as response code
And I get "OK" as response phrase
And I get a list with the following elements:
| method | url_pattern | entrypoint | command | Index | id |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * |
| GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 1 | * |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 2 | * |
Scenario: Inserting a midst route.
When inserting a midst route the previous route set
will maintain their relative order and the indexes
of thefollowing routes will be increased by one.
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 |
Then I get 200 as response code
And I get "OK" as response phrase
And I get the following entity as response body:
| method | url_pattern | entrypoint | command | index | id |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 | * |
When I request a routes listing
Then I get 200 as response code
And I get "OK" as response phrase
And I get a list with the following elements:
| method | url_pattern | entrypoint | command | Index | id |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 | * |
| GET | /listVarDir | /bin/sh -c | ls -la /var \| response /body | 1 | * |
| GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * |