/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_ssh_transport.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib.tests import TestCase
18
 
from bzrlib.errors import SSHVendorNotFound, UnknownSSH
19
 
from bzrlib.transport.ssh import (
 
17
from breezy.tests import TestCase
 
18
from breezy.errors import SSHVendorNotFound, UnknownSSH
 
19
from breezy.transport.ssh import (
20
20
    OpenSSHSubprocessVendor,
21
21
    PLinkSubprocessVendor,
22
22
    SSHCorpSubprocessVendor,
43
43
        self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
44
44
        vendor = object()
45
45
        manager.register_vendor("vendor", vendor)
46
 
        self.assertIs(manager.get_vendor({"BZR_SSH": "vendor"}), vendor)
 
46
        self.assertIs(manager.get_vendor({"BRZ_SSH": "vendor"}), vendor)
47
47
 
48
48
    def test_default_vendor(self):
49
49
        manager = TestSSHVendorManager()
56
56
        manager = TestSSHVendorManager()
57
57
        self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
58
58
        self.assertRaises(UnknownSSH,
59
 
            manager.get_vendor, {"BZR_SSH": "vendor"})
 
59
            manager.get_vendor, {"BRZ_SSH": "vendor"})
60
60
        vendor = object()
61
61
        manager.register_vendor("vendor", vendor)
62
 
        self.assertIs(manager.get_vendor({"BZR_SSH": "vendor"}), vendor)
 
62
        self.assertIs(manager.get_vendor({"BRZ_SSH": "vendor"}), vendor)
63
63
 
64
64
    def test_get_vendor_by_inspection_openssh(self):
65
65
        manager = TestSSHVendorManager()
98
98
        # Once the vendor is found the result is cached (mainly because of the
99
99
        # 'get_vendor' sometimes can be an expensive operation) and later
100
100
        # invocations of the 'get_vendor' just returns the cached value.
101
 
        self.assertIs(manager.get_vendor({"BZR_SSH": "vendor"}), vendor)
 
101
        self.assertIs(manager.get_vendor({"BRZ_SSH": "vendor"}), vendor)
102
102
        self.assertIs(manager.get_vendor({}), vendor)
103
103
        # The cache can be cleared by the 'clear_cache' method
104
104
        manager.clear_cache()
108
108
        # The 'get_vendor' method search for SSH vendors as following:
109
109
        #
110
110
        #   1. Check previously cached value
111
 
        #   2. Check BZR_SSH environment variable
 
111
        #   2. Check BRZ_SSH environment variable
112
112
        #   3. Check the system for known SSH vendors
113
113
        #   4. Fall back to the default vendor if registered
114
114
        #
129
129
        manager.set_ssh_version_string("OpenSSH")
130
130
        self.assertIsInstance(manager.get_vendor({}), OpenSSHSubprocessVendor)
131
131
 
132
 
        # If the BZR_SSH environment variable is found it will be treated as
 
132
        # If the BRZ_SSH environment variable is found it will be treated as
133
133
        # the vendor name
134
134
        manager.clear_cache()
135
135
        vendor = object()
136
136
        manager.register_vendor("vendor", vendor)
137
 
        self.assertIs(manager.get_vendor({"BZR_SSH": "vendor"}), vendor)
 
137
        self.assertIs(manager.get_vendor({"BRZ_SSH": "vendor"}), vendor)
138
138
 
139
139
        # Last cached value always checked first
140
140
        self.assertIs(manager.get_vendor({}), vendor)
143
143
        manager = TestSSHVendorManager()
144
144
        manager.set_ssh_version_string("plink: Release 0.60")
145
145
        plink_path = "C:/Program Files/PuTTY/plink.exe"
146
 
        vendor = manager.get_vendor({"BZR_SSH": plink_path})
 
146
        vendor = manager.get_vendor({"BRZ_SSH": plink_path})
147
147
        self.assertIsInstance(vendor, PLinkSubprocessVendor)
148
148
        args = vendor._get_vendor_specific_argv("user", "host", 22, ["bzr"])
149
149
        self.assertEqual(args[0], plink_path)
153
153
        manager.set_ssh_version_string(
154
154
            "OpenSSH_5.1p1 Debian-5, OpenSSL, 0.9.8g 19 Oct 2007")
155
155
        openssh_path = "/usr/bin/ssh"
156
 
        vendor = manager.get_vendor({"BZR_SSH": openssh_path})
 
156
        vendor = manager.get_vendor({"BRZ_SSH": openssh_path})
157
157
        self.assertIsInstance(vendor, OpenSSHSubprocessVendor)
158
158
        args = vendor._get_vendor_specific_argv("user", "host", 22, ["bzr"])
159
159
        self.assertEqual(args[0], openssh_path)