From d564ff920647dbe35a9848835492806370684e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Hurtado?= Date: Fri, 23 Aug 2019 13:11:05 +0200 Subject: [PATCH] New route added for 'Control API' for retrieving route info --- spec/README.md | 46 +++++++++++++++---- .../control/get/error_notfound.feature | 12 +++++ .../test/features/control/get/success.feature | 25 ++++++++++ 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 spec/test/features/control/get/error_notfound.feature create mode 100644 spec/test/features/control/get/success.feature diff --git a/spec/README.md b/spec/README.md index d4f23eb..35d9922 100644 --- a/spec/README.md +++ b/spec/README.md @@ -98,7 +98,7 @@ TODO: Intro to Architecture ### Core Concepts -In this section we are going to define several concepts that will be used +In this section we are going to define several concepts that will be used frequently throughout the spec. @@ -127,7 +127,7 @@ whole lifetime of the server. ## Design Principles -* Kapow! implementations should follow a general principle of robustness: be +* Kapow! implementations should follow a general principle of robustness: be conservative in what you do, be liberal in what you accept from others. * We reuse conventions of well-established software projects, such as Docker. * All requests and responses will leverage JSON as the data encoding method. @@ -339,6 +339,34 @@ Removes the route identified by `:id`. * **Notes**: +#### Retrieve route information + +Retrieves the information about the route identified by `:id`. + +* **URL**: `/routes/:id` +* **Method**: `GET` +* **Success Responses**: + * **Code**: `200 OK`
+ **Content**:
+ ```json + { + "method": "GET", + "url_pattern": "/hello", + "entrypoint": null, + "command": "echo Hello World | response /body", + "index": 0, + "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" + } + ``` +* **Error Responses**: + * **Code**: `404 Not Found` +* **Sample Call**:
+ ```sh + $ curl -X GET $KAPOW_URL/routes/ROUTE_1f186c92_f906_4506_9788_a1f541b11d0f + ``` +* **Notes**: + + # HTTP Data API It is the channel through which the actual HTTP data flows during the @@ -425,12 +453,12 @@ following resource paths: - Returned Value: `foo` - Comment: That would provide read-only access to the request URL parameter `q`. - Obtain the `Content-Type` header of the request. - - Scenario: A POST request with a JSON body and the header `Content-Type` set + - Scenario: A POST request with a JSON body and the header `Content-Type` set to `application/json`. - Key: `/request/headers/Content-Type` - Access: Read-Only - Returned Value: `application/json` - - Comment: That would provide read-only access to the value of the request + - Comment: That would provide read-only access to the value of the request header `Content-Type`. - Read a field from a form. - Scenario: A request generated by submitting this form:
@@ -446,7 +474,7 @@ following resource paths: - Key: `/request/form/firstname` - Access: Read-Only - Returned Value: `Jane` - - Comment: That would provide read-only access to the value of the field + - Comment: That would provide read-only access to the value of the field `firstname` of the form. - Set the response status code. - Scenario: A request is being attended. @@ -462,7 +490,7 @@ following resource paths: - Access: Write-Only - Acceptable Value: Any string of bytes. - Default Value: N/A - - Comment: For media types other than `application/octet-stream` you should + - Comment: For media types other than `application/octet-stream` you should specify the appropiate `Content-Type` header. **Note**: Parameters under `request` are read-only and, conversely, parameters under @@ -471,12 +499,12 @@ following resource paths: #### Get handler resource -Returns the value of the requested resource path, or an error if the resource +Returns the value of the requested resource path, or an error if the resource path doesn't exist or is invalid. * **URL**: `/handlers/{:handler_id}{:resource_path}` * **Method**: `GET` -* **URL Params**: FIXME: We think that here should be options to cook the value +* **URL Params**: FIXME: We think that here should be options to cook the value in some way, or get it raw. * **Success Responses**: * **Code**: `200 OK`
@@ -497,7 +525,7 @@ path doesn't exist or is invalid. * **URL**: `/handlers/{:handler_id}{:resource_path}` * **Method**: `PUT` -* **URL Params**: FIXME: We think that here should be options to cook the value +* **URL Params**: FIXME: We think that here should be options to cook the value in some way, or pass it raw. * **Data Params**: Binary payload. * **Success Responses**: diff --git a/spec/test/features/control/get/error_notfound.feature b/spec/test/features/control/get/error_notfound.feature new file mode 100644 index 0000000..5a2bea9 --- /dev/null +++ b/spec/test/features/control/get/error_notfound.feature @@ -0,0 +1,12 @@ +Feature: Fail to retrieve a route info in Kapow! server. + When trying to get a route info in the server, if it + does no exists the server respons with an error. + + Scenario: Try to get info for a non-existing route. + A request of retrieving a non-existing route info + will trigger a not found error. + + Given I have a just started Kapow! server + When I get the info for route with id "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" + Then I get 404 as response code + And I get "Not Found" as response reason phrase diff --git a/spec/test/features/control/get/success.feature b/spec/test/features/control/get/success.feature new file mode 100644 index 0000000..d71def9 --- /dev/null +++ b/spec/test/features/control/get/success.feature @@ -0,0 +1,25 @@ +Feature: Retrieve route info in Kapow! server. + Users can retrieve route info from the server by + specifying its id. + + Scenario: Retrieve route info. + Get route info by spscifying its id. + + 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 get the first route info + Then I get 200 as response code + And I get "OK" as response reason phrase + And I get the following response body: + """ + { + "method": "GET", + "url_pattern": "/listRootDir", + "entrypoint": "/bin/sh -c", + "command": "ls -la / | response /body", + "index": 0, + "id": ANY + } + """