Files
vector/scripts/e4-live-check.sh
T

27 lines
2.0 KiB
Bash
Raw 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.
#!/bin/sh
# E4 живая проверка: операция, contour_operation_id, ошибка без токена (ожидаемо 503)
set -e
TOKEN=$(curl -s -m 15 -X POST localhost:8000/api/v1/auth/login \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'username=admin&password=pass123' \
| python3 -c 'import sys,json; print(json.load(sys.stdin)["access_token"])')
CASE_ID=$(curl -s -m 15 "localhost:8000/api/v1/cases?limit=1" -H "Authorization: Bearer $TOKEN" | python3 -c 'import sys,json; print(json.load(sys.stdin)["items"][0]["id"])')
echo "=== операции кейса (case_id-фильтр):"
OPS=$(curl -s -m 15 "localhost:8000/api/v1/operations?case_id=$CASE_ID" -H "Authorization: Bearer $TOKEN")
echo "$OPS" | python3 -c 'import sys,json; d=json.load(sys.stdin); print("found:", d["total"])'
OID=$(echo "$OPS" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d["items"][0]["id"] if d["items"] else "")')
if [ -z "$OID" ]; then
OID=$(curl -s -m 15 -X POST localhost:8000/api/v1/operations -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' -d "{\"title\": \"E4-тест\", \"case_id\": \"$CASE_ID\"}" \
| python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')
echo "создана операция: $OID"
fi
echo "=== отправка без CONTOUR_TOKEN (ожидаем 503 с понятным detail):"
curl -s -m 15 -X POST "localhost:8000/api/v1/operations/$OID/send-to-contour" -H "Authorization: Bearer $TOKEN" | head -c 150
echo
echo "=== привязка contour_operation_id:"
curl -s -m 15 -X PATCH "localhost:8000/api/v1/operations/$OID" -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"contour_operation_id": "22222222-2222-4222-8222-000000000001"}' > /dev/null
echo "=== отправка с токеном-заглушкой (КОНТУР CT130 недоступен с ВЕКТОРа? ожидаем 502/или успех):"
curl -s -m 35 -X POST "localhost:8000/api/v1/operations/$OID/send-to-contour" -H "Authorization: Bearer $TOKEN" | head -c 300