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

This commit is contained in:
Héctor Hurtado
2019-08-20 10:36:24 +02:00
14 changed files with 221 additions and 144 deletions
@@ -8,17 +8,17 @@ Feature: Kapow! server reject responses with malformed JSON bodies.
the server will respond with a bad request error.
Given I have a running Kapow! server
When I try to append with this JSON document:
"""
{
"method" "GET",
"url_pattern": /hello,
"entrypoint": null
"command": "echo Hello
World | response /body",
"id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
}
"""
Then I get 400 as response code
And I get "Malformed JSON" as response phrase
And I get an empty response body
When I try to append with this JSON document:
"""
{
"method" "GET",
"url_pattern": /hello,
"entrypoint": null
"command": "echo Hello
World | response /body",
"id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
}
"""
Then I get 400 as response code
And I get "Malformed JSON" as response phrase
And I get an empty response body
@@ -9,11 +9,11 @@ Feature: Kapow! server reject responses with semantic errors.
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
When I append the route:
| entrypoint | command |
| /bin/sh -c | ls -la / \| response /body |
Then I get 422 as response code
And I get "Missing Mandatory Field" as response reason phrase
And I get the following entity as response body:
| missing_mandatory_fields |
| "url_pattern", "method" |
@@ -23,11 +23,11 @@ Feature: Kapow! server reject responses with semantic errors.
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
When I append the route:
| method | url_pattern | entrypoint | command |
| GET | +123-- | /bin/sh -c | ls -la / \| response /body |
Then I get 422 as response code
And I get "Invalid Route Spec" as response reason phrase
And I get an empty response body
Scenario: Error because of wrong method value.
@@ -35,9 +35,9 @@ Feature: Kapow! server reject responses with semantic errors.
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
When I append the route:
| method | url_pattern | entrypoint | command |
| AVECES | +123-- | /bin/sh -c | ls -la / \| response /body |
Then I get 422 as response code
And I get "Invalid Data Type" as response reason phrase
And I get an empty response body
@@ -8,11 +8,11 @@ Feature: Append new routes in Kapow! server.
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
When I append the route:
| method | url_pattern | entrypoint | command |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body |
Then I get 201 as response code
And I get "Created" as response reason 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 | * |
@@ -25,11 +25,11 @@ Feature: Append new routes in Kapow! server.
| 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
When I append the route:
| method | url_pattern | entrypoint | command |
| GET | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body |
Then I get 201 as response code
And I get "Created" as response reason 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 | * |
@@ -7,7 +7,7 @@ Feature: Fail to delete a route in Kapow! server.
will trigger a not found error.
Given I have a just started Kapow! server
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get not found as response code
And I get "Not Found" as response phrase
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get 404 as response code
And I get "Not Found" as response reason phrase
And I get an empty response body
@@ -16,35 +16,35 @@ Feature: Routes auto-ordering in a Kapow! server.
will maintain their relative order and their indexes
will be decreased by one.
When I delete the first route inserted
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty response body
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 | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 1 | * |
| GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * |
When I delete the first route inserted
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty response body
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 | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 1 | * |
| GET | /listDir/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | 2 | * |
Scenario: Removing the last routes.
When removing the last route the remaining ones will
maintain their relative order and indexes.
When I delete the last route inserted
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty response body
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 | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 2 | * |
When I delete the last route inserted
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty response body
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 | /listEtcDir | /bin/sh -c | ls -la /etc \| response /body | 2 | * |
Scenario: Removing a midst route.
When removing a midst route the remaining ones will
@@ -6,8 +6,8 @@ Feature: Delete routes in Kapow! server.
Routes are removed from the sever by specifying their id.
Given I have a running Kapow! server
And It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get ok as response code
And I get "OK" as response phrase
And It has a route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
When I delete the route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx"
Then I get 200 as response code
And I get "OK" as response reason phrase
And I get an empty response body
@@ -8,18 +8,18 @@ Feature: Kapow! server reject responses with malformed JSON bodies.
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
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
@@ -8,35 +8,35 @@ Feature: Kapow! server reject insert responses with semantic errors.
missing fields.
Given I have a running Kapow! server
When I insert 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" |
When I insert the route:
| entrypoint | command |
| /bin/sh -c | ls -la / \| response /body |
Then I get 422 as response code
And I get "Missing Mandatory Field" as response reason phrase
And I get the following entity as response body:
| missing_mandatory_fields |
| "url_pattern", "method" |
Scenario: Error because of wrong route specification.
If a request contains an invalid expression in the
url_pattern field the server responds with an error.
Given I have a running Kapow! server
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get unprocessable entity as response code
And I get "Invalid Route Spec" as response phrase
And I get an empty response body
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get 422 as response code
And I get "Invalid Route Spec" as response reason phrase
And I get an empty response body
Scenario: Error because of wrong method value.
If a request contains an invalid value in the
method field the server responds with an error.
Given I have a running Kapow! server
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| AVECES | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get unprocessable entity as response code
And I get "Invalid Data Type" as response phrase
And I get an empty response body
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| AVECES | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get 422 as response code
And I get "Invalid Data Type" as response reason phrase
And I get an empty response body
@@ -13,11 +13,11 @@ Feature: Insert new routes in Kapow! server.
A route can be inserted at the begining of the list
by specifying an index 0 in the request.
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get ok as response code
And I get "OK" as response phrase
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 0 |
Then I get 200 as response code
And I get "OK" as response reason 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 | * |
@@ -27,11 +27,11 @@ Feature: Insert new routes in Kapow! server.
by specifying an index less or equal to the last
index in the request.
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 |
Then I get ok as response code
And I get "OK" as response phrase
When I insert the route:
| method | url_pattern | entrypoint | command | index |
| GET | /listRootDir | /bin/sh -c | ls -la / \| response /body | 1 |
Then I get 200 as response code
And I get "OK" as response reason 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 | 1 | * |
+11 -11
View File
@@ -9,10 +9,10 @@ Feature: Listing routes in a Kapow! server
will show an empty list of routes.
Given I have a just started Kapow! server
When I request a routes listing
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty list
When I request a routes listing
Then I get 200 as response code
And I get "OK" as response phrase
And I get an empty list
Scenario: Listing routes on a server with routes loaded.
After some route creation/insertion operations the server
@@ -22,10 +22,10 @@ Feature: Listing routes in a Kapow! server
| 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 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 | * |
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 | * |