From ef77f6d2d6ebe11d2c1afd93314d44840f6c7d77 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 18 Mar 2026 18:39:14 +0900 Subject: init --- bin/test.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 bin/test.sh (limited to 'bin/test.sh') diff --git a/bin/test.sh b/bin/test.sh new file mode 100755 index 0000000..ca305aa --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -euo pipefail + +# Test the webhook forwarder locally. +# Start the server first with: cargo run +# Then run this script in another terminal. + +BASE="http://localhost:8080" + +echo "=== Test 1: GET should return 405 ===" +STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/test-token") +echo "GET /test-token -> $STATUS (expect 405)" + +echo "" +echo "=== Test 2: POST to / should forward ===" +STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/test-token" -H "Content-Type: application/json" -d '{"ref":"refs/heads/main"}') +echo "POST /test-token -> $STATUS (expect 502 if Dokploy unreachable, or upstream status)" + +echo "" +echo "=== Test 3: POST to /compose/ should forward ===" +STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/compose/test-token" -H "Content-Type: application/json" -d '{"ref":"refs/heads/main"}') +echo "POST /compose/test-token -> $STATUS (expect 502 if Dokploy unreachable, or upstream status)" + +echo "" +echo "=== Test 4: POST to invalid path should return 404 ===" +STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/") +echo "POST / -> $STATUS (expect 404)" + +echo "" +echo "=== Test 5: POST to nested invalid path should return 404 ===" +STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$BASE/foo/bar/baz") +echo "POST /foo/bar/baz -> $STATUS (expect 404)" + +echo "" +echo "Done!" -- cgit v1.2.3