Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit c0005fd

Browse files
committed
Test that the device ID doesn't change
1 parent ead6b09 commit c0005fd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/push/test_http.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ def _set_pusher(self, user_id: str, access_token: str, enabled: bool) -> None:
772772
lang=None,
773773
data={"url": "http://example.com/_matrix/push/v1/notify"},
774774
enabled=enabled,
775+
device_id=user_tuple.device_id,
775776
)
776777
)
777778

@@ -886,19 +887,21 @@ def test_null_enabled(self) -> None:
886887
self.assertEqual(len(channel.json_body["pushers"]), 1)
887888
self.assertTrue(channel.json_body["pushers"][0]["org.matrix.msc3881.enabled"])
888889

889-
def test_update_different_device_access_token(self) -> None:
890+
def test_update_different_device_access_token_device_id(self) -> None:
890891
"""Tests that if we create a pusher from one device, the update it from another
891-
device, the access token associated with the pusher stays the same.
892+
device, the access token and device ID associated with the pusher stays the
893+
same.
892894
"""
893895
# Create a user with a pusher.
894896
user_id, access_token = self._make_user_with_pusher("user")
895897

896898
# Get the token ID for the current access token, since that's what we store in
897-
# the pushers table.
899+
# the pushers table. Also get the device ID from it.
898900
user_tuple = self.get_success(
899901
self.hs.get_datastores().main.get_user_by_access_token(access_token)
900902
)
901903
token_id = user_tuple.token_id
904+
device_id = user_tuple.device_id
902905

903906
# Generate a new access token, and update the pusher with it.
904907
new_token = self.login("user", "pass")
@@ -910,10 +913,11 @@ def test_update_different_device_access_token(self) -> None:
910913
)
911914
pushers: List[PusherConfig] = list(ret)
912915

913-
# Check that we still have one pusher, and that the access token associated with
914-
# it didn't change.
916+
# Check that we still have one pusher, and that the access token and device ID
917+
# associated with it didn't change.
915918
self.assertEqual(len(pushers), 1)
916919
self.assertEqual(pushers[0].access_token, token_id)
920+
self.assertEqual(pushers[0].device_id, device_id)
917921

918922
@override_config({"experimental_features": {"msc3881_enabled": True}})
919923
def test_device_id(self) -> None:

0 commit comments

Comments
 (0)