openshell 0.0.113__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from __future__ import annotations
5
+
6
+ import re
7
+ import subprocess
8
+ import sys
9
+ from pathlib import Path
10
+
11
+
12
+ def test_generate_homebrew_formula_uses_tagged_macos_driver_asset_without_default_driver(
13
+ tmp_path: Path,
14
+ ) -> None:
15
+ release_dir = tmp_path / "release"
16
+ release_dir.mkdir()
17
+ (release_dir / "openshell-checksums-sha256.txt").write_text(
18
+ "\n".join(
19
+ [
20
+ "a" * 64 + " openshell-aarch64-apple-darwin.tar.gz",
21
+ "b" * 64 + " openshell-driver-vm-aarch64-apple-darwin.tar.gz",
22
+ ]
23
+ )
24
+ + "\n",
25
+ encoding="utf-8",
26
+ )
27
+ (release_dir / "openshell-gateway-checksums-sha256.txt").write_text(
28
+ "d" * 64 + " openshell-gateway-aarch64-apple-darwin.tar.gz\n",
29
+ encoding="utf-8",
30
+ )
31
+
32
+ repo_root = Path(__file__).resolve().parents[2]
33
+ output = tmp_path / "openshell.rb"
34
+ subprocess.run(
35
+ [
36
+ sys.executable,
37
+ str(repo_root / "tasks/scripts/release.py"),
38
+ "generate-homebrew-formula",
39
+ "--release-tag",
40
+ "v0.0.10",
41
+ "--release-dir",
42
+ str(release_dir),
43
+ "--output",
44
+ str(output),
45
+ ],
46
+ check=True,
47
+ )
48
+
49
+ formula = output.read_text(encoding="utf-8")
50
+ assert (
51
+ "https://github.com/NVIDIA/OpenShell/releases/download/"
52
+ "v0.0.10/openshell-driver-vm-aarch64-apple-darwin.tar.gz"
53
+ ) in formula
54
+ assert 'sha256 "' + "b" * 64 + '"' in formula
55
+ assert "OPENSHELL_DRIVERS: " not in formula
56
+ assert 'OPENSHELL_GATEWAY_CONFIG: "#{var}/openshell/gateway.toml"' not in formula
57
+ assert "init-gateway-config.sh" not in formula
58
+ assert 'gateway_config = var/"openshell/gateway.toml"' in formula
59
+ assert "unless gateway_config.exist?" in formula
60
+ generated_config = re.search(
61
+ r"gateway_config_contents = <<~TOML\n(?P<contents>.*?)\n TOML",
62
+ formula,
63
+ flags=re.DOTALL,
64
+ )
65
+ assert generated_config is not None
66
+ assert "[openshell.gateway]" in generated_config.group("contents")
67
+ assert "bind_address =" not in generated_config.group("contents")
68
+ assert 'bind_address = "[::1]:17670"' in formula
69
+ assert "gateway_config.read == legacy_ipv6_gateway_config_contents" in formula
70
+ assert "gateway_config.write gateway_config_contents" in formula
71
+ assert '# compute_drivers = ["vm"]' not in formula
72
+ assert (
73
+ "openshell gateway add https://localhost:17670 --local --name openshell"
74
+ in formula
75
+ )
76
+ assert 'run opt_libexec/"openshell-gateway-homebrew-service"' in formula
77
+ assert 'xdg_config_home="${XDG_CONFIG_HOME:-${HOME}/.config}"' in formula
78
+ assert 'xdg_gateway_config="${xdg_config_home}/openshell/gateway.toml"' in formula
79
+ assert 'prefix_gateway_config="#{var}/openshell/gateway.toml"' in formula
80
+ assert (
81
+ 'if [ -z "${OPENSHELL_GATEWAY_CONFIG:-}" ] && [ ! -f "${xdg_gateway_config}" ] && [ -f "${prefix_gateway_config}" ]; then'
82
+ ) in formula
83
+ assert (
84
+ 'exec "#{opt_bin}/openshell-gateway" --config "${prefix_gateway_config}"'
85
+ in formula
86
+ )
87
+ assert 'exec "#{opt_bin}/openshell-gateway"' in formula
88
+ assert "--db-url" not in formula
89
+ assert 'docker_tls_dir="${HOME}/.local/state/openshell/homebrew/tls"' in formula
90
+ assert (
91
+ 'export OPENSHELL_LOCAL_TLS_DIR="${OPENSHELL_LOCAL_TLS_DIR:-${docker_tls_dir}}"'
92
+ in formula
93
+ )
94
+ assert '/usr/bin/install -m 0600 "#{var}/openshell/tls/server/tls.key"' in formula
95
+ assert "OPENSHELL_CONFIG_" not in formula
96
+ assert "OPENSHELL_DOCKER_TLS_DIR" not in formula
97
+ assert 'xdg_gateway_env="${xdg_config_home}/openshell/gateway.env"' in formula
98
+ assert 'prefix_gateway_env="#{var}/openshell/gateway.env"' in formula
99
+ assert '. "${xdg_gateway_env}"' in formula
100
+ assert '. "${prefix_gateway_env}"' in formula
101
+ assert 'gateway_env = var/"openshell/gateway.env"' not in formula
102
+ assert "#OPENSHELL_GATEWAY_CONFIG=#{var}/openshell/gateway.toml" not in formula
103
+ assert "environment_variables(" not in formula
104
+ assert " OPENSHELL_BIND_ADDRESS:" not in formula
105
+ assert " OPENSHELL_SERVER_PORT:" not in formula
106
+ assert " OPENSHELL_TLS_CERT:" not in formula
107
+ assert "OPENSHELL_DRIVER_DIR:" not in formula
108
+ assert "OPENSHELL_DOCKER_SUPERVISOR_IMAGE:" not in formula
109
+ assert 'OPENSHELL_DOCKER_TLS_CA: "#{var}/openshell/tls/ca.crt"' not in formula
110
+ assert "entitlements.atomic_write" in formula
111
+ assert "brew services restart openshell" in formula
112
+
113
+
114
+ def test_snap_wrapper_uses_optional_gateway_config_without_generating_toml() -> None:
115
+ repo_root = Path(__file__).resolve().parents[2]
116
+ wrapper = (repo_root / "tasks/scripts/snap-gateway-wrapper.sh").read_text(
117
+ encoding="utf-8"
118
+ )
119
+
120
+ assert "init-gateway-config.sh" not in wrapper
121
+ assert (
122
+ 'export OPENSHELL_DB_URL="${OPENSHELL_DB_URL:-sqlite:${SNAP_COMMON}/gateway.db?mode=rwc}"'
123
+ in wrapper
124
+ )
125
+ assert 'export OPENSHELL_DISABLE_TLS="${OPENSHELL_DISABLE_TLS:-true}"' in wrapper
126
+ assert (
127
+ 'exec "${SNAP}/bin/openshell-gateway" --config "$CANONICAL_CONFIG_FILE" "$@"'
128
+ in wrapper
129
+ )
130
+ assert 'exec "${SNAP}/bin/openshell-gateway" "$@"' in wrapper
131
+
132
+
133
+ def test_rpm_spec_uses_gateway_defaults_without_config_helper() -> None:
134
+ repo_root = Path(__file__).resolve().parents[2]
135
+ spec = (repo_root / "openshell.spec").read_text(encoding="utf-8")
136
+
137
+ assert "init-gateway-config.sh" not in spec
138
+ assert "init-pki.sh" not in spec
139
+ assert "Environment=OPENSHELL_LOCAL_TLS_DIR=%%h/.local/state/openshell/tls" in spec
140
+ assert (
141
+ "openshell-gateway generate-certs --output-dir ${OPENSHELL_LOCAL_TLS_DIR}"
142
+ in spec
143
+ )
144
+ assert "EnvironmentFile=-%%E/openshell/gateway.env" in spec
145
+ assert "%%S/openshell/tls" not in spec
146
+ assert "Environment=OPENSHELL_DRIVERS" not in spec
147
+ assert "Environment=OPENSHELL_BIND_ADDRESS" not in spec
148
+ assert "Environment=OPENSHELL_PODMAN_TLS_CA" not in spec
149
+ assert "ExecStart=/usr/bin/openshell-gateway" in spec
150
+ assert "--config" not in spec
151
+ assert "--db-url" not in spec
152
+
153
+
154
+ def test_deb_user_service_uses_gateway_defaults_without_config_helper() -> None:
155
+ repo_root = Path(__file__).resolve().parents[2]
156
+ unit = (repo_root / "deploy/deb/openshell-gateway.service").read_text(
157
+ encoding="utf-8"
158
+ )
159
+
160
+ assert "EnvironmentFile=-%E/openshell/gateway.env" in unit
161
+ assert "Environment=OPENSHELL_LOCAL_TLS_DIR=%h/.local/state/openshell/tls" in unit
162
+ assert (
163
+ "openshell-gateway generate-certs --output-dir ${OPENSHELL_LOCAL_TLS_DIR}"
164
+ in unit
165
+ )
166
+ assert "%S/openshell/tls" not in unit
167
+ assert "init-gateway-config.sh" not in unit
168
+ assert "ExecStart=/usr/bin/openshell-gateway" in unit
169
+ assert "--config" not in unit
170
+ assert "--db-url" not in unit