summary refs log tree commit diff
path: root/tests/crypto
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-11-18 19:56:42 +0000
committerGitHub <noreply@github.com>2022-11-18 19:56:42 +0000
commite1b15f25f3ad4b45b381544ca6b3cd2caf43d25d (patch)
tree1e90b1de80aee13ffbf80400435b2d5b617cc545 /tests/crypto
parentReduce default third party invite rate limit to 216 invites per day (#14487) (diff)
downloadsynapse-e1b15f25f3ad4b45b381544ca6b3cd2caf43d25d.tar.xz
Fix /key/v2/server calls with URL-unsafe key IDs (#14490)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Diffstat (limited to 'tests/crypto')
-rw-r--r--tests/crypto/test_keyring.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/crypto/test_keyring.py b/tests/crypto/test_keyring.py
index 820a1a54e2..63628aa6b0 100644
--- a/tests/crypto/test_keyring.py
+++ b/tests/crypto/test_keyring.py
@@ -469,6 +469,18 @@ class ServerKeyFetcherTestCase(unittest.HomeserverTestCase):
         keys = self.get_success(fetcher.get_keys(SERVER_NAME, ["key1"], 0))
         self.assertEqual(keys, {})
 
+    def test_keyid_containing_forward_slash(self) -> None:
+        """We should url-encode any url unsafe chars in key ids.
+
+        Detects https://github.com/matrix-org/synapse/issues/14488.
+        """
+        fetcher = ServerKeyFetcher(self.hs)
+        self.get_success(fetcher.get_keys("example.com", ["key/potato"], 0))
+
+        self.http_client.get_json.assert_called_once()
+        args, kwargs = self.http_client.get_json.call_args
+        self.assertEqual(kwargs["path"], "/_matrix/key/v2/server/key%2Fpotato")
+
 
 class PerspectivesKeyFetcherTestCase(unittest.HomeserverTestCase):
     def make_homeserver(self, reactor, clock):