def test_server_options(self): """Test server connection options""" with open('config', 'w') as f: f.write('ClientAliveInterval 1\nClientAliveInterval 2') options = asyncssh.SSHServerConnectionOptions(config='config') self.assertEqual(options.keepalive_interval, 1) with open('config', 'w') as f: f.write('ClientAliveInterval 2\nClientAliveCountMax 3\n') options = asyncssh.SSHServerConnectionOptions(options, config='config') self.assertEqual(options.keepalive_interval, 1) self.assertEqual(options.keepalive_count_max, 3)
async def connect_reverse(self, options=None, **kwargs): """Create a connection to the test server""" options = asyncssh.SSHServerConnectionOptions(options, server_factory=Server, server_host_keys=['skey'], gss_host=None) return await asyncssh.connect_reverse(self._server_addr, self._server_port, options=options, **kwargs)
async def listen(cls, *, server_factory=(), options=None, **kwargs): """Create an SSH server for the tests to use""" if server_factory == (): server_factory = Server options = asyncssh.SSHServerConnectionOptions( options=options, server_factory=server_factory, gss_host=None, server_host_keys=['skey']) return await asyncssh.listen(port=0, family=socket.AF_INET, options=options, **kwargs)
def connect_reverse(self, loop=(), options=None, **kwargs): """Create a connection to the test server""" if loop == (): loop = self.loop options = asyncssh.SSHServerConnectionOptions( options, server_factory=Server, server_host_keys=['skey'], gss_host=None) return (yield from asyncssh.connect_reverse(self._server_addr, self._server_port, loop=loop, options=options, **kwargs))