diff --git a/spec/README.md b/spec/README.md index 35d9922..c1e7c9f 100644 --- a/spec/README.md +++ b/spec/README.md @@ -209,7 +209,7 @@ field must be a json scaped string. ] ``` * **Sample Call**: `$ curl $KAPOW_URL/routes` -* **Notes**: Currently all routes are returned; in the future, a filter may be +* **Notes**: Currently all routes are returned; in the future, a filter may be accepted. @@ -314,10 +314,11 @@ A new id is created for the appended route so it can be referenced later. ``` * **Notes**: * Route numbering starts at zero. - * When `index` is not provided or is less than `0` the route will be inserted + * When `index` is not provided or is `0` the route will be inserted first, effectively making it index `0`. * Conversely, when `index` is greater than the number of entries on the route table, it will be inserted last. + * Finally, when `index` is less than `0` a 422 error is raised. * A successful request will yield a response containing all the effective parameters that were applied. diff --git a/spec/test/features/control/insert/error_unprocessable.feature b/spec/test/features/control/insert/error_unprocessable.feature index 374a68e..97e15c7 100644 --- a/spec/test/features/control/insert/error_unprocessable.feature +++ b/spec/test/features/control/insert/error_unprocessable.feature @@ -34,3 +34,21 @@ Feature: Kapow! server rejects insertion requests with semantic errors. """ Then I get 422 as response code And I get "Invalid Route" as response reason phrase + + Scenario: Error because negative index specified. + If a request contains a negative number in the + index field the server responds with an error. + + Given I have a running Kapow! server + When I insert the route: + """ + { + "method": "GET", + "url_pattern": "+123--", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": -1 + } + """ + Then I get 422 as response code + And I get "Invalid Route" as response reason phrase