scripts: живая проверка E3 на CT108
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# E3 живая проверка на CT108: операция создается на реальном кейсе, список, статусная машина
|
||||||
|
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; d=json.load(sys.stdin); items=d.get("items",[]); print(items[0]["id"] if items else "")')
|
||||||
|
echo "case_id: $CASE_ID"
|
||||||
|
echo "=== создание операции:"
|
||||||
|
curl -s -m 15 -X POST localhost:8000/api/v1/operations \
|
||||||
|
-H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
|
||||||
|
-d "{\"title\": \"E3-тест: операция на реальном кейсе\", \"case_id\": \"$CASE_ID\"}" > /tmp/op.json
|
||||||
|
python3 -c 'import json; d=json.load(open("/tmp/op.json")); print("op:", d.get("id"), "| status:", d.get("status"))'
|
||||||
|
OID=$(python3 -c 'import json; print(json.load(open("/tmp/op.json"))["id"])')
|
||||||
|
echo "=== статусная машина: paused → active:"
|
||||||
|
curl -s -m 15 -X PATCH "localhost:8000/api/v1/operations/$OID" -H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H 'Content-Type: application/json' -d '{"status": "paused"}' | python3 -c 'import sys,json; print("paused:", json.load(sys.stdin)["status"])'
|
||||||
|
curl -s -m 15 -X PATCH "localhost:8000/api/v1/operations/$OID" -H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H 'Content-Type: application/json' -d '{"status": "active"}' | python3 -c 'import sys,json; print("active:", json.load(sys.stdin)["status"])'
|
||||||
|
echo "=== недопустимый переход active → archived... нет, разрешён; completed → active запрещён:"
|
||||||
|
curl -s -m 15 -X PATCH "localhost:8000/api/v1/operations/$OID" -H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H 'Content-Type: application/json' -d '{"status": "completed"}' > /dev/null
|
||||||
|
curl -s -m 15 -X PATCH "localhost:8000/api/v1/operations/$OID" -H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H 'Content-Type: application/json' -d '{"status": "active"}' | head -c 150
|
||||||
|
echo
|
||||||
|
echo "=== summary:"
|
||||||
|
curl -s -m 15 localhost:8000/api/v1/operations/summary -H "Authorization: Bearer $TOKEN" | head -c 120
|
||||||
|
echo
|
||||||
|
echo "=== аудит:"
|
||||||
|
curl -s -m 15 "localhost:8000/api/v1/admin/users/audit?limit=5" -H "Authorization: Bearer $TOKEN" | python3 -c 'import sys,json; d=json.load(sys.stdin); print("events:", [e["event_type"] for e in d["items"]])'
|
||||||
Reference in New Issue
Block a user