-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_test.sh
More file actions
executable file
·83 lines (68 loc) · 2.29 KB
/
quick_test.sh
File metadata and controls
executable file
·83 lines (68 loc) · 2.29 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
#!/bin/bash
# Quick API Test Script for Task Manager PRO
BASE_URL="http://localhost:8000"
echo "🚀 Task Manager PRO - Quick API Test"
echo "====================================="
echo ""
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# 1. Health Check
echo -e "${YELLOW}1. Health Check${NC}"
curl -s $BASE_URL/health | python3 -m json.tool
echo -e "\n"
# 2. Register User
echo -e "${YELLOW}2. Register User${NC}"
REGISTER_RESPONSE=$(curl -s -X POST $BASE_URL/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"email": "[email protected]",
"password": "TestPass123!"
}')
echo $REGISTER_RESPONSE | python3 -m json.tool
echo -e "\n"
# 3. Login
echo -e "${YELLOW}3. Login & Get Token${NC}"
LOGIN_RESPONSE=$(curl -s -X POST $BASE_URL/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "testuser",
"password": "TestPass123!"
}')
echo $LOGIN_RESPONSE | python3 -m json.tool
TOKEN=$(echo $LOGIN_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])" 2>/dev/null)
if [ -z "$TOKEN" ]; then
echo -e "${RED}Failed to get token. User might already exist - trying to login with existing credentials${NC}"
exit 1
fi
echo -e "${GREEN}✓ Token acquired${NC}"
echo -e "\n"
# 4. Create Task
echo -e "${YELLOW}4. Create Task${NC}"
TASK_RESPONSE=$(curl -s -X POST $BASE_URL/api/tasks \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"title": "Test API Integration",
"description": "Testing the Task Manager PRO API",
"due_date": "2026-12-31",
"priority": "high"
}')
echo $TASK_RESPONSE | python3 -m json.tool
TASK_ID=$(echo $TASK_RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin)['id'])" 2>/dev/null)
echo -e "\n"
# 5. List Tasks
echo -e "${YELLOW}5. List All Tasks${NC}"
curl -s -X GET $BASE_URL/api/tasks \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
echo -e "\n"
# 6. Get Current User
echo -e "${YELLOW}6. Get Current User Info${NC}"
curl -s -X GET $BASE_URL/api/users/me \
-H "Authorization: Bearer $TOKEN" | python3 -m json.tool
echo -e "\n"
echo -e "${GREEN}✅ All tests completed!${NC}"
echo -e "\n📚 Visit http://localhost:8000/api/docs for interactive documentation"