Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

test(sql): deleting a harness must not leave the database password on disk

richard-epsilla97488cc163d8
diff --git a/gateway/tests/test_sql_datasource.py b/gateway/tests/test_sql_datasource.py
index 97d4af8b..321b2f3e 100644
--- a/gateway/tests/test_sql_datasource.py
+++ b/gateway/tests/test_sql_datasource.py
@@ -165,6 +165,19 @@ def test_disconnecting_removes_the_record(api, harness):
assert q.status_code == 404 and q.json()["error"]["code"] == "datasource_not_connected"
+def test_deleting_the_harness_does_not_leave_the_credential_behind(api, harness):
+ """The most decisive thing the UI offers must not leave a production password on disk."""
+ api.put(f"/v1/harnesses/{harness}/datasource",
+ json={"engine": "postgres", "connection_string": PG_DSN})
+ stored = next(iter(Path(_DATA, "secrets").rglob(app._ds_secret_key(harness))))
+ assert PG_DSN == asyncio.run(app.BACKING.secrets.get(app._tenants_for(ORG)[0], app._ds_secret_key(harness)))
+
+ assert api.delete(f"/v1/harnesses/{harness}").json()["deleted"] is True
+ # The file may remain (the store has no delete); what it holds must not.
+ assert not asyncio.run(app.BACKING.secrets.get(app._tenants_for(ORG)[0], app._ds_secret_key(harness)))
+ assert PASSWORD not in stored.read_text()
+
+
def test_another_org_cannot_see_or_use_a_datasource(client, harness, api):
api.put(f"/v1/harnesses/{harness}/datasource",
json={"engine": "postgres", "connection_string": PG_DSN})