The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: trim salvaged SSL/config unit tests to two invariants each; flip the #124654 and #119928 E2E gates
teknium186f20a367a9e
diff --git a/tests/e2e/core/upgrade/network/test_proxy_only_egress.py b/tests/e2e/core/upgrade/network/test_proxy_only_egress.pyindex ad9c009a553..3afb1f91957 100644--- a/tests/e2e/core/upgrade/network/test_proxy_only_egress.py+++ b/tests/e2e/core/upgrade/network/test_proxy_only_egress.py@@ -19,7 +19,6 @@ import shutilimport pytest-from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.upgrade import _helpers as Hfrom tests.e2e.core.upgrade import _install_helpers as Ifrom tests.e2e.core.upgrade.network import _netedge as N@@ -94,13 +93,7 @@ def test_update_with_corporate_root_only_in_ssl_cert_file(inst):r = inst.hermes("update", "--yes", edge=edge, corporate_root=False, env={"SSL_CERT_FILE": str(bundle)})finally:edge.close()- with known_failure(- r"unable to access 'https://github\.com/NousResearch/hermes-agent\.git/': "- r"(SSL certificate|server certificate verification failed|SSL certificate problem)",- "gated on #124654: the updater's git fetch ignores SSL_CERT_FILE, so a corporate root "- "supplied that way passes the channel read and then fails at `Fetching updates`",- ):- _assert_updated_through_proxy(inst, r, new)+ _assert_updated_through_proxy(inst, r, new)def test_tunnel_cut_to_channel_host_fails_fast_and_changes_nothing(inst):diff --git a/tests/e2e/core/upgrade/test_config_roundtrip_properties.py b/tests/e2e/core/upgrade/test_config_roundtrip_properties.pyindex 4d7008811d3..8192f5caa56 100644--- a/tests/e2e/core/upgrade/test_config_roundtrip_properties.py+++ b/tests/e2e/core/upgrade/test_config_roundtrip_properties.py@@ -21,10 +21,6 @@ A seeded property / matrix layer over every surface that writes ``config.yaml``Generators are ``random.Random(seed)`` over a fixed seed list (hypothesis is not a dependency);every assertion message carries the seed / case so a failure is reproducible with ``-k``.--Cells for a live gap are merge-order safe: they XFAIL only while they fail with that gap's own-message (``tests/e2e/core/_pending_fixes.known_failure``), fail loudly on anything else, and pass as-plain tests once the fix lands."""from __future__ import annotations@@ -49,7 +45,6 @@ from typing import Any, Callable, Iterableimport pytestimport hermes_yaml as yaml-from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.upgrade._helpers import WORKTREE, isolated_envimport hermes_cli.config as C@@ -641,13 +636,10 @@ def test_p2_env_lock_refusal_is_not_reported_as_success(key, tmp_path):env_before = _read(hh / ".env")r = _cli(env, "config", "set", key, "c18-new")wrote = _read(hh / ".env") != env_before- with known_failure(r"^`config set \w+` exit=0 but \.env unchanged|^a refused env write still rewrote config\.yaml",- "#119928 (fix PR #119929): when the managed-scope .env pins a key, `hermes config set` "- "prints the refusal, then '✓ Set', exits 0, and the credential route still rewrites config.yaml"):- assert (r.returncode == 0) == wrote, (- f"`config set {key}` exit={r.returncode} but .env {'changed' if wrote else 'unchanged'}:\n{r.stdout}{r.stderr}")- if not wrote:- assert _read(hh / "config.yaml") == cfg_text, "a refused env write still rewrote config.yaml"+ assert (r.returncode == 0) == wrote, (+ f"`config set {key}` exit={r.returncode} but .env {'changed' if wrote else 'unchanged'}:\n{r.stdout}{r.stderr}")+ if not wrote:+ assert _read(hh / "config.yaml") == cfg_text, "a refused env write still rewrote config.yaml"# ── real tui_gateway stdio JSON-RPC process ──────────────────────────────────diff --git a/tests/hermes_cli/test_managed_scope_writeguard.py b/tests/hermes_cli/test_managed_scope_writeguard.pyindex 51f427e1712..6d894c3ace2 100644--- a/tests/hermes_cli/test_managed_scope_writeguard.py+++ b/tests/hermes_cli/test_managed_scope_writeguard.py@@ -113,25 +113,6 @@ def _assert_user_stores_untouched(home, before):assert _user_stores(home) == before[email protected]("command, args", [- pytest.param("set", ("DEEPSEEK_API_KEY", NEW_KEY), id="set-credential"),- pytest.param("set", ("TELEGRAM_HOME_CHANNEL", "999"), id="set-env-setting"),- pytest.param("unset", ("DEEPSEEK_API_KEY",), id="unset-credential"),- pytest.param("unset", ("TELEGRAM_HOME_CHANNEL",), id="unset-env-setting"),-])-def test_config_set_unset_of_pinned_env_key_exits_nonzero_and_writes_nothing(pinned_env, capsys, command, args):- from hermes_cli.config import set_config_value, unset_config_value-- home, before = pinned_env- with pytest.raises(SystemExit) as exc:- (set_config_value if command == "set" else unset_config_value)(*args)- assert exc.value.code == 1- out = capsys.readouterr()- assert "managed by your administrator" in out.err- assert "✓" not in out.out- _assert_user_stores_untouched(home, before)--@pytest.mark.parametrize("method", ["PUT", "DELETE"])@pytest.mark.parametrize("lock, refusal", [pytest.param("scope", "managed by your administrator", id="managed-scope"),@@ -199,17 +180,6 @@ def test_disconnect_on_a_package_managed_install_still_clears_the_auth_store(antassert "anthropic" not in json.loads((home / "auth.json").read_text(encoding="utf-8"))["credential_pool"]-def test_disconnect_refuses_a_pinned_key_before_removing_any_other(anthropic_homes):- home, managed, reload = anthropic_homes- (managed / ".env").write_text(f"ANTHROPIC_TOKEN={ADMIN_KEY}\n", encoding="utf-8")- (home / ".env").write_text(f"ANTHROPIC_API_KEY={OLD_KEY}\n", encoding="utf-8")- reload()- before = {name: (home / name).read_text(encoding="utf-8") for name in (".env", "auth.json")}- resp = _disconnect("anthropic")- assert "managed by your administrator" in resp.get("error", {}).get("message", ""), resp- assert {name: (home / name).read_text(encoding="utf-8") for name in (".env", "auth.json")} == before--# ── bulk save strips managed leaves ──────────────────────────────────────────diff --git a/tests/hermes_cli/test_update_ssl_cert_file.py b/tests/hermes_cli/test_update_ssl_cert_file.pyindex 5f445311c02..a51be656ff0 100644--- a/tests/hermes_cli/test_update_ssl_cert_file.py+++ b/tests/hermes_cli/test_update_ssl_cert_file.py@@ -1,87 +1,36 @@-"""SSL_CERT_FILE → GIT_SSL_CAINFO mapping for the updater's git children.+"""SSL_CERT_FILE → GIT_SSL_CAINFO for the updater's git children (#124654).-git's libcurl ignores ``SSL_CERT_FILE``: GnuTLS builds do, and so do OpenSSL-builds with a compiled-in CA path. git reads only ``GIT_SSL_CAINFO`` /-``http.sslCAInfo``. Behind a TLS-inspecting proxy whose corporate root lives-only in ``SSL_CERT_FILE``, the channel read (Python honors it) succeeded and-the very next ``git fetch`` failed with "certificate signer not trusted",-reported as a "Network error". The updater must keep one CA story across all-of its git children — including the partial-clone checkout's lazy promisor-fetches, which inherit the process environment rather than-``_no_prompt_git_kwargs``.+git's libcurl ignores ``SSL_CERT_FILE``; behind a TLS-inspecting proxy whose root lives only+there, the channel read (Python) passed and the next ``git fetch`` failed. The mapping lands in+``os.environ`` so the partial clone's lazy promisor fetches inherit it too."""+import osimport subprocessfrom hermes_cli import update_cmd-def _git_config_reader(configured: str | None):- """A ``git`` double answering ``config --get http.sslCAInfo``."""- calls = []-+def _git_config(configured: str | None):def run(cmd, args, **kwargs):- calls.append(args)- if args[:3] == ["config", "--get", "http.sslCAInfo"]:- out = configured if configured is not None else ""- return subprocess.CompletedProcess(cmd, 0 if configured else 1, out, "")- raise AssertionError(f"unexpected git call: {args}")-- return run, calls---class TestMapSslCertFileForGit:- def test_maps_when_only_ssl_cert_file_is_set(self, monkeypatch, tmp_path):- monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "corp-bundle.pem"))- monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)- run, _ = _git_config_reader(None)- monkeypatch.setattr(update_cmd, "_git_run", run)- update_cmd._map_ssl_cert_file_for_git(["git"])- import os- assert os.environ["GIT_SSL_CAINFO"] == str(tmp_path / "corp-bundle.pem")-- def test_explicit_git_ssl_cainfo_wins(self, monkeypatch, tmp_path):- monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "corp-bundle.pem"))- monkeypatch.setenv("GIT_SSL_CAINFO", str(tmp_path / "git-pinned.pem"))- run, calls = _git_config_reader(None)- monkeypatch.setattr(update_cmd, "_git_run", run)- update_cmd._map_ssl_cert_file_for_git(["git"])- import os- assert os.environ["GIT_SSL_CAINFO"] == str(tmp_path / "git-pinned.pem")- assert calls == [] # the env pin short-circuits before git is consulted-- def test_configured_http_sslcainfo_is_not_overridden(self, monkeypatch, tmp_path):- monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "corp-bundle.pem"))- monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)- run, _ = _git_config_reader(str(tmp_path / "configured.pem"))- monkeypatch.setattr(update_cmd, "_git_run", run)- update_cmd._map_ssl_cert_file_for_git(["git"])- import os- assert "GIT_SSL_CAINFO" not in os.environ-- def test_noop_without_ssl_cert_file(self, monkeypatch):- monkeypatch.delenv("SSL_CERT_FILE", raising=False)- monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)- run, calls = _git_config_reader(None)- monkeypatch.setattr(update_cmd, "_git_run", run)- update_cmd._map_ssl_cert_file_for_git(["git"])- import os- assert "GIT_SSL_CAINFO" not in os.environ- assert calls == [] # nothing to map — git is never consulted-- def test_mapped_bundle_reaches_network_git_children(self, monkeypatch, tmp_path):- """The mapping is live in the env of a network git call made after it."""- import os- monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "corp-bundle.pem"))- monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)-- def run(cmd, args, **kwargs):- if args[:3] == ["config", "--get", "http.sslCAInfo"]:- return subprocess.CompletedProcess(cmd, 1, "", "")- return subprocess.CompletedProcess(cmd, 0, "", "")-- monkeypatch.setattr(update_cmd, "_git_run", run)- update_cmd._map_ssl_cert_file_for_git(["git"])- kw = update_cmd._no_prompt_git_kwargs()- assert kw["env"]["GIT_SSL_CAINFO"] == str(tmp_path / "corp-bundle.pem")- assert os.environ["GIT_SSL_CAINFO"] == str(tmp_path / "corp-bundle.pem")+ assert args[:3] == ["config", "--get", "http.sslCAInfo"], args+ return subprocess.CompletedProcess(cmd, 0 if configured else 1, configured or "", "")+ return run+++def test_ssl_cert_file_reaches_network_git_children(monkeypatch, tmp_path):+ bundle = str(tmp_path / "corp-bundle.pem")+ monkeypatch.setenv("SSL_CERT_FILE", bundle)+ monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)+ monkeypatch.setattr(update_cmd, "_git_run", _git_config(None))+ update_cmd._map_ssl_cert_file_for_git(["git"])+ assert update_cmd._no_prompt_git_kwargs()["env"]["GIT_SSL_CAINFO"] == bundle+ assert os.environ["GIT_SSL_CAINFO"] == bundle+++def test_configured_git_ca_is_not_overridden(monkeypatch, tmp_path):+ monkeypatch.setenv("SSL_CERT_FILE", str(tmp_path / "corp-bundle.pem"))+ monkeypatch.delenv("GIT_SSL_CAINFO", raising=False)+ monkeypatch.setattr(update_cmd, "_git_run", _git_config(str(tmp_path / "configured.pem")))+ update_cmd._map_ssl_cert_file_for_git(["git"])+ assert "GIT_SSL_CAINFO" not in os.environ