Refactoring

This commit is contained in:
Sheng
2019-10-09 11:40:07 +08:00
parent 049baad909
commit fc30ead69e
4 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ class Server(paramiko.ServerInterface):
self.key_verified = False
def get_cmd2enc(self, encodings):
while len(encodings) < 2:
while len(encodings) < len(self.commands):
encodings.append(random.choice(self.encodings))
return dict(zip(self.commands, encodings[0:2]))
+3 -2
View File
@@ -7,7 +7,7 @@ import tornado.gen
from tornado.testing import AsyncHTTPTestCase
from tornado.httpclient import HTTPError
from tornado.options import options
from tests.sshserver import run_ssh_server, banner
from tests.sshserver import run_ssh_server, banner, Server
from tests.utils import encode_multipart_formdata, read_file, make_tests_data_path # noqa
from webssh import handler
from webssh.main import make_app, make_handlers
@@ -25,6 +25,7 @@ except ImportError:
handler.DELAY = 0.1
swallow_http_errors = handler.swallow_http_errors
server_encodings = {e.strip() for e in Server.encodings}
class TestAppBase(AsyncHTTPTestCase):
@@ -775,7 +776,7 @@ class TestAppWithBadEncoding(OtherTestBase):
response = yield self.async_post('/', self.body)
dic = json.loads(to_str(response.body))
self.assert_status_none(dic)
self.assertIn(dic['encoding'], ['UTF-8', 'GBK'])
self.assertIn(dic['encoding'], server_encodings)
class TestAppWithUnknownEncoding(OtherTestBase):