Files
wehub-resource-sync b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:56:03 +08:00

45 lines
1.4 KiB
Python

"""Regression tests for gateway SSL certificate environment repair."""
from types import SimpleNamespace
def test_ensure_ssl_certs_ignores_stale_ssl_cert_file(monkeypatch, tmp_path):
"""A missing SSL_CERT_FILE should be treated as unset, not trusted."""
import ssl
import sys
from gateway.run import _ensure_ssl_certs
cert_file = tmp_path / "cacert.pem"
cert_file.write_text("dummy cert bundle", encoding="utf-8")
stale_file = tmp_path / "missing.pem"
monkeypatch.setenv("SSL_CERT_FILE", str(stale_file))
monkeypatch.setattr(
ssl,
"get_default_verify_paths",
lambda: SimpleNamespace(cafile=None, openssl_cafile=None),
)
monkeypatch.setitem(
sys.modules,
"certifi",
SimpleNamespace(where=lambda: str(cert_file)),
)
_ensure_ssl_certs()
assert stale_file.exists() is False
assert __import__("os").environ["SSL_CERT_FILE"] == str(cert_file)
def test_ensure_ssl_certs_keeps_existing_ssl_cert_file(monkeypatch, tmp_path):
"""A valid user-provided SSL_CERT_FILE must not be overwritten."""
from gateway.run import _ensure_ssl_certs
cert_file = tmp_path / "existing.pem"
cert_file.write_text("dummy cert bundle", encoding="utf-8")
monkeypatch.setenv("SSL_CERT_FILE", str(cert_file))
_ensure_ssl_certs()
assert __import__("os").environ["SSL_CERT_FILE"] == str(cert_file)