Skip to content

Commit aadabbd

Browse files
committed
Add tests for ssh user with backslash
1 parent 7b2abb5 commit aadabbd

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/pytests/unit/client/ssh/test_shell.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,18 @@ def test_scp_command_execution_uses_custom_path():
273273
args, _ = mock_run_cmd.call_args
274274
assert "/custom/scp" in args[0]
275275
assert "source_file.txt example.com:/path/dest_file.txt" in args[0]
276+
277+
278+
def test_ssh_using_user_with_backslash():
279+
_shell = shell.Shell(
280+
opts={"_ssh_version": (4, 9)},
281+
host="host.example.org",
282+
user="exampledomain\\user",
283+
passwd="password",
284+
)
285+
with patch.object(
286+
_shell, "_run_cmd", return_value=(None, None, None)
287+
) as mock_run_cmd:
288+
cmd_string = _shell.exec_cmd("whoami")
289+
args, _ = mock_run_cmd.call_args
290+
assert " User='exampledomain\\user' " in args[0]

tests/pytests/unit/client/ssh/test_single.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,3 +958,21 @@ def test_run_integration_with_no_pre_hook(opts, target):
958958
with patch.object(single_instance, "cmd_block", mock_cmd_block):
959959
stdout, stderr, retcode = single_instance.run()
960960
assert retcode == 0
961+
962+
963+
def test_check_thin_dir_with_backslash_user(opts):
964+
"""
965+
Test `thin_dir` path generation for the user with backslash in the name
966+
"""
967+
single = ssh.Single(
968+
opts,
969+
opts["argv"],
970+
"host.example.org",
971+
"host.example.org",
972+
user="exampledomain\\user",
973+
mods={},
974+
fsclient=None,
975+
mine=False,
976+
)
977+
assert single.thin_dir == single.opts["thin_dir"]
978+
assert ".exampledomain_user_" in single.thin_dir

0 commit comments

Comments
 (0)