style(host-agent): format Console task submission files
This commit is contained in:
@@ -492,9 +492,7 @@ def create_console_app(
|
|||||||
"title": "Tasks",
|
"title": "Tasks",
|
||||||
"session": session,
|
"session": session,
|
||||||
"csrf_token": session.csrf_token,
|
"csrf_token": session.csrf_token,
|
||||||
"tasks": metadata_store.list_tasks()
|
"tasks": metadata_store.list_tasks() if metadata_store is not None else [],
|
||||||
if metadata_store is not None
|
|
||||||
else [],
|
|
||||||
"metadata_store_missing": metadata_store is None,
|
"metadata_store_missing": metadata_store is None,
|
||||||
"devices": devices,
|
"devices": devices,
|
||||||
"automatic_device_value": AUTOMATIC_DEVICE_VALUE,
|
"automatic_device_value": AUTOMATIC_DEVICE_VALUE,
|
||||||
@@ -603,9 +601,7 @@ def create_console_app(
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await submit_self_task(
|
response = await submit_self_task(goal=goal, device_id=explicit_device_id)
|
||||||
goal=goal, device_id=explicit_device_id
|
|
||||||
)
|
|
||||||
except HostAgentAPIError as exc:
|
except HostAgentAPIError as exc:
|
||||||
context = _tasks_list_context(
|
context = _tasks_list_context(
|
||||||
session,
|
session,
|
||||||
|
|||||||
@@ -93,17 +93,14 @@ def test_history_store_records_task_submission_without_device(tmp_path) -> None:
|
|||||||
|
|
||||||
entries = store.list_recent()
|
entries = store.list_recent()
|
||||||
|
|
||||||
assert entries[0]["summary"] == (
|
assert entries[0]["summary"] == ("task submitted: task-cloud-2 (automatic device)")
|
||||||
"task submitted: task-cloud-2 (automatic device)"
|
|
||||||
)
|
|
||||||
assert entries[0]["detail"] == {"task_id": "task-cloud-2"}
|
assert entries[0]["detail"] == {"task_id": "task-cloud-2"}
|
||||||
|
|
||||||
|
|
||||||
def test_history_store_task_submission_redacts_goal_and_secrets(tmp_path) -> None:
|
def test_history_store_task_submission_redacts_goal_and_secrets(tmp_path) -> None:
|
||||||
store = ConsoleHistoryStore(tmp_path / "history.sqlite3")
|
store = ConsoleHistoryStore(tmp_path / "history.sqlite3")
|
||||||
secret_goal = (
|
secret_goal = (
|
||||||
"rotate secret-XYZ-abcdef-very-secret "
|
"rotate secret-XYZ-abcdef-very-secret cookie=session-abc; lease=lease-stale"
|
||||||
"cookie=session-abc; lease=lease-stale"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
store.record_task_submission(task_id="task-cloud-3", device_id="device-cloud-a")
|
store.record_task_submission(task_id="task-cloud-3", device_id="device-cloud-a")
|
||||||
@@ -111,8 +108,7 @@ def test_history_store_task_submission_redacts_goal_and_secrets(tmp_path) -> Non
|
|||||||
|
|
||||||
entries = store.list_recent()
|
entries = store.list_recent()
|
||||||
rendered = "\n".join(
|
rendered = "\n".join(
|
||||||
repr(entry["summary"]) + " " + json.dumps(entry["detail"])
|
repr(entry["summary"]) + " " + json.dumps(entry["detail"]) for entry in entries
|
||||||
for entry in entries
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert secret_goal not in rendered
|
assert secret_goal not in rendered
|
||||||
@@ -135,4 +131,4 @@ def test_history_store_task_submissions_prune_beyond_limit(tmp_path) -> None:
|
|||||||
"task-4",
|
"task-4",
|
||||||
"task-3",
|
"task-3",
|
||||||
"task-2",
|
"task-2",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -49,9 +49,7 @@ def _build_client(
|
|||||||
session_manager = SessionManager(ttl_seconds=3600.0)
|
session_manager = SessionManager(ttl_seconds=3600.0)
|
||||||
metadata_store: TaskMetadataStore | None = None
|
metadata_store: TaskMetadataStore | None = None
|
||||||
if include_metadata_store:
|
if include_metadata_store:
|
||||||
metadata_store = TaskMetadataStore(
|
metadata_store = TaskMetadataStore(db_path=tmp_path / "task_metadata.sqlite3")
|
||||||
db_path=tmp_path / "task_metadata.sqlite3"
|
|
||||||
)
|
|
||||||
|
|
||||||
app = create_console_app(
|
app = create_console_app(
|
||||||
config=config,
|
config=config,
|
||||||
@@ -373,7 +371,11 @@ def _make_submission_recorder(
|
|||||||
def asyncio_run(coro):
|
def asyncio_run(coro):
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
return asyncio.get_event_loop().run_until_complete(coro) if asyncio.get_event_loop().is_running() else asyncio.run(coro)
|
return (
|
||||||
|
asyncio.get_event_loop().run_until_complete(coro)
|
||||||
|
if asyncio.get_event_loop().is_running()
|
||||||
|
else asyncio.run(coro)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_tasks_page_renders_submission_form_with_device_options(tmp_path) -> None:
|
def test_tasks_page_renders_submission_form_with_device_options(tmp_path) -> None:
|
||||||
@@ -444,8 +446,7 @@ def test_authenticated_explicit_device_submission_uses_runtime_id(tmp_path) -> N
|
|||||||
|
|
||||||
assert response.status_code == 303
|
assert response.status_code == 303
|
||||||
assert (
|
assert (
|
||||||
response.headers["location"]
|
response.headers["location"] == "/tasks?submitted=1&task_id=task-cloud-explicit"
|
||||||
== "/tasks?submitted=1&task_id=task-cloud-explicit"
|
|
||||||
)
|
)
|
||||||
assert captured == {"goal": "open mail", "device_id": "device-cloud-a"}
|
assert captured == {"goal": "open mail", "device_id": "device-cloud-a"}
|
||||||
|
|
||||||
@@ -577,9 +578,7 @@ def test_cloud_definitive_rejection_renders_safe_error_without_calling_history(
|
|||||||
tmp_path,
|
tmp_path,
|
||||||
) -> None:
|
) -> None:
|
||||||
submit, captured = _make_submission_recorder(
|
submit, captured = _make_submission_recorder(
|
||||||
raise_api_error=HostAgentAPIError(
|
raise_api_error=HostAgentAPIError(403, "Host self-submission is disabled"),
|
||||||
403, "Host self-submission is disabled"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
client, context = _build_client(tmp_path, submit_self_task=submit)
|
client, context = _build_client(tmp_path, submit_self_task=submit)
|
||||||
context["manager"].register_device(
|
context["manager"].register_device(
|
||||||
|
|||||||
Reference in New Issue
Block a user