diff options
author | Anders Björklund <anders.bjorklund.2@volvocars.com> | 2020-02-18 14:08:35 +0100 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-04-15 06:51:22 +0000 |
commit | 8e0fe1920eee959ad14225ad2327793371be05d1 (patch) | |
tree | db8cb7e6cf088cdcd5fdd411c75ea62ccc51f27c /tests/test_git_command.py | |
parent | d086467012e1970f44f27b67b4296a2a6fb097d5 (diff) | |
download | git-repo-8e0fe1920eee959ad14225ad2327793371be05d1.tar.gz |
Use hash for ControlPath instead of full variables
The generated socket path can be too long, if your FQDN is very long...
Typical error message from ssh client:
unix_listener: path "/tmp/ssh-fqduawon/master-USER@HOST:PORT.qfCZ51OAZgTzVLbg" too long for Unix domain socket
Use a hashed version instead, to keep within the socket file path limit.
This requires OpenSSH_6.7p1, or later.
Change-Id: Ia4bb9ae8aac6c4ee31d5a458f917f3753f40001b
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255632
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Anders Björklund <anders.bjorklund.2@volvocars.com>
Diffstat (limited to 'tests/test_git_command.py')
-rw-r--r-- | tests/test_git_command.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_git_command.py b/tests/test_git_command.py index c2d3f1df..2c22b250 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py | |||
@@ -30,6 +30,33 @@ import git_command | |||
30 | import wrapper | 30 | import wrapper |
31 | 31 | ||
32 | 32 | ||
33 | class SSHUnitTest(unittest.TestCase): | ||
34 | """Tests the ssh functions.""" | ||
35 | |||
36 | def test_ssh_version(self): | ||
37 | """Check ssh_version() handling.""" | ||
38 | ver = git_command._parse_ssh_version('Unknown\n') | ||
39 | self.assertEqual(ver, ()) | ||
40 | ver = git_command._parse_ssh_version('OpenSSH_1.0\n') | ||
41 | self.assertEqual(ver, (1, 0)) | ||
42 | ver = git_command._parse_ssh_version('OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13, OpenSSL 1.0.1f 6 Jan 2014\n') | ||
43 | self.assertEqual(ver, (6, 6, 1)) | ||
44 | ver = git_command._parse_ssh_version('OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017\n') | ||
45 | self.assertEqual(ver, (7, 6)) | ||
46 | |||
47 | def test_ssh_sock(self): | ||
48 | """Check ssh_sock() function.""" | ||
49 | with mock.patch('tempfile.mkdtemp', return_value='/tmp/foo'): | ||
50 | # old ssh version uses port | ||
51 | with mock.patch('git_command.ssh_version', return_value=(6, 6)): | ||
52 | self.assertTrue(git_command.ssh_sock().endswith('%p')) | ||
53 | git_command._ssh_sock_path = None | ||
54 | # new ssh version uses hash | ||
55 | with mock.patch('git_command.ssh_version', return_value=(6, 7)): | ||
56 | self.assertTrue(git_command.ssh_sock().endswith('%C')) | ||
57 | git_command._ssh_sock_path = None | ||
58 | |||
59 | |||
33 | class GitCallUnitTest(unittest.TestCase): | 60 | class GitCallUnitTest(unittest.TestCase): |
34 | """Tests the _GitCall class (via git_command.git).""" | 61 | """Tests the _GitCall class (via git_command.git).""" |
35 | 62 | ||