💫 Toolkit to help you get started with SDD or any other process!
feat: report the OpenSSL runtime in `specify version` (#4556)
yi111abbbede7c629
diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.pyindex cfcc51e35..ccc2be67f 100644--- a/src/specify_cli/__init__.py+++ b/src/specify_cli/__init__.py@@ -498,6 +498,18 @@ def version(info_table.add_row("Platform", platform.system())info_table.add_row("Architecture", platform.machine())info_table.add_row("OS Version", platform.version())+ # The OpenSSL runtime the interpreter actually loaded. HTTPS failure+ # reports (#4433) hinge on which OpenSSL is in play, and on Windows it is+ # not obvious from the outside, so surface it here. An interpreter built+ # without the ssl extension skips the row rather than failing the command.+ try:+ import ssl++ openssl_version = getattr(ssl, "OPENSSL_VERSION", "")+ except ImportError:+ openssl_version = ""+ if openssl_version:+ info_table.add_row("OpenSSL", openssl_version)panel = Panel(info_table,diff --git a/tests/test_cli_version.py b/tests/test_cli_version.pyindex 041ff62e5..3d8d54bae 100644--- a/tests/test_cli_version.py+++ b/tests/test_cli_version.py@@ -1,8 +1,11 @@"""Tests for CLI version reporting."""import json+import sys+from types import SimpleNamespacefrom unittest.mock import patch+import pytestfrom typer.testing import CliRunnerfrom specify_cli import app@@ -77,3 +80,59 @@ class TestVersionCommand:assert result.exit_code != 0assert "--json requires --features" in result.output++ def test_version_reports_openssl_runtime(self):+ """specify version reports the OpenSSL runtime the interpreter loaded.++ Regression test for the triage gap in #4433: HTTPS failures on Windows+ are commonly blamed on a PATH-preceded OpenSSL DLL, but ``specify+ version`` reported no OpenSSL information at all, so a report had no way+ to show which runtime was actually in use.+ """+ ssl = pytest.importorskip("ssl")++ with patch("specify_cli.get_speckit_version", return_value="1.2.3"):+ result = runner.invoke(app, ["version"])++ assert result.exit_code == 0++ expected = ssl.OPENSSL_VERSION+ assert expected, "test host reports no ssl.OPENSSL_VERSION to assert against"+ assert expected in result.output++ def test_version_skips_openssl_row_when_ssl_unavailable(self, monkeypatch):+ """An interpreter built without the ssl extension skips the OpenSSL row.++ ``sys.modules["ssl"] = None`` makes ``import ssl`` raise ImportError,+ simulating a build without ``_ssl``. The command must still succeed —+ only the OpenSSL row is omitted.+ """+ monkeypatch.setitem(sys.modules, "ssl", None)+ with patch("specify_cli.get_speckit_version", return_value="1.2.3"):+ result = runner.invoke(app, ["version"])++ assert result.exit_code == 0+ assert "OpenSSL" not in result.output++ def test_version_skips_openssl_row_when_version_attr_missing(self, monkeypatch):+ """An ssl module without OPENSSL_VERSION also skips the row.++ The implementation reads ``getattr(ssl, "OPENSSL_VERSION", "")``, so an+ importable ssl that lacks the attribute must omit the row rather than+ raise AttributeError.+ """+ monkeypatch.setitem(sys.modules, "ssl", SimpleNamespace())+ with patch("specify_cli.get_speckit_version", return_value="1.2.3"):+ result = runner.invoke(app, ["version"])++ assert result.exit_code == 0+ assert "OpenSSL" not in result.output++ def test_version_features_never_touches_ssl(self, monkeypatch):+ """--features/--json return early and must not require ssl at all."""+ monkeypatch.setitem(sys.modules, "ssl", None)+ with patch("specify_cli.get_speckit_version", return_value="1.2.3"):+ result = runner.invoke(app, ["version", "--features", "--json"])++ assert result.exit_code == 0+ assert json.loads(result.output)["version"] == "1.2.3"