Skip to content

Commit 3904b0b

Browse files
committed
test: 更新微服务测试脚本配置和端点
- 移除服务启动等待时间 - 更新服务端点为统一域名 - 修改测试用户凭证为管理员账户 - 调整认证端点从/login变为/token
1 parent 8e14184 commit 3904b0b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test-microservice.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22

33
# 测试微服务认证流程脚本
44

5-
# 等待服务启动
6-
echo "等待服务启动..."
7-
sleep 20
5+
echo "开始测试..."
86

97
# 定义变量
10-
auth_service_url="http://localhost:8000/api/auth"
11-
user_service_url="http://localhost:8001/api/users"
12-
product_service_url="http://localhost:8002/api/products"
13-
username="testuser"
14-
password="testpassword"
8+
auth_service_url="http://localhost/api/auth"
9+
user_service_url="http://localhost/api/users"
10+
product_service_url="http://localhost/api/products"
11+
username="admin"
12+
password="secret"
1513

1614
# 1. 测试登录获取token
1715
echo -e "\n1. 测试登录获取token..."
18-
login_response=$(curl -s -X POST "${auth_service_url}/login" -H "Content-Type: application/json" -d '{"username": "'${username}'", "password": "'${password}'"}')
16+
login_response=$(curl -s -X POST "${auth_service_url}/token" -H "Content-Type: application/x-www-form-urlencoded" -d "username=${username}&password=${password}")
1917

2018
token=$(echo "${login_response}" | grep -o '"access_token":"[^"]*' | cut -d':' -f2 | tr -d '"')
2119

0 commit comments

Comments
 (0)