feat(api): Add API testing script and quick test guide
This commit is contained in:
parent
b0318430ad
commit
7221a8e280
2 changed files with 117 additions and 0 deletions
51
backend/API-TEST-GUIDE.md
Normal file
51
backend/API-TEST-GUIDE.md
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# Quick API Test Commands
|
||||
|
||||
## Test from your local machine
|
||||
|
||||
### 1. Health Check
|
||||
```
|
||||
curl http://10.0.10.30:6800/health
|
||||
```
|
||||
|
||||
### 2. Ready Check
|
||||
```
|
||||
curl http://10.0.10.30:6800/ready
|
||||
```
|
||||
|
||||
### 3. Register User
|
||||
```
|
||||
curl -X POST http://10.0.10.30:6800/api/auth/register \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email": "test@example.com", "password": "SecurePassword123!", "username": "testuser"}'
|
||||
```
|
||||
|
||||
### 4. Login
|
||||
```
|
||||
curl -X POST http://10.0.10.30:6800/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email": "test@example.com", "password": "SecurePassword123!"}'
|
||||
```
|
||||
|
||||
### 5. Get User Profile (with token)
|
||||
```
|
||||
TOKEN=$(curl -s -X POST http://10.0.10.30:6800/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"email": "test@example.com", "password": "SecurePassword123!"}' \
|
||||
| jq -r '.access_token')
|
||||
|
||||
curl http://10.0.10.30:6800/api/users/me \
|
||||
-H "Authorization: Bearer $TOKEN"
|
||||
```
|
||||
|
||||
## Test from the server
|
||||
```
|
||||
cd backend
|
||||
./scripts/test-api.sh
|
||||
```
|
||||
|
||||
## Expected Results
|
||||
|
||||
- Health Check: `+`{"status":"ok"}`+`
|
||||
- Ready Check: `+`{"status":"ready"}`+`
|
||||
- Register: `+`{"message": "User registered successfully", "user_id": "..."}`+`
|
||||
- Login: `+`{"access_token": "...", "refresh_token": "...", "token_type": "bearer"}`+`
|
||||
Loading…
Add table
Add a link
Reference in a new issue