Beispiel #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"
Beispiel #2
0
 def is_required(self):
     Connection()
Beispiel #3
0
 def has_no_required_args_and_returns_None(self, client):
     c = Connection("host")
     c.open()
     assert c.close() is None
Beispiel #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)
Beispiel #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)
Beispiel #6
0
 def is_connected_defaults_to_False(self):
     assert Connection("host").is_connected is False
Beispiel #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)
Beispiel #8
0
 def loses_to_explicit(self):
     config = self._runtime_config()
     cxn = Connection("runtime",
                      config=config,
                      connect_timeout=23)
     assert cxn.connect_timeout == 23
Beispiel #9
0
 def defaults_to_empty_dict(self):
     assert Connection("host").connect_kwargs == {}
Beispiel #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
Beispiel #11
0
 def wins_over_proxycommand(self):
     cxn = self._runtime_cxn(basename="both_proxies")
     assert cxn.gateway == Connection("winner@everything:777")
Beispiel #12
0
 def setup(self):
     self._expected_gw = Connection("jumpuser@jumphost:373")
Beispiel #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
Beispiel #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
Beispiel #15
0
 def comparison_to_non_Connections_is_False(self):
     assert Connection("host") != 15
Beispiel #16
0
 def may_be_given_explicitly(self):
     cxn = Connection("host", connect_kwargs={"foo": "bar"})
     assert cxn.connect_kwargs == {"foo": "bar"}
Beispiel #17
0
 def hashing_works(self):
     assert hash(Connection("host")) == hash(Connection("host"))
Beispiel #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"}
Beispiel #19
0
 def has_no_required_args_and_returns_None(self, client):
     assert Connection("host").open() is None
Beispiel #20
0
 def str_displays_repr(self):
     c = Connection("meh")
     assert str(c) == "<Connection host=meh>"
Beispiel #21
0
 def client_defaults_to_a_new_SSHClient(self):
     c = Connection("host").client
     assert isinstance(c, SSHClient)
     assert c.get_transport() is None
Beispiel #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
Beispiel #23
0
 def is_connected_True_when_successful(self, client):
     c = Connection("host")
     c.open()
     assert c.is_connected is True
Beispiel #24
0
 def omits_default_param_values(self):
     c = Connection("justhost")
     assert repr(c) == "<Connection host=justhost>"
Beispiel #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)
Beispiel #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
Beispiel #27
0
 def is_exposed_as_attribute(self):
     assert Connection("host").host == "host"  # buffalo buffalo
Beispiel #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
Beispiel #29
0
 def calls_SSHClient_close(self, client):
     "calls paramiko.SSHClient.close()"
     c = Connection("host")
     c.open()
     c.close()
     client.close.assert_called_with()
Beispiel #30
0
 def original_host_always_set(self):
     cxn = Connection("somehost")
     assert cxn.original_host == "somehost"
     assert cxn.host == "somehost"