fix: complete retention archive pagination and validation
This commit is contained in:
@@ -179,6 +179,7 @@ grep -q 'source_kind=SCHEDULE' "$E2E_DIR/schedule.log"
|
||||
printf '%s\n' "[8/8] final console data and logout check"
|
||||
ORBIT_E2E_URL="$E2E_URL" ORBIT_E2E_QUEUE="$E2E_QUEUE" ORBIT_E2E_PASSWORD_FILE="$E2E_PASSWORD_FILE" \
|
||||
ORBIT_E2E_USER="$E2E_ADMIN" python3 - <<'PY'
|
||||
import hashlib
|
||||
import http.cookiejar
|
||||
import json
|
||||
import os
|
||||
@@ -194,10 +195,12 @@ password = pathlib.Path(os.environ["ORBIT_E2E_PASSWORD_FILE"]).read_text(encodin
|
||||
jar = http.cookiejar.CookieJar()
|
||||
client = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
|
||||
|
||||
def request(path, method="GET", body=None):
|
||||
def request(path, method="GET", body=None, headers=None):
|
||||
data = None if body is None else json.dumps(body).encode("utf-8")
|
||||
req = urllib.request.Request(base + path, method=method, data=data)
|
||||
req.add_header("Accept", "application/json")
|
||||
for name, value in (headers or {}).items():
|
||||
req.add_header(name, value)
|
||||
if body is not None:
|
||||
req.add_header("Content-Type", "application/json")
|
||||
try:
|
||||
@@ -213,10 +216,37 @@ assert status == 200, status
|
||||
items = json.loads(body).get("data", {}).get("items", [])
|
||||
assert any(item.get("state") == "SUCCEEDED" for item in items), "no succeeded task visible in console scope"
|
||||
assert any(item.get("handler", "").startswith("text.normalize.runtime.") for item in items)
|
||||
status, body = request("/console/retention")
|
||||
assert status == 200, (status, body)
|
||||
policy = json.loads(body)["data"]
|
||||
assert policy["revision"] == "0" and policy["enabled"] is False
|
||||
update = {key: policy[key] for key in ("enabled", "idempotency_days", "task_history_days", "workflow_history_days", "event_log_days", "delivery_history_days", "inbox_history_days", "audit_log_days")}
|
||||
update.update(expected_revision="0", enabled=True, reason="console retention end-to-end validation")
|
||||
headers = {"Idempotency-Key": "e2e-retention-save"}
|
||||
status, body = request("/console/retention", "PUT", update, headers)
|
||||
assert status == 200 and json.loads(body)["data"]["revision"] == "1", (status, body)
|
||||
status, body = request("/console/retention", "PUT", update, headers)
|
||||
assert status == 200 and json.loads(body)["data"]["revision"] == "1", (status, body)
|
||||
status, _ = request("/console/retention", "PUT", update, {"Idempotency-Key": "e2e-retention-stale"})
|
||||
assert status == 409, status
|
||||
status, body = request("/console/retention/preview")
|
||||
assert status == 200 and len(json.loads(body)["data"]["items"]) == 7, (status, body)
|
||||
status, body = request("/console/retention/export", "POST", {"kind": "tasks", "expected_revision": "1", "limit": 20})
|
||||
assert status == 200, (status, body)
|
||||
snapshot = json.loads(body)["data"]
|
||||
assert snapshot["format_version"] == 1
|
||||
assert hashlib.sha256(snapshot["content"].encode("utf-8")).hexdigest() == snapshot["sha256"]
|
||||
content = json.loads(snapshot["content"])
|
||||
assert content["source_retained"] is True and content["root_count"] == 0
|
||||
status, _ = request("/console/retention/export", "POST", {"kind": "tasks", "expected_revision": "0"})
|
||||
assert status == 409, status
|
||||
print("retention_policy=ok replay=ok stale_revision=409 preview_categories=7 empty_export_digest=ok")
|
||||
status, _ = request("/console/auth/logout", "POST", {})
|
||||
assert status == 200, status
|
||||
status, _ = request("/v1/tasks?" + urllib.parse.urlencode({"queue_id": queue, "limit": 1}))
|
||||
assert status == 401, status
|
||||
status_retention, _ = request("/console/retention")
|
||||
assert status_retention == 401, status_retention
|
||||
print("console_task_data=ok succeeded_tasks=%d logout=ok unauthorized_after_logout=%d" % (sum(item.get("state") == "SUCCEEDED" for item in items), status))
|
||||
PY
|
||||
|
||||
|
||||
Reference in New Issue
Block a user