Merge pull request #23 from BBVA/feature/kapow-set-get

Feature kapow set & kapow get commands
This commit is contained in:
César Gallego Rodríguez
2019-09-05 11:35:16 +02:00
committed by GitHub
26 changed files with 143 additions and 177 deletions
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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``:
+33
View File
@@ -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()
-19
View File
@@ -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"
-46
View File
@@ -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()
+5 -5
View File
@@ -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
+1 -1
View File
@@ -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)'
+1 -1
View File
@@ -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'
+11 -11
View File
@@ -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
+6 -6
View File
@@ -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'
+1 -1
View File
@@ -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'
+5 -5
View File
@@ -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}
+7 -7
View File
@@ -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
<html>
<body>
<a href='javascript: Array.from(document.querySelectorAll("a")).filter(x => x.href.indexOf("magnet") != -1 ).map(x => x.href = "http://localhost:8080/save/magnet?link="+encodeURI(x.href))'>Add me to your bookmarks!</a>
@@ -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"'
-2
View File
@@ -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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 47 KiB

+14 -14
View File
@@ -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
@@ -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
@@ -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
}
@@ -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
}
@@ -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
@@ -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
}
@@ -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"
}
@@ -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
}
"""
@@ -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
}
@@ -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
}
@@ -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
}