File tree Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Expand file tree Collapse file tree 2 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ def __init__(self, host):
30
30
self .host = host
31
31
self .port = None
32
32
self .user = None
33
- if ':' in host :
34
- self .host , self .port = host .split (':' )
33
+ if ':' in self . host :
34
+ self .host , self .port = self . host .split (':' )
35
35
if '@' in self .host :
36
- self .user , self .host = host .split ('@' )
36
+ self .user , self .host = self . host .split ('@' )
37
37
38
38
self .proc = None
39
39
@@ -167,7 +167,7 @@ class SSHHTTPAdapter(BaseHTTPAdapter):
167
167
def __init__ (self , base_url , timeout = 60 ,
168
168
pool_connections = constants .DEFAULT_NUM_POOLS ,
169
169
max_pool_size = constants .DEFAULT_MAX_POOL_SIZE ,
170
- shell_out = True ):
170
+ shell_out = False ):
171
171
self .ssh_client = None
172
172
if not shell_out :
173
173
self ._create_paramiko_client (base_url )
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ import docker
3
+ from docker .transport .sshconn import SSHSocket
4
+
5
+ class SSHAdapterTest (unittest .TestCase ):
6
+ def test_ssh_hostname_prefix_trim (self ):
7
+ conn = docker .transport .SSHHTTPAdapter (base_url = "ssh://user@hostname:1234" , shell_out = True )
8
+ assert conn .ssh_host == "user@hostname:1234"
9
+
10
+ def test_ssh_parse_url (self ):
11
+ c = SSHSocket (host = "user@hostname:1234" )
12
+ assert c .host == "hostname"
13
+ assert c .port == "1234"
14
+ assert c .user == "user"
15
+
16
+ def test_ssh_parse_hostname_only (self ):
17
+ c = SSHSocket (host = "hostname" )
18
+ assert c .host == "hostname"
19
+ assert c .port == None
20
+ assert c .user == None
21
+
22
+ def test_ssh_parse_user_and_hostname (self ):
23
+ c = SSHSocket (host = "user@hostname" )
24
+ assert c .host == "hostname"
25
+ assert c .port == None
26
+ assert c .user == "user"
27
+
28
+ def test_ssh_parse_hostname_and_port (self ):
29
+ c = SSHSocket (host = "hostname:22" )
30
+ assert c .host == "hostname"
31
+ assert c .port == "22"
32
+ assert c .user == None
You can’t perform that action at this time.
0 commit comments