Fix encoding for account validity HTML files on Python 2
parent
99eec6d2d5
commit
7a95d8fff9
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
import logging
|
||||
|
||||
from six import ensure_binary
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
from synapse.api.errors import AuthError, SynapseError
|
||||
|
|
@ -63,7 +65,7 @@ class AccountValidityRenewServlet(RestServlet):
|
|||
request.setResponseCode(status_code)
|
||||
request.setHeader(b"Content-Type", b"text/html; charset=utf-8")
|
||||
request.setHeader(b"Content-Length", b"%d" % (len(response),))
|
||||
request.write(response.encode("utf8"))
|
||||
request.write(ensure_binary(response))
|
||||
finish_request(request)
|
||||
defer.returnValue(None)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import json
|
|||
import os
|
||||
|
||||
from mock import Mock
|
||||
from six import ensure_binary
|
||||
|
||||
import pkg_resources
|
||||
|
||||
|
|
@ -437,7 +438,7 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
# Check that the HTML we're getting is the one we expect on a successful renewal.
|
||||
expected_html = self.hs.config.account_validity.account_renewed_html_content
|
||||
self.assertEqual(
|
||||
channel.result["body"], expected_html.encode("utf8"), channel.result
|
||||
channel.result["body"], ensure_binary(expected_html), channel.result
|
||||
)
|
||||
|
||||
# Move 3 days forward. If the renewal failed, every authed request with
|
||||
|
|
@ -467,7 +468,7 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
# invalid/unknown token.
|
||||
expected_html = self.hs.config.account_validity.invalid_token_html_content
|
||||
self.assertEqual(
|
||||
channel.result["body"], expected_html.encode("utf8"), channel.result
|
||||
channel.result["body"], ensure_binary(expected_html), channel.result
|
||||
)
|
||||
|
||||
def test_manual_email_send(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue