diff options
author | Erik Johnston <erikj@element.io> | 2024-05-16 15:04:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 15:04:14 +0100 |
commit | 5e892671a74251109bf9cf4a78bebed9d8085979 (patch) | |
tree | 4ca66bf70f476f18fccf3c9cdd80a009977e0976 /tests/handlers | |
parent | Refactor Sync handler to be able to return different sync responses (`SyncVer... (diff) | |
download | synapse-5e892671a74251109bf9cf4a78bebed9d8085979.tar.xz |
Fix bug where push rules would be empty in `/sync` (#17142)
Fixes #16987 Some old accounts seem to have an entry in global account data table for push rules, which we should ignore
Diffstat (limited to 'tests/handlers')
-rw-r--r-- | tests/handlers/test_sync.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/handlers/test_sync.py b/tests/handlers/test_sync.py index 9c12a11e3a..0299113b95 100644 --- a/tests/handlers/test_sync.py +++ b/tests/handlers/test_sync.py @@ -24,7 +24,7 @@ from parameterized import parameterized from twisted.test.proto_helpers import MemoryReactor -from synapse.api.constants import EventTypes, JoinRules +from synapse.api.constants import AccountDataTypes, EventTypes, JoinRules from synapse.api.errors import Codes, ResourceLimitError from synapse.api.filtering import FilterCollection, Filtering from synapse.api.room_versions import RoomVersion, RoomVersions @@ -895,6 +895,33 @@ class SyncTestCase(tests.unittest.HomeserverTestCase): self.assertIn(private_call_event.event_id, priv_event_ids) + def test_push_rules_with_bad_account_data(self) -> None: + """Some old accounts have managed to set a `m.push_rules` account data, + which we should ignore in /sync response. + """ + + user = self.register_user("alice", "password") + + # Insert the bad account data. + self.get_success( + self.store.add_account_data_for_user(user, AccountDataTypes.PUSH_RULES, {}) + ) + + sync_result: SyncResult = self.get_success( + self.sync_handler.wait_for_sync_for_user( + create_requester(user), generate_sync_config(user) + ) + ) + + for account_dict in sync_result.account_data: + if account_dict["type"] == AccountDataTypes.PUSH_RULES: + # We should have lots of push rules here, rather than the bad + # empty data. + self.assertNotEqual(account_dict["content"], {}) + return + + self.fail("No push rules found") + _request_key = 0 |