From 1264ed75eb5c4a5abce32f6890b82aea55c67860 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Thu, 2 Apr 2020 22:42:12 +0200 Subject: [PATCH] Small testing script for the API with individual payloads --- curl.sh | 26 ++++++++++++++++++++++++++ tests/bogus_command.json | 4 ++++ tests/bogus_method.json | 4 ++++ tests/stats.json | 4 ++++ tests/version.json | 4 ++++ tests/zone_list.json | 4 ++++ tests/zone_read.json | 5 +++++ 7 files changed, 51 insertions(+) create mode 100755 curl.sh create mode 100644 tests/bogus_command.json create mode 100644 tests/bogus_method.json create mode 100644 tests/stats.json create mode 100644 tests/version.json create mode 100644 tests/zone_list.json create mode 100644 tests/zone_read.json diff --git a/curl.sh b/curl.sh new file mode 100755 index 0000000..fecf45d --- /dev/null +++ b/curl.sh @@ -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 "" diff --git a/tests/bogus_command.json b/tests/bogus_command.json new file mode 100644 index 0000000..91c0a06 --- /dev/null +++ b/tests/bogus_command.json @@ -0,0 +1,4 @@ +{ + "command": "bogus", + "method": "GET" +} diff --git a/tests/bogus_method.json b/tests/bogus_method.json new file mode 100644 index 0000000..8dde021 --- /dev/null +++ b/tests/bogus_method.json @@ -0,0 +1,4 @@ +{ + "command": "version", + "method": "READ" +} diff --git a/tests/stats.json b/tests/stats.json new file mode 100644 index 0000000..52bbfb5 --- /dev/null +++ b/tests/stats.json @@ -0,0 +1,4 @@ +{ + "command": "stats", + "method": "GET" +} diff --git a/tests/version.json b/tests/version.json new file mode 100644 index 0000000..2e624cf --- /dev/null +++ b/tests/version.json @@ -0,0 +1,4 @@ +{ + "command": "version", + "method": "GET" +} diff --git a/tests/zone_list.json b/tests/zone_list.json new file mode 100644 index 0000000..d09ba25 --- /dev/null +++ b/tests/zone_list.json @@ -0,0 +1,4 @@ +{ + "command": "zone", + "method": "GET" +} diff --git a/tests/zone_read.json b/tests/zone_read.json new file mode 100644 index 0000000..32977f4 --- /dev/null +++ b/tests/zone_read.json @@ -0,0 +1,5 @@ +{ + "command": "zone", + "method": "GET", + "args": ["foobar.netlib.re"] +}