Small testing script for the API with individual payloads

This commit is contained in:
southerntofu 2020-04-02 22:42:12 +02:00
parent ec484df578
commit 1264ed75eb
7 changed files with 51 additions and 0 deletions

26
curl.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
function list {
echo "Available test payloads:"
for file in ./tests/*; do
echo $(basename ${file} .json)
done
}
[[ $# != 1 ]] && list && exit 0
file="./tests/${1}"
if [ ! -f ${file} ]; then
if [ -f ${file}.json ]; then
file="${file}.json"
else
echo "File not found: ${file}"
exit 1
fi
fi
curl -f -H "REMOTE_USER: apitest" -H "Content-Type: application/json" -d @${file} http://localhost:3030/api
[[ $? != 0 ]] && echo "HTTP ERROR" && exit 1
echo ""

4
tests/bogus_command.json Normal file
View File

@ -0,0 +1,4 @@
{
"command": "bogus",
"method": "GET"
}

4
tests/bogus_method.json Normal file
View File

@ -0,0 +1,4 @@
{
"command": "version",
"method": "READ"
}

4
tests/stats.json Normal file
View File

@ -0,0 +1,4 @@
{
"command": "stats",
"method": "GET"
}

4
tests/version.json Normal file
View File

@ -0,0 +1,4 @@
{
"command": "version",
"method": "GET"
}

4
tests/zone_list.json Normal file
View File

@ -0,0 +1,4 @@
{
"command": "zone",
"method": "GET"
}

5
tests/zone_read.json Normal file
View File

@ -0,0 +1,5 @@
{
"command": "zone",
"method": "GET",
"args": ["foobar.netlib.re"]
}