Files
user-system/test_api.bat

40 lines
1.1 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 用户管理系统 API 测试脚本
@if "%TEST_ADMIN_ACCOUNT%"=="" set TEST_ADMIN_ACCOUNT=admin
@if "%TEST_ADMIN_PASSWORD%"=="" (
@echo 请先设置 TEST_ADMIN_PASSWORD
@exit /b 1
)
## 1. 健康检查
@echo "=== 1. 健康检查 ==="
curl http://localhost:8080/health
echo.
## 2. 用户注册
@echo.
@echo "=== 2. 用户注册 ==="
curl -X POST http://localhost:8080/api/v1/auth/register ^
-H "Content-Type: application/json" ^
-d "{\"username\":\"testuser\",\"password\":\"Test123456\",\"email\":\"test@example.com\"}"
echo.
## 3. 用户登录
@echo.
@echo "=== 3. 用户登录admin ==="
curl -X POST http://localhost:8080/api/v1/auth/login ^
-H "Content-Type: application/json" ^
-d "{\"account\":\"%TEST_ADMIN_ACCOUNT%\",\"password\":\"%TEST_ADMIN_PASSWORD%\"}"
echo.
## 4. 获取用户信息需要token这里先跳过
@echo.
@echo "=== 4. 需要使用登录返回的token ==="
@echo "请复制上面登录返回的access_token然后手动测试"
@echo "curl -X GET http://localhost:8080/api/v1/auth/userinfo -H \"Authorization: Bearer YOUR_TOKEN\""
echo.
@echo.
@echo "测试完成!"
@pause