fix(backend): expose c2_task.source in GET /c2/tasks response
Serialize source as t.source.value (string) in list_simulation_tasks. Updated test_c2_tasks_list shape assertion to include 'source' and assert value is 'mimic' for execute-created tasks. Added test in test_c2_import to assert source='import' in GET /c2/tasks after import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -282,6 +282,25 @@ class TestImportHappyPath:
|
||||
resp = _import(client, redteam_token, sim["id"], [100])
|
||||
assert resp.status_code == 200
|
||||
|
||||
def test_source_field_is_import_in_tasks_listing(
|
||||
self, monkeypatch, client: FlaskClient, admin_token: str
|
||||
) -> None:
|
||||
"""Imported tasks appear with source='import' in GET /c2/tasks response."""
|
||||
_make_completed_get_task(monkeypatch)
|
||||
eng = _make_engagement(client, admin_token)
|
||||
_put_config(client, admin_token, eng["id"])
|
||||
sim = _make_sim(client, admin_token, eng["id"])
|
||||
|
||||
_import(client, admin_token, sim["id"], [100])
|
||||
|
||||
resp = client.get(
|
||||
f"/api/simulations/{sim['id']}/c2/tasks",
|
||||
headers=_h(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
task = resp.get_json()["tasks"][0]
|
||||
assert task["source"] == "import"
|
||||
|
||||
def test_no_transition_when_all_skipped(
|
||||
self, app: Flask, monkeypatch, client: FlaskClient, admin_token: str
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user