test: update smoke test for user auth flow

This commit is contained in:
mirivlad 2026-06-01 23:36:38 +08:00
parent f8dc436709
commit b3662d4876
1 changed files with 9 additions and 1 deletions

View File

@ -22,8 +22,16 @@ echo ":: Health"
curl -sf "http://localhost:$SERVER_PORT/api/v1/health" | grep -q '"ok"' && echo " OK" curl -sf "http://localhost:$SERVER_PORT/api/v1/health" | grep -q '"ok"' && echo " OK"
echo ":: Register device" echo ":: Register device"
# Register user first
curl -sf -X POST "http://localhost:$SERVER_PORT/api/v1/auth/register" \
-H "Content-Type: application/json" \
-d '{"username":"smokeuser","email":"smoke@test.local","password":"mypass123"}' > /dev/null
# Confirm email
TOKEN=$(sqlite3 "$SDIR/server.db" "SELECT token FROM server_email_tokens WHERE purpose='confirm' LIMIT 1")
curl -sf "http://localhost:$SERVER_PORT/api/v1/auth/confirm?token=$TOKEN" > /dev/null
# Register device with user creds
REG=$(curl -sf -X POST "http://localhost:$SERVER_PORT/api/v1/device/register" \ REG=$(curl -sf -X POST "http://localhost:$SERVER_PORT/api/v1/device/register" \
-H "Content-Type: application/json" -d '{"name":"smoke","username":"admin","password":"pass"}') -H "Content-Type: application/json" -d '{"name":"smoke","username":"smokeuser","password":"mypass123"}')
DID=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['device_id'])") DID=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['device_id'])")
AKEY=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['api_key'])") AKEY=$(echo "$REG" | python3 -c "import sys,json;print(json.load(sys.stdin)['api_key'])")
echo " device=$DID" echo " device=$DID"