diff --git a/tests/test_app.py b/tests/test_app.py index c9f8e63..dc5f072 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -42,7 +42,7 @@ def test_health_exposes_current_version(): with TestClient(app.app) as client: response = client.get("/health") assert response.status_code == 200 - assert response.json()["version"] == app.VERSION == "2.3.0" + assert response.json()["version"] == app.VERSION == "2.3.1" def test_invalid_log_target_is_rejected_before_ssh(): @@ -145,6 +145,24 @@ def test_backup_item_reports_age_and_severity(): assert app._backup_item(1, "", "timeout")["state"] == "unknown" +def test_ssh_uses_writable_runtime_known_hosts(monkeypatch): + captured = {} + + class Result: + returncode = 0 + stdout = "ok" + stderr = "" + + def fake_run(args, **_kwargs): + captured["args"] = args + return Result() + + monkeypatch.setattr(app._sp, "run", fake_run) + assert app._ssh("sascha@example", "true", timeout=1)[0] == 0 + joined = " ".join(captured["args"]) + assert "UserKnownHostsFile=/tmp/butler_known_hosts" in joined + + def test_ssh_timeout_is_normalized_instead_of_crashing_collection(monkeypatch): def timeout(*_args, **_kwargs): raise app._sp.TimeoutExpired(cmd=["ssh"], timeout=1)