Skip to content

Commit 522013a

Browse files
[tests] Improve OpenVPN config regression test #572
- Updated u_path resolution to be independent of cwd. - Quoted sourced path to prevent shell breakage. - Added explicit returncode assertion for better diagnostics. - Addressed final CodeRabbit review feedback. Fixes #572
1 parent 485d006 commit 522013a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/runtests.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,15 @@ def test_create_prefix_users(self):
240240
def test_openvpn_config_whitespace_handling(self):
241241
"""Verify openvpn_config_download handles whitespace."""
242242
import os
243+
import shlex
243244
import subprocess
244245
import tempfile
245246

246247
with tempfile.TemporaryDirectory() as tmpdir:
247-
u_path = os.path.abspath("images/common/utils.sh")
248+
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
249+
u_path = os.path.join(repo_root, "images", "common", "utils.sh")
248250
script = (
249-
f"source {u_path}\n"
251+
f"source {shlex.quote(u_path)}\n"
250252
"curl() { true; }\n"
251253
"tar() { touch 'my vpn with spaces.conf'; }\n"
252254
"chmod() { true; }\n"
@@ -263,6 +265,11 @@ def test_openvpn_config_whitespace_handling(self):
263265
capture_output=True,
264266
text=True,
265267
)
268+
self.assertEqual(
269+
res.returncode,
270+
0,
271+
f"Mock script failed:\nSTDOUT:\n{res.stdout}\nSTDERR:\n{res.stderr}",
272+
)
266273
self.assertIn("PASS", res.stdout)
267274

268275
def test_console_errors(self):

0 commit comments

Comments
 (0)