summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier 'reivilibre <oliverw@matrix.org>2024-07-30 12:40:16 +0100
committerOlivier 'reivilibre <oliverw@matrix.org>2024-07-30 14:27:19 +0100
commit98876d342f7b49ace4ecbb185d4d72810b38ae7d (patch)
tree50128e41f1a1a8612b130d69744daa2f945bd9ce
parentFix signature and bug in `writeHeaders` in the tests (diff)
downloadsynapse-98876d342f7b49ace4ecbb185d4d72810b38ae7d.tar.xz
Fix tests relying on headers not being Headers
-rw-r--r--tests/rest/client/test_login.py5
-rw-r--r--tests/test_server.py6
2 files changed, 5 insertions, 6 deletions
diff --git a/tests/rest/client/test_login.py b/tests/rest/client/test_login.py
index 3fb77fd9dd..3a99838719 100644
--- a/tests/rest/client/test_login.py
+++ b/tests/rest/client/test_login.py
@@ -969,9 +969,8 @@ class CASTestCase(unittest.HomeserverTestCase):
         # Test that the response is HTML.
         self.assertEqual(channel.code, 200, channel.result)
         content_type_header_value = ""
-        for header in channel.result.get("headers", []):
-            if header[0] == b"Content-Type":
-                content_type_header_value = header[1].decode("utf8")
+        for header in channel.headers.getRawHeaders("Content-Type"):
+            content_type_header_value = header
 
         self.assertTrue(content_type_header_value.startswith("text/html"))
 
diff --git a/tests/test_server.py b/tests/test_server.py
index 0910ea5f28..45015ca653 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -393,7 +393,7 @@ class WrapHtmlRequestHandlerTests(unittest.TestCase):
 
         self.assertEqual(channel.code, 301)
         headers = channel.result["headers"]
-        location_headers = [v for k, v in headers if k == b"Location"]
+        location_headers = headers.getRawHeaders(b"Location", [])
         self.assertEqual(location_headers, [b"/look/an/eagle"])
 
     def test_redirect_exception_with_cookie(self) -> None:
@@ -416,9 +416,9 @@ class WrapHtmlRequestHandlerTests(unittest.TestCase):
 
         self.assertEqual(channel.code, 304)
         headers = channel.result["headers"]
-        location_headers = [v for k, v in headers if k == b"Location"]
+        location_headers = headers.getRawHeaders(b"Location", [])
         self.assertEqual(location_headers, [b"/no/over/there"])
-        cookies_headers = [v for k, v in headers if k == b"Set-Cookie"]
+        cookies_headers = headers.getRawHeaders(b"Set-Cookie", [])
         self.assertEqual(cookies_headers, [b"session=yespls"])
 
     def test_head_request(self) -> None: