95 lines
2.8 KiB
Bash
95 lines
2.8 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# furt-lua/scripts/test_curl.sh
|
||
|
|
# Manual curl tests for Furt Lua HTTP-Server
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
# Colors
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
RED='\033[0;31m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
NC='\033[0m'
|
||
|
|
|
||
|
|
# Server configuration
|
||
|
|
SERVER_URL="http://127.0.0.1:8080"
|
||
|
|
|
||
|
|
echo -e "${GREEN}=== Furt HTTP-Server Manual Tests ===${NC}"
|
||
|
|
echo -e "${YELLOW}Server:${NC} $SERVER_URL"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 1: Health Check
|
||
|
|
echo -e "${YELLOW}Test 1: Health Check${NC}"
|
||
|
|
echo "curl -X GET $SERVER_URL/health"
|
||
|
|
echo ""
|
||
|
|
curl -X GET "$SERVER_URL/health" | jq . 2>/dev/null || curl -X GET "$SERVER_URL/health"
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 2: Basic POST Test
|
||
|
|
echo -e "${YELLOW}Test 2: Basic POST Test${NC}"
|
||
|
|
echo "curl -X POST $SERVER_URL/test -H 'Content-Type: application/json' -d '{\"test\":\"data\"}'"
|
||
|
|
echo ""
|
||
|
|
curl -X POST "$SERVER_URL/test" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"test":"data","number":42}' | jq . 2>/dev/null || \
|
||
|
|
curl -X POST "$SERVER_URL/test" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"test":"data","number":42}'
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 3: Mail Endpoint - Valid Data
|
||
|
|
echo -e "${YELLOW}Test 3: Mail Endpoint - Valid Data${NC}"
|
||
|
|
echo "curl -X POST $SERVER_URL/v1/mail/send -H 'Content-Type: application/json' -d '{...}'"
|
||
|
|
echo ""
|
||
|
|
curl -X POST "$SERVER_URL/v1/mail/send" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{
|
||
|
|
"name": "Test User",
|
||
|
|
"email": "test@example.com",
|
||
|
|
"message": "This is a test message from curl"
|
||
|
|
}' | jq . 2>/dev/null || \
|
||
|
|
curl -X POST "$SERVER_URL/v1/mail/send" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{
|
||
|
|
"name": "Test User",
|
||
|
|
"email": "test@example.com",
|
||
|
|
"message": "This is a test message from curl"
|
||
|
|
}'
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 4: Mail Endpoint - Invalid Data
|
||
|
|
echo -e "${YELLOW}Test 4: Mail Endpoint - Invalid Data (Missing Fields)${NC}"
|
||
|
|
echo "curl -X POST $SERVER_URL/v1/mail/send -H 'Content-Type: application/json' -d '{\"name\":\"Test\"}'"
|
||
|
|
echo ""
|
||
|
|
curl -X POST "$SERVER_URL/v1/mail/send" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"name":"Test"}' | jq . 2>/dev/null || \
|
||
|
|
curl -X POST "$SERVER_URL/v1/mail/send" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"name":"Test"}'
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 5: 404 Error
|
||
|
|
echo -e "${YELLOW}Test 5: 404 Error Handling${NC}"
|
||
|
|
echo "curl -X GET $SERVER_URL/nonexistent"
|
||
|
|
echo ""
|
||
|
|
curl -X GET "$SERVER_URL/nonexistent" | jq . 2>/dev/null || curl -X GET "$SERVER_URL/nonexistent"
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Test 6: Method Not Allowed (if we want to test this)
|
||
|
|
echo -e "${YELLOW}Test 6: Wrong Method${NC}"
|
||
|
|
echo "curl -X PUT $SERVER_URL/v1/mail/send"
|
||
|
|
echo ""
|
||
|
|
curl -X PUT "$SERVER_URL/v1/mail/send" | jq . 2>/dev/null || curl -X PUT "$SERVER_URL/v1/mail/send"
|
||
|
|
echo ""
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${GREEN}=== Manual Tests Complete ===${NC}"
|
||
|
|
echo -e "${YELLOW}Note:${NC} These tests show the raw HTTP responses."
|
||
|
|
echo -e "${YELLOW} For automated testing, use: lua tests/test_http.lua${NC}"
|
||
|
|
|