fix(qa11): use relative version checks for idempotent runs
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
Some checks failed
Aegis CI / lint-and-test (push) Has been cancelled
This commit is contained in:
@@ -102,8 +102,9 @@ def main():
|
|||||||
check("POST /knowledge/playbooks (detect) → 201", r.status_code == 201,
|
check("POST /knowledge/playbooks (detect) → 201", r.status_code == 201,
|
||||||
r.text[:150])
|
r.text[:150])
|
||||||
pb1 = r.json() if r.status_code == 201 else {}
|
pb1 = r.json() if r.status_code == 201 else {}
|
||||||
|
pb1_start_version = pb1.get("version", 1)
|
||||||
check("Playbook has id", bool(pb1.get("id")))
|
check("Playbook has id", bool(pb1.get("id")))
|
||||||
check("Playbook version = 1", pb1.get("version") == 1)
|
check("Playbook version is integer ≥ 1", pb1_start_version >= 1)
|
||||||
check("Playbook tools list", pb1.get("tools") == ["Splunk", "Sigma"])
|
check("Playbook tools list", pb1.get("tools") == ["Splunk", "Sigma"])
|
||||||
|
|
||||||
r = requests.post(f"{BASE}/knowledge/playbooks", headers=h, json={
|
r = requests.post(f"{BASE}/knowledge/playbooks", headers=h, json={
|
||||||
@@ -180,15 +181,19 @@ def main():
|
|||||||
check("PATCH /knowledge/playbooks/{id} → 200", r.status_code == 200,
|
check("PATCH /knowledge/playbooks/{id} → 200", r.status_code == 200,
|
||||||
r.text[:120])
|
r.text[:120])
|
||||||
pb1_v2 = r.json() if r.status_code == 200 else {}
|
pb1_v2 = r.json() if r.status_code == 200 else {}
|
||||||
check("Version incremented to 2", pb1_v2.get("version") == 2)
|
expected_v2 = pb1_start_version + 1
|
||||||
|
check(f"Version incremented to {expected_v2}",
|
||||||
|
pb1_v2.get("version") == expected_v2)
|
||||||
check("Content updated", "Sysmon" in pb1_v2.get("content", ""))
|
check("Content updated", "Sysmon" in pb1_v2.get("content", ""))
|
||||||
check("Tools updated (3 items)", len(pb1_v2.get("tools", [])) == 3)
|
check("Tools updated (3 items)", len(pb1_v2.get("tools", [])) == 3)
|
||||||
|
|
||||||
r = requests.patch(f"{BASE}/knowledge/playbooks/{pb1_id}", headers=h, json={
|
r = requests.patch(f"{BASE}/knowledge/playbooks/{pb1_id}", headers=h, json={
|
||||||
"title": "Detection Playbook v3",
|
"title": "Detection Playbook v+3",
|
||||||
"change_note": "Renamed",
|
"change_note": "Renamed",
|
||||||
})
|
})
|
||||||
check("PATCH again → version 3", r.json().get("version") == 3
|
expected_v3 = pb1_start_version + 2
|
||||||
|
check(f"PATCH again → version {expected_v3}",
|
||||||
|
r.json().get("version") == expected_v3
|
||||||
if r.status_code == 200 else False)
|
if r.status_code == 200 else False)
|
||||||
|
|
||||||
# List versions
|
# List versions
|
||||||
@@ -207,7 +212,8 @@ def main():
|
|||||||
r = requests.post(f"{BASE}/knowledge/playbooks/{pb1_id}/restore/1", headers=h)
|
r = requests.post(f"{BASE}/knowledge/playbooks/{pb1_id}/restore/1", headers=h)
|
||||||
check("POST /restore/1 → 200", r.status_code == 200, r.text[:120])
|
check("POST /restore/1 → 200", r.status_code == 200, r.text[:120])
|
||||||
restored = r.json() if r.status_code == 200 else {}
|
restored = r.json() if r.status_code == 200 else {}
|
||||||
check("Version incremented after restore", restored.get("version", 0) >= 4)
|
check("Version incremented after restore",
|
||||||
|
restored.get("version", 0) >= pb1_start_version + 3)
|
||||||
check("Content restored to v1 content",
|
check("Content restored to v1 content",
|
||||||
"Sysmon" not in restored.get("content", ""))
|
"Sysmon" not in restored.get("content", ""))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user