|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | import unittest
|
16 |
| -from typing import Collection, Dict, Iterable, List, Optional |
| 16 | +from typing import Any, Collection, Dict, Iterable, List, Optional |
17 | 17 |
|
18 | 18 | from parameterized import parameterized
|
19 | 19 |
|
@@ -728,6 +728,31 @@ def test_room_v10_rejects_string_power_levels(self) -> None:
|
728 | 728 | pl_event.room_version, pl_event2, {("fake_type", "fake_key"): pl_event}
|
729 | 729 | )
|
730 | 730 |
|
| 731 | + def test_room_v10_rejects_other_non_integer_power_levels(self) -> None: |
| 732 | + def create_event(pl_event_content: Dict[str, Any]) -> EventBase: |
| 733 | + return make_event_from_dict( |
| 734 | + { |
| 735 | + "room_id": TEST_ROOM_ID, |
| 736 | + **_maybe_get_event_id_dict_for_room_version(RoomVersions.V10), |
| 737 | + "type": "m.room.power_levels", |
| 738 | + "sender": "@test:test.com", |
| 739 | + "state_key": "", |
| 740 | + "content": pl_event_content, |
| 741 | + "signatures": {"test.com": {"ed25519:0": "some9signature"}}, |
| 742 | + }, |
| 743 | + room_version=RoomVersions.V10, |
| 744 | + ) |
| 745 | + |
| 746 | + contents: Iterable[Dict[str, Any]] = [ |
| 747 | + {"notifications": {"room": None}}, |
| 748 | + {"users": {"@alice:wonderland": []}}, |
| 749 | + {"users_default": {}}, |
| 750 | + ] |
| 751 | + for content in contents: |
| 752 | + event = create_event(content) |
| 753 | + with self.assertRaises(SynapseError): |
| 754 | + event_auth._check_power_levels(event.room_version, event, {}) |
| 755 | + |
731 | 756 |
|
732 | 757 | # helpers for making events
|
733 | 758 | TEST_DOMAIN = "example.com"
|
|
0 commit comments