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