webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit d389e32b85a59aa72b173907bf2724f2a40b0678
parent a1c9378048088cde18839a7419bb2a37f58d31f2
Author: Sheng <webmaster0115@gmail.com>
Date:   Wed, 13 Feb 2019 09:30:06 +0800

Enhanced tests

Diffstat:
Mtests/test_app.py | 39++++++++++++++-------------------------
1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/tests/test_app.py b/tests/test_app.py @@ -561,7 +561,7 @@ class TestAppWithRejectPolicy(OtherTestBase): def test_app_with_hostname_not_in_hostkeys(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) + body = urlencode(self.body) response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) @@ -584,7 +584,7 @@ class TestAppWithBadHostKey(OtherTestBase): def test_app_with_bad_host_key(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) + body = urlencode(self.body) response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) @@ -668,7 +668,7 @@ class TestAppWithPutRequest(OtherTestBase): def test_app_with_method_not_supported(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) + body = urlencode(self.body) with self.assertRaises(HTTPError) as ctx: yield client.fetch( @@ -687,17 +687,11 @@ class TestAppWithTooManyConnections(OtherTestBase): @tornado.testing.gen_test def test_app_with_too_many_connections(self): + clients['127.0.0.1'] = {'fake_worker_id': None} + url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) - response = yield client.fetch(url, method='POST', body=body, - headers=self.headers) - data = json.loads(to_str(response.body)) - worker_id = data['id'] - self.assertIsNotNone(worker_id) - self.assertIsNotNone(data['encoding']) - self.assertIsNone(data['status']) - + body = urlencode(self.body) response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) @@ -705,19 +699,14 @@ class TestAppWithTooManyConnections(OtherTestBase): self.assertIsNone(data['encoding']) self.assertEqual(data['status'], 'Too many connections.') - ws_url = url.replace('http', 'ws') + 'ws?id=' + worker_id - ws = yield tornado.websocket.websocket_connect(ws_url) - msg = yield ws.read_message() - self.assertIsNotNone(msg) + clients['127.0.0.1'].clear() response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) - self.assertIsNone(data['id']) - self.assertIsNone(data['encoding']) - self.assertEqual(data['status'], 'Too many connections.') - - ws.close() + self.assertIsNotNone(data['id']) + self.assertIsNotNone(data['encoding']) + self.assertIsNone(data['status']) class TestAppWithCrossOriginOperation(OtherTestBase): @@ -728,7 +717,7 @@ class TestAppWithCrossOriginOperation(OtherTestBase): def test_app_with_wrong_event_origin(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo', _origin='localhost')) + body = urlencode(dict(self.body, _origin='localhost')) response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) @@ -742,7 +731,7 @@ class TestAppWithCrossOriginOperation(OtherTestBase): def test_app_with_wrong_header_origin(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) + body = urlencode(self.body) headers = dict(self.headers, Origin='localhost') response = yield client.fetch(url, method='POST', body=body, headers=headers) @@ -757,7 +746,7 @@ class TestAppWithCrossOriginOperation(OtherTestBase): def test_app_with_correct_event_origin(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo', _origin=self.origin)) + body = urlencode(dict(self.body, _origin=self.origin)) response = yield client.fetch(url, method='POST', body=body, headers=self.headers) data = json.loads(to_str(response.body)) @@ -770,7 +759,7 @@ class TestAppWithCrossOriginOperation(OtherTestBase): def test_app_with_correct_header_origin(self): url = self.get_url('/') client = self.get_http_client() - body = urlencode(dict(self.body, username='foo')) + body = urlencode(self.body) headers = dict(self.headers, Origin=self.origin) response = yield client.fetch(url, method='POST', body=body, headers=headers)