diff --git a/README.rst b/README.rst index 007c637..4c6fca0 100644 --- a/README.rst +++ b/README.rst @@ -34,7 +34,7 @@ Kapow! allows you to write a litte script that will **serve an executable as RES service**. This script will let you define how to connect HTTP and the Shell using Kapow!'s shell abstractions to the HTTP world. See it to believe: -.. image:: https://github.com/BBVA/kapow/blob/master/resources/kapow.gif?raw=true +.. image:: resources/kapow.gif?raw=true :alt: Kapow! in action diff --git a/doc/readme.rst b/doc/readme.rst index 0835521..15a761e 100644 --- a/doc/readme.rst +++ b/doc/readme.rst @@ -34,7 +34,7 @@ that contains: .. code-block:: bash kapow route add /backups \ - -c 'cloudx storage ls /backups | grep $(request /params/query) | response /body' + -c 'cloudx storage ls /backups | grep $(kapow get /request/params/query) | kapow set /response/body' and execute it in the host with the command: @@ -53,7 +53,7 @@ First you must create a pow file named ``hello.pow`` with the following contents .. code-block:: bash - kapow route add /greet -c "echo 'hello world' | response /body" + kapow route add /greet -c "echo 'hello world' | kapow set /response/body" then, you must execute: @@ -75,7 +75,7 @@ First you must create a pow file named ``echo.pow`` with the following contents: .. code-block:: bash - kapow route add -X POST /echo -c 'request /body | response /body' + kapow route add -X POST /echo -c 'kapow get /request/body | kapow set /response/body' then, you must execute: @@ -108,7 +108,7 @@ Let's write a ``multiline.pow`` file with the following content: kapow route add /log_and_love - <<- 'EOF' echo "[$(date)] and stuff" >> stuff.log - echo love | response /body + echo love | kapow set /response/body EOF and then we serve it with ``kapow``: diff --git a/poc/bin/kapow b/poc/bin/kapow index f9073e7..73ffc3b 100755 --- a/poc/bin/kapow +++ b/poc/bin/kapow @@ -595,5 +595,38 @@ def route_list(route_id, url): print(json.dumps(response.json(), indent=2)) +@kapow.command("set") +@click.option("--url", envvar='KAPOW_URL') +@click.option("--handler-id", envvar='KAPOW_HANDLER_ID') +@click.argument("path", nargs=1) +@click.argument("value", required=False) +def kapow_set(url, handler_id, path, value): + if value is None: + data = sys.stdin.buffer + else: + data = value.encode('utf-8') + + try: + response = requests.put(f"{url}/handlers/{handler_id}{path}", + data=data) + except requests.exceptions.ConnectionError: + return False + else: + response.raise_for_status() + + +@kapow.command("get") +@click.option("--url", envvar='KAPOW_URL') +@click.option("--handler-id", envvar='KAPOW_HANDLER_ID') +@click.argument("path", nargs=1) +def kapow_get(url, handler_id, path): + try: + response = requests.get(f"{url}/handlers/{handler_id}{path}") + response.raise_for_status() + except requests.exceptions.ConnectionError: + return False + else: + print(response.text) + if __name__ == '__main__': kapow() diff --git a/poc/bin/request b/poc/bin/request deleted file mode 100755 index 0ebf854..0000000 --- a/poc/bin/request +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# -# Copyright 2019 Banco Bilbao Vizcaya Argentaria, S.A. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -curl -sf "${KAPOW_URL}/handlers/${KAPOW_HANDLER_ID}/request$1" diff --git a/poc/bin/response b/poc/bin/response deleted file mode 100755 index 75dc091..0000000 --- a/poc/bin/response +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -# -# Copyright 2019 Banco Bilbao Vizcaya Argentaria, S.A. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import sys - -import click -import requests - - -@click.command() -@click.option("--url", envvar='KAPOW_URL') -@click.option("--handler-id", envvar='KAPOW_HANDLER_ID') -@click.argument("path", nargs=1) -@click.argument("value", required=False) -def response(url, handler_id, path, value): - if value is None: - data = sys.stdin.buffer - else: - data = value.encode('utf-8') - - try: - response = requests.put(f"{url}/handlers/{handler_id}/response{path}", - data=data) - except requests.exceptions.ConnectionError: - return False - else: - response.raise_for_status() - - -if __name__ == '__main__': - response() diff --git a/poc/bin/static b/poc/bin/static index 5698741..ebe59c4 100755 --- a/poc/bin/static +++ b/poc/bin/static @@ -5,17 +5,17 @@ PATHNAME="$2" REAL="$(realpath --relative-base="$BASE" "$BASE/$PATHNAME")" if [ ! -f "$BASE/$PATHNAME" ]; then - response /status 404 + kapow set /response/status 404 exit else case $REAL in "/"*) - response /status 403 + kapow set /response/status 403 exit ;; *) - response /status 200 - response /headers/Content-Type "$(python -m mimetypes "$BASE/$REAL" | awk '/type:/ {print $2; exit 0}; !/type:/ {print "application/octet-stream"}')" - response /body < "$BASE/$REAL" + kapow set /response/status 200 + kapow set /response/headers/Content-Type "$(python -m mimetypes "$BASE/$REAL" | awk '/type:/ {print $2; exit 0}; !/type:/ {print "application/octet-stream"}')" + kapow set /response/body < "$BASE/$REAL" esac fi diff --git a/poc/examples/eval.pow b/poc/examples/eval.pow index 209be5d..acc18bd 100755 --- a/poc/examples/eval.pow +++ b/poc/examples/eval.pow @@ -16,4 +16,4 @@ # limitations under the License. # -kapow route add -X POST '/eval' -c '$($(request /body) | response /stream)' +kapow route add -X POST '/eval' -c '$($(kapow get /request/body) | kapow set /response/stream)' diff --git a/poc/examples/nmap/nmap.pow b/poc/examples/nmap/nmap.pow index e68eb4c..37ec075 100755 --- a/poc/examples/nmap/nmap.pow +++ b/poc/examples/nmap/nmap.pow @@ -16,4 +16,4 @@ # limitations under the License. # -kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(request /matches/ip) | response /body' +kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(kapow get /request/matches/ip) | kapow set /response/body' diff --git a/poc/examples/operator.pow b/poc/examples/operator.pow index 6be8194..27bca22 100755 --- a/poc/examples/operator.pow +++ b/poc/examples/operator.pow @@ -16,26 +16,26 @@ # limitations under the License. # -kapow route add /list/files -c 'ls -la $(request /params/path) | response /body' +kapow route add /list/files -c 'ls -la $(kapow get /request/params/path) | kapow set /response/body' -kapow route add /list/processes -c 'ps -aux | response /body' +kapow route add /list/processes -c 'ps -aux | kapow set /response/body' -kapow route add /show/cpuinfo -c 'response /body < /proc/cpuinfo' +kapow route add /show/cpuinfo -c 'kapow set /response/body < /proc/cpuinfo' -kapow route add /show/memory -c 'free -m | response /body' +kapow route add /show/memory -c 'free -m | kapow set /response/body' -kapow route add /show/disk -c 'df -h | response /body' +kapow route add /show/disk -c 'df -h | kapow set /response/body' -kapow route add /show/connections -c 'ss -pluton | response /body' +kapow route add /show/connections -c 'ss -pluton | kapow set /response/body' -kapow route add /show/mounts -c 'mount | response /body' +kapow route add /show/mounts -c 'mount | kapow set /response/body' kapow route add /tail/dmesg - <<-'EOF' - response /headers/Content-Type text/plain - dmesg -w | response /stream + kapow set /response/headers/Content-Type text/plain + dmesg -w | kapow set /response/stream EOF kapow route add /tail/journal - <<-'EOF' - response /headers/Content-Type text/plain - journalctl -f | response /stream + kapow set /response/headers/Content-Type text/plain + journalctl -f | kapow set /response/stream EOF diff --git a/poc/examples/pandoc/pandoc.pow b/poc/examples/pandoc/pandoc.pow index 22af342..fb245c5 100755 --- a/poc/examples/pandoc/pandoc.pow +++ b/poc/examples/pandoc/pandoc.pow @@ -17,10 +17,10 @@ # kapow route add -X POST --entrypoint '/bin/zsh -c' '/convert/{from}/{to}' - <<-'EOF' - pandoc --from=$(request /matches/from) \ - --to=$(request /matches/to) \ - --output=>(response /body) \ - =(request /body) + pandoc --from=$(kapow get /request/matches/from) \ + --to=$(kapow get /request/matches/to) \ + --output=>(kapow set /response/body) \ + =(kapow get /request/body) EOF -kapow route add -X GET '/formats/input' -c 'pandoc --list-input-formats | response /body' -kapow route add -X GET '/formats/output' -c 'pandoc --list-output-formats | grep -v pdf | response /body' +kapow route add -X GET '/formats/input' -c 'pandoc --list-input-formats | kapow set /response/body' +kapow route add -X GET '/formats/output' -c 'pandoc --list-output-formats | grep -v pdf | kapow set /response/body' diff --git a/poc/examples/pdfeditor/pdfeditor.pow b/poc/examples/pdfeditor/pdfeditor.pow index 00db1da..06eb815 100755 --- a/poc/examples/pdfeditor/pdfeditor.pow +++ b/poc/examples/pdfeditor/pdfeditor.pow @@ -17,4 +17,4 @@ # kapow route add -X POST --entrypoint ./topdf '/editor/pdf' -kapow route add / -c 'response /headers/Content-Type text/html && response /body < pdfeditor.html' +kapow route add / -c 'kapow set /response/headers/Content-Type text/html && kapow set /response/body < pdfeditor.html' diff --git a/poc/examples/pdfeditor/topdf b/poc/examples/pdfeditor/topdf index d05b2dc..8e2dddc 100755 --- a/poc/examples/pdfeditor/topdf +++ b/poc/examples/pdfeditor/topdf @@ -17,12 +17,12 @@ # tmpfile=$(mktemp --suffix=.pdf) -pandoc --from=$(request /form/from) --to=pdf --output=${tmpfile} -t latex =(request /form/content) +pandoc --from=$(kapow get /request/form/from) --to=pdf --output=${tmpfile} -t latex =(kapow get /request/form/content) if [ $? -eq 0 ]; then - response /headers/Content-Type application/pdf - response /body < ${tmpfile} - response /status 200 + kapow set /response/headers/Content-Type application/pdf + kapow set /response/body < ${tmpfile} + kapow set /response/status 200 else - response /status 500 + kapow set /response/status 500 fi rm -f ${tmpfile} diff --git a/poc/examples/torrent.pow b/poc/examples/torrent.pow index c58ff45..ee31e7d 100755 --- a/poc/examples/torrent.pow +++ b/poc/examples/torrent.pow @@ -17,8 +17,8 @@ # kapow route add / - <<-'EOF' - response /headers/Content-Type text/html - response /body <<-HTML + kapow set /response/headers/Content-Type text/html + kapow set /response/body <<-HTML
Add me to your bookmarks! @@ -28,16 +28,16 @@ kapow route add / - <<-'EOF' EOF kapow route add /save/magnet -e '/bin/bash -c' - <<-'EOF' - link=$(request /params/link) - [ -z $link ] && response /status 400 && exit 0 + link=$(kapow get /request/params/link) + [ -z $link ] && kapow set /response/status 400 && exit 0 watch_folder=/tmp cd $watch_folder [[ "$link" =~ xt=urn:btih:([^&/]+) ]] || exit; echo "d10:magnet-uri${#link}:${link}e" > "meta-${BASH_REMATCH[1]}.torrent" - response /status 302 - response /headers/Location /torrent/list + kapow set /response/status 302 + kapow set /response/headers/Location /torrent/list EOF -kapow route add /torrent/list -c 'response /body "Not Implemented Yet"' +kapow route add /torrent/list -c 'kapow set /response/body "Not Implemented Yet"' diff --git a/poc/setup.cfg b/poc/setup.cfg index bc2f52f..2740a1b 100644 --- a/poc/setup.cfg +++ b/poc/setup.cfg @@ -10,8 +10,6 @@ zip_safe = True include_package_data = True scripts = bin/kapow - bin/request - bin/response bin/static install_requires = aiohttp==3.5.4 diff --git a/resources/kapow.gif b/resources/kapow.gif index 7c29bcc..63b20ec 100644 Binary files a/resources/kapow.gif and b/resources/kapow.gif differ diff --git a/spec/README.md b/spec/README.md index dcaa4f9..4883b90 100644 --- a/spec/README.md +++ b/spec/README.md @@ -159,7 +159,7 @@ Content-Length: 189 "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } @@ -194,7 +194,7 @@ field must be a json scaped string. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" }, @@ -202,7 +202,7 @@ field must be a json scaped string. "method": "POST", "url_pattern": "/bye", "entrypoint": null, - "command": "echo Bye World | response /body", + "command": "echo Bye World | kapow set /response/body", "index": 1, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } @@ -227,7 +227,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body" + "command": "echo Hello World | kapow set /response/body" } ``` * **Success Responses**: @@ -239,7 +239,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } @@ -254,7 +254,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body" + "command": "echo Hello World | kapow set /response/body" } EOF ``` @@ -280,7 +280,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", } ``` * **Success Responses**: @@ -292,7 +292,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } @@ -307,7 +307,7 @@ A new id is created for the appended route so it can be referenced later. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0 } EOF @@ -354,7 +354,7 @@ Retrieves the information about the route identified by `{id}`. "method": "GET", "url_pattern": "/hello", "entrypoint": null, - "command": "echo Hello World | response /body", + "command": "echo Hello World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } @@ -673,7 +673,7 @@ Options: #### Example ```sh -kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(request /matches/ip) | response /body' +kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(kapow get /request/matches/ip) | kapow set /response/body' ``` ### `request` @@ -689,7 +689,7 @@ Exposes the requests' resources. #### Example ```sh # Access the body of the request -request /body +kapow get /request/body ``` @@ -706,14 +706,14 @@ Exposes the response's resources. #### Example ```sh # Write to the body of the response -echo 'Hello, World!' | response /body +echo 'Hello, World!' | kapow set /response/body ``` ## An End-to-End Example ```sh $ cat nmap.kpow -kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(request /matches/ip) | response /body' +kapow route add -X GET '/list/{ip}' -c 'nmap -sL $(kapow get /request/matches/ip) | kapow set /response/body' ``` ```sh $ kapow ./nmap.kapow diff --git a/spec/test/features/control/append/error_unprocessable.feature b/spec/test/features/control/append/error_unprocessable.feature index 29eb180..128ece7 100644 --- a/spec/test/features/control/append/error_unprocessable.feature +++ b/spec/test/features/control/append/error_unprocessable.feature @@ -12,7 +12,7 @@ Feature: Kapow! server rejects requests with semantic errors. """ { "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body" + "command": "ls -la / | kapow set /response/body" } """ Then I get 422 as response code @@ -29,7 +29,7 @@ Feature: Kapow! server rejects requests with semantic errors. "method": "GET", "url_pattern": "+123--", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body" + "command": "ls -la / | kapow set /response/body" } """ Then I get 422 as response code diff --git a/spec/test/features/control/append/success.feature b/spec/test/features/control/append/success.feature index 2f419b7..0ab5581 100644 --- a/spec/test/features/control/append/success.feature +++ b/spec/test/features/control/append/success.feature @@ -14,7 +14,7 @@ Feature: Append new routes in Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body" + "command": "ls -la / | kapow set /response/body" } """ Then I get 201 as response code @@ -25,7 +25,7 @@ Feature: Append new routes in Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY } @@ -37,15 +37,15 @@ Feature: Append new routes in Kapow! server. Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | When I append the route: """ { "method": "GET", "url_pattern": "/baz", "entrypoint": "/bin/sh -c", - "command": "ls -la /etc | response /body" + "command": "ls -la /etc | kapow set /response/body" } """ Then I get 201 as response code @@ -56,7 +56,7 @@ Feature: Append new routes in Kapow! server. "method": "GET", "url_pattern": "/baz", "entrypoint": "/bin/sh -c", - "command": "ls -la /etc | response /body", + "command": "ls -la /etc | kapow set /response/body", "index": 2, "id": ANY } diff --git a/spec/test/features/control/delete/list_order.feature b/spec/test/features/control/delete/list_order.feature index f6296c4..c2f0531 100644 --- a/spec/test/features/control/delete/list_order.feature +++ b/spec/test/features/control/delete/list_order.feature @@ -5,10 +5,10 @@ Feature: Consistent route order after a route deletion in Kapow! server. Background: Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /bar | /bin/sh -c | ls -la /var \| response /body | - | GET | /baz | /bin/sh -c | ls -la /etc \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /bar | /bin/sh -c | ls -la /var \| kapow set /response/body | + | GET | /baz | /bin/sh -c | ls -la /etc \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | Scenario: Removing the first route. After removing the first route the remaining ones @@ -24,7 +24,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 0, "id": ANY }, @@ -32,7 +32,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/baz", "entrypoint": "/bin/sh -c", - "command": "ls -la /etc | response /body", + "command": "ls -la /etc | kapow set /response/body", "index": 1, "id": ANY }, @@ -40,7 +40,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 2, "id": ANY } @@ -60,7 +60,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY }, @@ -68,7 +68,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 1, "id": ANY }, @@ -76,7 +76,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/baz", "entrypoint": "/bin/sh -c", - "command": "ls -la /etc | response /body", + "command": "ls -la /etc | kapow set /response/body", "index": 2, "id": ANY } @@ -97,7 +97,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY }, @@ -105,7 +105,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/baz", "entrypoint": "/bin/sh -c", - "command": "ls -la /etc | response /body", + "command": "ls -la /etc | kapow set /response/body", "index": 1, "id": ANY }, @@ -113,7 +113,7 @@ Feature: Consistent route order after a route deletion in Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 2, "id": ANY } diff --git a/spec/test/features/control/delete/success.feature b/spec/test/features/control/delete/success.feature index 3aafacd..8b60dac 100644 --- a/spec/test/features/control/delete/success.feature +++ b/spec/test/features/control/delete/success.feature @@ -7,8 +7,8 @@ Feature: Delete routes in Kapow! server. Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | When I delete the first route Then I get 204 as response code And I get "No Content" as response reason phrase diff --git a/spec/test/features/control/get/success.feature b/spec/test/features/control/get/success.feature index c01f09f..e723fa5 100644 --- a/spec/test/features/control/get/success.feature +++ b/spec/test/features/control/get/success.feature @@ -7,8 +7,8 @@ Feature: Retrieve route details in Kapow! server. Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | When I get the first route Then I get 200 as response code And I get "OK" as response reason phrase @@ -18,7 +18,7 @@ Feature: Retrieve route details in Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY } diff --git a/spec/test/features/control/insert/error_malformed.feature b/spec/test/features/control/insert/error_malformed.feature index 86e9461..74ea132 100644 --- a/spec/test/features/control/insert/error_malformed.feature +++ b/spec/test/features/control/insert/error_malformed.feature @@ -15,7 +15,7 @@ Feature: Kapow! server rejects insertion requests with malformed JSON bodies. "url_pattern": /hello, "entrypoint": null "command": "echo Hello - World | response /body", + World | kapow set /response/body", "index": 0, "id": "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx" } diff --git a/spec/test/features/control/insert/error_unprocessable.feature b/spec/test/features/control/insert/error_unprocessable.feature index 97e15c7..c90898d 100644 --- a/spec/test/features/control/insert/error_unprocessable.feature +++ b/spec/test/features/control/insert/error_unprocessable.feature @@ -11,7 +11,7 @@ Feature: Kapow! server rejects insertion requests with semantic errors. """ { "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body" + "command": "ls -la / | kapow set /response/body" } """ Then I get 422 as response code @@ -28,7 +28,7 @@ Feature: Kapow! server rejects insertion requests with semantic errors. "method": "GET", "url_pattern": "+123--", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0 } """ @@ -46,7 +46,7 @@ Feature: Kapow! server rejects insertion requests with semantic errors. "method": "GET", "url_pattern": "+123--", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": -1 } """ diff --git a/spec/test/features/control/insert/list_order.feature b/spec/test/features/control/insert/list_order.feature index 5e11303..5644736 100644 --- a/spec/test/features/control/insert/list_order.feature +++ b/spec/test/features/control/insert/list_order.feature @@ -5,8 +5,8 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. Background: Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | Scenario: Inserting before the first route. After inserting before the first route the previous set @@ -19,7 +19,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 0 } """ @@ -31,7 +31,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 0, "id": ANY }, @@ -39,7 +39,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 1, "id": ANY }, @@ -47,7 +47,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 2, "id": ANY } @@ -64,7 +64,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 2 } """ @@ -76,7 +76,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY }, @@ -84,7 +84,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 1, "id": ANY }, @@ -92,7 +92,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 2, "id": ANY } @@ -110,7 +110,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 1 } """ @@ -122,7 +122,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY }, @@ -130,7 +130,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 1, "id": ANY }, @@ -138,7 +138,7 @@ Feature: Consistent route ordering after inserting a route in a Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 2, "id": ANY } diff --git a/spec/test/features/control/insert/success.feature b/spec/test/features/control/insert/success.feature index 185308a..61ff11e 100644 --- a/spec/test/features/control/insert/success.feature +++ b/spec/test/features/control/insert/success.feature @@ -6,8 +6,8 @@ Feature: Insert new routes in Kapow! server. Background: Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | Scenario: Insert a route at the beginning. A route can be inserted at the beginning of the list @@ -19,7 +19,7 @@ Feature: Insert new routes in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 0 } """ @@ -31,7 +31,7 @@ Feature: Insert new routes in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 0, "id": ANY } @@ -48,7 +48,7 @@ Feature: Insert new routes in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 1 } """ @@ -60,7 +60,7 @@ Feature: Insert new routes in Kapow! server. "method": "GET", "url_pattern": "/bar", "entrypoint": "/bin/sh -c", - "command": "ls -la /var | response /body", + "command": "ls -la /var | kapow set /response/body", "index": 1, "id": ANY } diff --git a/spec/test/features/control/list/success.feature b/spec/test/features/control/list/success.feature index d3c3fd4..711435f 100644 --- a/spec/test/features/control/list/success.feature +++ b/spec/test/features/control/list/success.feature @@ -22,8 +22,8 @@ Feature: Listing routes in a Kapow! server. Given I have a Kapow! server with the following routes: | method | url_pattern | entrypoint | command | - | GET | /foo | /bin/sh -c | ls -la / \| response /body | - | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| response /body | + | GET | /foo | /bin/sh -c | ls -la / \| kapow set /response/body | + | GET | /qux/{dirname} | /bin/sh -c | ls -la /request/params/dirname \| kapow set /response/body | When I request a routes listing Then I get 200 as response code And I get "OK" as response reason phrase @@ -34,7 +34,7 @@ Feature: Listing routes in a Kapow! server. "method": "GET", "url_pattern": "/foo", "entrypoint": "/bin/sh -c", - "command": "ls -la / | response /body", + "command": "ls -la / | kapow set /response/body", "index": 0, "id": ANY }, @@ -42,7 +42,7 @@ Feature: Listing routes in a Kapow! server. "method": "GET", "url_pattern": "/qux/{dirname}", "entrypoint": "/bin/sh -c", - "command": "ls -la /request/params/dirname | response /body", + "command": "ls -la /request/params/dirname | kapow set /response/body", "index": 1, "id": ANY }