Validate the result of locale charmap

This commit is contained in:
Sheng
2019-10-05 13:18:53 +08:00
parent 1fe361f601
commit afcf8b52cc
4 changed files with 49 additions and 11 deletions
+23 -1
View File
@@ -515,6 +515,7 @@ class OtherTestBase(TestAppBase):
tdstream = ''
maxconn = 20
origin = 'same'
encoding = ''
body = {
'hostname': '127.0.0.1',
'port': '',
@@ -543,7 +544,8 @@ class OtherTestBase(TestAppBase):
OtherTestBase.sshserver_port += 1
t = threading.Thread(
target=run_ssh_server, args=(self.sshserver_port, self.running)
target=run_ssh_server,
args=(self.sshserver_port, self.running, self.encoding)
)
t.setDaemon(True)
t.start()
@@ -762,3 +764,23 @@ class TestAppWithCrossOriginOperation(OtherTestBase):
self.assertEqual(
response.headers.get('Access-Control-Allow-Origin'), self.origin
)
class TestAppWithBadEncoding(OtherTestBase):
encoding = b'\xe7\xbc\x96\xe7\xa0\x81'
@tornado.testing.gen_test
def test_app_with_a_bad_encoding(self):
response = yield self.async_post('/', self.body)
self.assertIn(b'Bad encoding', response.body)
class TestAppWithUnknownEncoding(OtherTestBase):
encoding = u'UnknownEncoding'
@tornado.testing.gen_test
def test_app_with_a_bad_encoding(self):
response = yield self.async_post('/', self.body)
self.assertIn(b'Unknown encoding', response.body)