summary refs log tree commit diff
path: root/tests/rest
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-10-31 20:31:43 +0000
committerGitHub <noreply@github.com>2022-10-31 20:31:43 +0000
commitdbfc9b803ee32f7b31c2b5ccbc53a1bfcaa95983 (patch)
treee59a0e29c0a839a62a437626eee705ec19323ead /tests/rest
parentSupport OIDC backchannel logouts (#11414) (diff)
downloadsynapse-dbfc9b803ee32f7b31c2b5ccbc53a1bfcaa95983.tar.xz
Fix dehydrated device REST checks (#14336)
Diffstat (limited to 'tests/rest')
-rw-r--r--tests/rest/client/test_devices.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/rest/client/test_devices.py b/tests/rest/client/test_devices.py
index aa98222434..d80eea17d3 100644
--- a/tests/rest/client/test_devices.py
+++ b/tests/rest/client/test_devices.py
@@ -200,3 +200,37 @@ class DevicesTestCase(unittest.HomeserverTestCase):
         self.reactor.advance(43200)
         self.get_success(self.handler.get_device(user_id, "abc"))
         self.get_failure(self.handler.get_device(user_id, "def"), NotFoundError)
+
+
+class DehydratedDeviceTestCase(unittest.HomeserverTestCase):
+    servlets = [
+        admin.register_servlets_for_client_rest_resource,
+        login.register_servlets,
+        register.register_servlets,
+        devices.register_servlets,
+    ]
+
+    def test_PUT(self) -> None:
+        """Sanity-check that we can PUT a dehydrated device.
+
+        Detects https://github.com/matrix-org/synapse/issues/14334.
+        """
+        alice = self.register_user("alice", "correcthorse")
+        token = self.login(alice, "correcthorse")
+
+        # Have alice update their device list
+        channel = self.make_request(
+            "PUT",
+            "_matrix/client/unstable/org.matrix.msc2697.v2/dehydrated_device",
+            {
+                "device_data": {
+                    "algorithm": "org.matrix.msc2697.v1.dehydration.v1.olm",
+                    "account": "dehydrated_device",
+                }
+            },
+            access_token=token,
+            shorthand=False,
+        )
+        self.assertEqual(channel.code, HTTPStatus.OK, channel.json_body)
+        device_id = channel.json_body.get("device_id")
+        self.assertIsInstance(device_id, str)