コード例 #1
0
 def loses_to_explicit(self):
     # Would be 'abaddon', as above
     config = self._runtime_config()
     cxn = Connection("runtime", config=config, user="******")
     assert cxn.user == "set"
コード例 #2
0
 def is_required(self):
     Connection()
コード例 #3
0
 def has_no_required_args_and_returns_None(self, client):
     c = Connection("host")
     c.open()
     assert c.close() is None
コード例 #4
0
 def submits_connect_timeout(self, client):
     Connection("host", connect_timeout=27).open()
     client.connect.assert_called_with(username=get_local_user(),
                                       hostname="host",
                                       port=22,
                                       timeout=27)
コード例 #5
0
 def uses_configured_user_host_and_port(self, client):
     Connection(user="******", host="myhost", port=9001).open()
     client.connect.assert_called_once_with(username="******",
                                            hostname="myhost",
                                            port=9001)
コード例 #6
0
 def is_connected_defaults_to_False(self):
     assert Connection("host").is_connected is False
コード例 #7
0
 def calls_SSHClient_connect(self, client):
     "calls paramiko.SSHClient.connect() with correct args"
     Connection("host").open()
     client.connect.assert_called_with(username=get_local_user(),
                                       hostname="host",
                                       port=22)
コード例 #8
0
 def loses_to_explicit(self):
     config = self._runtime_config()
     cxn = Connection("runtime",
                      config=config,
                      connect_timeout=23)
     assert cxn.connect_timeout == 23
コード例 #9
0
 def defaults_to_empty_dict(self):
     assert Connection("host").connect_kwargs == {}
コード例 #10
0
 def explicit_False_turns_off_feature(self):
     config = self._runtime_config(basename="proxyjump")
     cxn = Connection("runtime", config=config, gateway=False)
     assert cxn.gateway is False
コード例 #11
0
 def wins_over_proxycommand(self):
     cxn = self._runtime_cxn(basename="both_proxies")
     assert cxn.gateway == Connection("winner@everything:777")
コード例 #12
0
 def setup(self):
     self._expected_gw = Connection("jumpuser@jumphost:373")
コード例 #13
0
 def explicit_False_turns_off_feature(self):
     # This isn't as necessary for things like user/port, which
     # _may not_ be None in the end - this setting could be.
     config = self._runtime_config()
     cxn = Connection("runtime", config=config, gateway=False)
     assert cxn.gateway is False
コード例 #14
0
 def loses_to_explicit(self):
     config = self._runtime_config()  # Would be 666, as above
     cxn = Connection("runtime", config=config, port=777)
     assert cxn.port == 777
コード例 #15
0
 def comparison_to_non_Connections_is_False(self):
     assert Connection("host") != 15
コード例 #16
0
 def may_be_given_explicitly(self):
     cxn = Connection("host", connect_kwargs={"foo": "bar"})
     assert cxn.connect_kwargs == {"foo": "bar"}
コード例 #17
0
 def hashing_works(self):
     assert hash(Connection("host")) == hash(Connection("host"))
コード例 #18
0
 def may_be_configured(self):
     c = Config(overrides={"connect_kwargs": {"origin": "config"}})
     cxn = Connection("host", config=c)
     assert cxn.connect_kwargs == {"origin": "config"}
コード例 #19
0
 def has_no_required_args_and_returns_None(self, client):
     assert Connection("host").open() is None
コード例 #20
0
 def str_displays_repr(self):
     c = Connection("meh")
     assert str(c) == "<Connection host=meh>"
コード例 #21
0
 def client_defaults_to_a_new_SSHClient(self):
     c = Connection("host").client
     assert isinstance(c, SSHClient)
     assert c.get_transport() is None
コード例 #22
0
 def displays_core_params(self):
     c = Connection(user="******", host="there", port=123)
     template = "<Connection host=there user=me port=123>"
     assert repr(c) == template
コード例 #23
0
 def is_connected_True_when_successful(self, client):
     c = Connection("host")
     c.open()
     assert c.is_connected is True
コード例 #24
0
 def omits_default_param_values(self):
     c = Connection("justhost")
     assert repr(c) == "<Connection host=justhost>"
コード例 #25
0
 def defaults_to_auto_add(self):
     # TODO: change Paramiko API so this isn't a private access
     # TODO: maybe just merge with the __init__ test that is similar
     assert isinstance(Connection("host").client._policy, AutoAddPolicy)
コード例 #26
0
 def proxyjump_gateway_shows_type(self):
     c = Connection(host="myhost", gateway=Connection("jump"))
     template = "<Connection host=myhost gw=proxyjump>"
     assert repr(c) == template
コード例 #27
0
 def is_exposed_as_attribute(self):
     assert Connection("host").host == "host"  # buffalo buffalo
コード例 #28
0
 def proxycommand_gateway_shows_type(self):
     c = Connection(host="myhost", gateway="netcat is cool")
     template = "<Connection host=myhost gw=proxycommand>"
     assert repr(c) == template
コード例 #29
0
 def calls_SSHClient_close(self, client):
     "calls paramiko.SSHClient.close()"
     c = Connection("host")
     c.open()
     c.close()
     client.close.assert_called_with()
コード例 #30
0
 def original_host_always_set(self):
     cxn = Connection("somehost")
     assert cxn.original_host == "somehost"
     assert cxn.host == "somehost"