-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-web-api.sh
More file actions
executable file
·92 lines (77 loc) · 2.42 KB
/
Copy pathtest-web-api.sh
File metadata and controls
executable file
·92 lines (77 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# SecondLayer MCP - Web API Test Script
# Використання: ./test-web-api.sh
BASE_URL="${API_URL:-http://localhost:3000}"
API_KEY="${API_KEY:-test-key-123}"
echo "========================================="
echo "SecondLayer MCP - Web API Tests"
echo "========================================="
echo "Base URL: $BASE_URL"
echo "API Key: ${API_KEY:0:10}..."
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
function test_endpoint() {
local name=$1
local method=$2
local endpoint=$3
local data=$4
echo -n "Testing: $name... "
if [ "$method" == "GET" ]; then
response=$(curl -s -w "\n%{http_code}" \
-H "Authorization: Bearer $API_KEY" \
"$BASE_URL$endpoint")
else
response=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "$data" \
"$BASE_URL$endpoint")
fi
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | head -n-1)
if [ "$http_code" == "200" ]; then
echo -e "${GREEN}✓ OK${NC} (HTTP $http_code)"
return 0
else
echo -e "${RED}✗ FAIL${NC} (HTTP $http_code)"
echo "Response: $body" | head -3
return 1
fi
}
# Test 1: Health check (no auth required)
echo "1. Health Check"
test_endpoint "Health endpoint" "GET" "/health"
echo ""
# Test 2: List tools
echo "2. MCP Tools"
test_endpoint "List tools" "GET" "/api/tools"
echo ""
# Test 3: Search precedents
echo "3. Search Legal Precedents"
test_endpoint "Search" "POST" "/api/tools/search_legal_precedents" \
'{"query": "тестовий запит", "limit": 1}'
echo ""
# Test 4: Get similar reasoning
echo "4. Similar Reasoning"
test_endpoint "Similar reasoning" "POST" "/api/tools/get_similar_reasoning" \
'{"reasoning_text": "суд вважає", "limit": 1}'
echo ""
# Test 5: Find law articles
echo "5. Law Articles"
test_endpoint "Find articles" "POST" "/api/tools/find_relevant_law_articles" \
'{"topic": "мобілізація"}'
echo ""
# Summary
echo "========================================="
echo -e "${GREEN}All tests completed!${NC}"
echo ""
echo "Next steps:"
echo "1. Open web demo: open config-examples/web-client-demo.html"
echo "2. View API docs: curl $BASE_URL/api/tools | jq ."
echo "3. Check logs: tail -f logs/combined.log"
echo ""