Files
hermes-agent/tests/hermes_cli/test_windows_ssh_runtime_inventory.py
yoniebans 7f72db17af fix(desktop): read the Windows SSH inventory through the runtime helper
The roster and install-id reads ran Python by rewriting the launcher's bootstrap source, behind their own PowerShell link scan and install-root rule. A link inside any profile directory aborted the whole roster, and a home nested under the install root read its install id from a different directory than the profile list.

Both reads now come from one read-only `inventory` operation of the runtime helper, reached through `--run-module` like every other helper call. It uses the install's own root resolution, profile predicate and identity reader, and creates nothing. The source rewrite and the launcher gate that required its spelling are gone.
2026-10-24 10:28:47 +02:00

54 lines
1.9 KiB
Python

"""Desktop's Windows SSH inventory reads through the canonical root and profile predicate."""
from __future__ import annotations
import os
import pytest
import hermes_constants
from hermes_cli.windows_ssh_runtime import dispatch
def _roster(root):
profiles = root / "profiles"
(profiles / ".deleted").mkdir(parents=True)
(root / "config.yaml").write_text("")
for name in ("bob", "win-research", "ghost", "tombstoned", ".rollback-1", "bad name"):
(profiles / name).mkdir()
if name != "ghost":
(profiles / name / "config.yaml").write_text("")
(profiles / ".deleted" / "tombstoned").write_text("")
return profiles
@pytest.mark.parametrize("pinned", [False, True])
def test_inventory_lists_live_profiles_without_minting_an_identity(monkeypatch, tmp_path, pinned):
root = tmp_path / "state-root"
profiles = _roster(root)
monkeypatch.setenv("HERMES_HOME", str(profiles / "bob" if pinned else root))
result = dispatch(["inventory"])
assert result == {"profiles": ["default", "bob", "win-research"], "installId": None}
assert not (root / "install_id").exists()
@pytest.mark.platforms("posix")
def test_a_link_inside_a_profile_does_not_hide_the_roster(monkeypatch, tmp_path):
root = tmp_path / "state-root"
profiles = _roster(root)
os.symlink(tmp_path, profiles / "bob" / "workspace")
monkeypatch.setenv("HERMES_HOME", str(root))
assert dispatch(["inventory"])["profiles"] == ["default", "bob", "win-research"]
def test_a_nested_home_reads_the_identity_of_its_install_root(monkeypatch, tmp_path):
native = tmp_path / "native"
(native / "work").mkdir(parents=True)
(native / "install_id").write_text("A" * 32 + "\n")
monkeypatch.setattr(hermes_constants, "_get_platform_default_hermes_home", lambda: native)
monkeypatch.setenv("HERMES_HOME", str(native / "work"))
assert dispatch(["inventory"])["installId"] == "a" * 32