mirror of
https://github.com/jtesta/ssh-audit.git
synced 2024-11-16 13:35:39 +01:00
ec1dda8d7f
* Remove mypy job for Python 2 modified: tox.ini * Remove Python 2 compatibility import modified: ssh-audit.py * Remove compatibility import for BytesIO and StringIO This is no longer necessary, as support for Python 2 was dropped. modified: ssh-audit.py * Remove `text-type` compatibility layer ... as support for Python 2 was dropped already. modified: ssh-audit.py * Remove `binary-type` compatibility layer ... as support for Python 2 was dropped already. modified: ssh-audit.py * Remove try-except block for typing ... as since Python 3.5 it is included in the standard library. modified: ssh-audit.py * Move typing import to top of module modified: ssh-audit.py * Remove obsolete encoding declaration modified: ssh-audit.py * Apply pyupgrade on ssh-audit.py pyupgrade is a tool which updates Python code to modern syntax modified: ssh-audit.py * Remove Python 2 compatibility from conftest.py modified: test/conftest.py * Remove Python 2 compatibility from test_auditconf.py modified: test/test_auditconf.py * Remove Python 2 compatibility from test_banner.py modified: test/test_banner.py * Remove Python 2 compatibility from test_buffer.py modified: test/test_buffer.py * Remove Python 2 compatibility from test_errors.py modified: test/test_errors.py * Remove Python 2 compatibility from test_output.py modified: test/test_output.py * Remove Python 2 compatibility from test_resolve.py modified: test/test_resolve.py * Remove Python 2 compatibility from test_socket.py modified: test/test_socket.py * Remove Python 2 compatibility from test_software.py modified: test/test_software.py * Remove Python 2 compatibility from test_ssh_algorithm.py modified: test/test_ssh_algorithm.py * Remove Python 2 compatibility from test_ssh1.py modified: test/test_ssh1.py * Remove Python 2 compatibility from test_ssh2.py modified: test/test_ssh2.py * Remove Python 2 compatibility and Py2 only tests ... from test_utils.py. modified: test/test_utils.py * Remove Python 2 compatibility from test_version_compare.py modified: test/test_version_compare.py * Remove Python 2 job from appveyor config This was done blindly, as it is unclear whether appveyor runs at all. modified: .appveyor.yml
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import pytest
|
|
|
|
|
|
# pylint: disable=attribute-defined-outside-init
|
|
class TestSocket:
|
|
@pytest.fixture(autouse=True)
|
|
def init(self, ssh_audit):
|
|
self.ssh = ssh_audit.SSH
|
|
|
|
def test_invalid_host(self, virtual_socket):
|
|
with pytest.raises(ValueError):
|
|
self.ssh.Socket(None, 22)
|
|
|
|
def test_invalid_port(self, virtual_socket):
|
|
with pytest.raises(ValueError):
|
|
self.ssh.Socket('localhost', 'abc')
|
|
with pytest.raises(ValueError):
|
|
self.ssh.Socket('localhost', -1)
|
|
with pytest.raises(ValueError):
|
|
self.ssh.Socket('localhost', 0)
|
|
with pytest.raises(ValueError):
|
|
self.ssh.Socket('localhost', 65536)
|
|
|
|
def test_not_connected_socket(self, virtual_socket):
|
|
sock = self.ssh.Socket('localhost', 22)
|
|
banner, header, err = sock.get_banner()
|
|
assert banner is None
|
|
assert len(header) == 0
|
|
assert err == 'not connected'
|
|
s, e = sock.recv()
|
|
assert s == -1
|
|
assert e == 'not connected'
|
|
s, e = sock.send('nothing')
|
|
assert s == -1
|
|
assert e == 'not connected'
|
|
s, e = sock.send_packet()
|
|
assert s == -1
|
|
assert e == 'not connected'
|