summary refs log tree commit diff
path: root/tests/handlers
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2021-10-27 17:01:18 +0200
committerGitHub <noreply@github.com>2021-10-27 16:01:18 +0100
commit8d46fac98e07ac319c7ae21dfc24502993de3f1d (patch)
treeafe8d555e6fed79e821de4feef69f29d27991bd4 /tests/handlers
parentInclude the stable identifier for MSC3288. (#11187) (diff)
downloadsynapse-8d46fac98e07ac319c7ae21dfc24502993de3f1d.tar.xz
Delete messages from `device_inbox` table when deleting device (#10969)
Fixes: #9346
Diffstat (limited to 'tests/handlers')
-rw-r--r--tests/handlers/test_device.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/handlers/test_device.py b/tests/handlers/test_device.py
index 3ac48e5e95..43031e07ea 100644
--- a/tests/handlers/test_device.py
+++ b/tests/handlers/test_device.py
@@ -160,6 +160,37 @@ class DeviceTestCase(unittest.HomeserverTestCase):
         # we'd like to check the access token was invalidated, but that's a
         # bit of a PITA.
 
+    def test_delete_device_and_device_inbox(self):
+        self._record_users()
+
+        # add an device_inbox
+        self.get_success(
+            self.store.db_pool.simple_insert(
+                "device_inbox",
+                {
+                    "user_id": user1,
+                    "device_id": "abc",
+                    "stream_id": 1,
+                    "message_json": "{}",
+                },
+            )
+        )
+
+        # delete the device
+        self.get_success(self.handler.delete_device(user1, "abc"))
+
+        # check that the device_inbox was deleted
+        res = self.get_success(
+            self.store.db_pool.simple_select_one(
+                table="device_inbox",
+                keyvalues={"user_id": user1, "device_id": "abc"},
+                retcols=("user_id", "device_id"),
+                allow_none=True,
+                desc="get_device_id_from_device_inbox",
+            )
+        )
+        self.assertIsNone(res)
+
     def test_update_device(self):
         self._record_users()