diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/setup.sh | 18 | ||||
| -rwxr-xr-x | bin/test.sh | 35 |
2 files changed, 53 insertions, 0 deletions
diff --git a/bin/setup.sh b/bin/setup.sh new file mode 100755 index 0000000..3b99a4e --- /dev/null +++ b/bin/setup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -euo pipefail + +cd /home/tradam/projects/webhook-forwarder + +# Initialize Rust project (skips if Cargo.toml already exists) +if [ ! -f Cargo.toml ]; then + cargo init --name webhook-forwarder +fi + +# Add dependencies +cargo add hyper --features server,http1 +cargo add hyper-util --features tokio +cargo add http-body-util +cargo add tokio --features rt-multi-thread,net,macros +cargo add bytes + +echo "Done! Rust project scaffolded successfully." 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 /<token> 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/<token> 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!" |
