From 42be99a2c7f7c31d693d414930118bd190c07497 Mon Sep 17 00:00:00 2001 From: Andris Raugulis Date: Wed, 19 Oct 2016 20:53:47 +0300 Subject: [PATCH] Test for non-ASCII banner. --- test/test_errors.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_errors.py b/test/test_errors.py index 13cc9e2..abdbebe 100644 --- a/test/test_errors.py +++ b/test/test_errors.py @@ -11,6 +11,7 @@ class TestErrors(object): def _conf(self): conf = self.AuditConf('localhost', 22) + conf.colors = False conf.batch = True return conf @@ -81,6 +82,18 @@ class TestErrors(object): assert 'error reading packet' in lines[-1] assert 'xxx' in lines[-1] + def test_non_ascii_banner(self, output_spy, virtual_socket): + vsocket = virtual_socket + vsocket.rdata.append(b'SSH-2.0-ssh-audit-test\xc3\xbc\r\n') + output_spy.begin() + with pytest.raises(SystemExit): + self.audit(self._conf()) + lines = output_spy.flush() + assert len(lines) == 3 + assert 'error reading packet' in lines[-1] + assert 'ASCII' in lines[-2] + assert lines[-3].endswith('SSH-2.0-ssh-audit-test?') + def test_nonutf8_data_after_banner(self, output_spy, virtual_socket): vsocket = virtual_socket vsocket.rdata.append(b'SSH-2.0-ssh-audit-test\r\n')