summary refs log tree commit diff
path: root/tests/test_event_auth.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2022-06-10 10:48:25 +0100
committerRichard van der Hoff <richard@matrix.org>2022-06-12 23:13:10 +0100
commit0d9d36b15c3cd2851f1cf3452c096480f568e6cb (patch)
tree5039968d06b3e12ae487aa53ec785947b554f7f7 /tests/test_event_auth.py
parentRemove `room_version` param from `validate_event_for_room_version` (diff)
downloadsynapse-0d9d36b15c3cd2851f1cf3452c096480f568e6cb.tar.xz
Remove `room_version` param from `check_auth_rules_for_event`
Instead, use the `room_version` property of the event we're checking.

The `room_version` was originally added as a parameter somewhere around #4482,
but really it's been redundant since #6875 added a `room_version` field to `EventBase`.
Diffstat (limited to '')
-rw-r--r--tests/test_event_auth.py43
1 files changed, 2 insertions, 41 deletions
diff --git a/tests/test_event_auth.py b/tests/test_event_auth.py
index 1e11fb5dac..229ecd84a6 100644
--- a/tests/test_event_auth.py
+++ b/tests/test_event_auth.py
@@ -38,7 +38,6 @@ class EventAuthTestCase(unittest.TestCase):
 
         # creator should be able to send state
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V9,
             _random_state_event(RoomVersions.V9, creator),
             auth_events,
         )
@@ -55,7 +54,6 @@ class EventAuthTestCase(unittest.TestCase):
         self.assertRaises(
             AuthError,
             event_auth.check_auth_rules_for_event,
-            RoomVersions.V9,
             _random_state_event(RoomVersions.V9, creator),
             auth_events,
         )
@@ -66,7 +64,6 @@ class EventAuthTestCase(unittest.TestCase):
         self.assertRaises(
             AuthError,
             event_auth.check_auth_rules_for_event,
-            RoomVersions.V9,
             _random_state_event(RoomVersions.V9, creator),
             auth_events,
         )
@@ -86,7 +83,6 @@ class EventAuthTestCase(unittest.TestCase):
 
         # creator should be able to send state
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V1,
             _random_state_event(RoomVersions.V1, creator),
             auth_events,
         )
@@ -95,7 +91,6 @@ class EventAuthTestCase(unittest.TestCase):
         self.assertRaises(
             AuthError,
             event_auth.check_auth_rules_for_event,
-            RoomVersions.V1,
             _random_state_event(RoomVersions.V1, joiner),
             auth_events,
         )
@@ -125,14 +120,12 @@ class EventAuthTestCase(unittest.TestCase):
         self.assertRaises(
             AuthError,
             event_auth.check_auth_rules_for_event,
-            RoomVersions.V1,
             _random_state_event(RoomVersions.V1, pleb),
             auth_events,
         ),
 
         # king should be able to send state
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V1,
             _random_state_event(RoomVersions.V1, king),
             auth_events,
         )
@@ -148,7 +141,6 @@ class EventAuthTestCase(unittest.TestCase):
 
         # creator should be able to send aliases
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V1,
             _alias_event(RoomVersions.V1, creator),
             auth_events,
         )
@@ -156,7 +148,6 @@ class EventAuthTestCase(unittest.TestCase):
         # Reject an event with no state key.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V1,
                 _alias_event(RoomVersions.V1, creator, state_key=""),
                 auth_events,
             )
@@ -164,14 +155,12 @@ class EventAuthTestCase(unittest.TestCase):
         # If the domain of the sender does not match the state key, reject.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V1,
                 _alias_event(RoomVersions.V1, creator, state_key="test.com"),
                 auth_events,
             )
 
         # Note that the member does *not* need to be in the room.
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V1,
             _alias_event(RoomVersions.V1, other),
             auth_events,
         )
@@ -187,19 +176,16 @@ class EventAuthTestCase(unittest.TestCase):
 
         # creator should be able to send aliases
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _alias_event(RoomVersions.V6, creator),
             auth_events,
         )
 
         # No particular checks are done on the state key.
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _alias_event(RoomVersions.V6, creator, state_key=""),
             auth_events,
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _alias_event(RoomVersions.V6, creator, state_key="test.com"),
             auth_events,
         )
@@ -207,7 +193,6 @@ class EventAuthTestCase(unittest.TestCase):
         # Per standard auth rules, the member must be in the room.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _alias_event(RoomVersions.V6, other),
                 auth_events,
             )
@@ -235,14 +220,12 @@ class EventAuthTestCase(unittest.TestCase):
 
         # on room V1, pleb should be able to modify the notifications power level.
         if allow_modification:
-            event_auth.check_auth_rules_for_event(room_version, pl_event, auth_events)
+            event_auth.check_auth_rules_for_event(pl_event, auth_events)
 
         else:
             # But an MSC2209 room rejects this change.
             with self.assertRaises(AuthError):
-                event_auth.check_auth_rules_for_event(
-                    room_version, pl_event, auth_events
-                )
+                event_auth.check_auth_rules_for_event(pl_event, auth_events)
 
     def test_join_rules_public(self):
         """
@@ -261,7 +244,6 @@ class EventAuthTestCase(unittest.TestCase):
 
         # Check join.
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -269,7 +251,6 @@ class EventAuthTestCase(unittest.TestCase):
         # A user cannot be force-joined to a room.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _member_event(RoomVersions.V6, pleb, "join", sender=creator),
                 auth_events.values(),
             )
@@ -280,7 +261,6 @@ class EventAuthTestCase(unittest.TestCase):
         )
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _join_event(RoomVersions.V6, pleb),
                 auth_events.values(),
             )
@@ -290,7 +270,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V6, pleb, "leave"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -300,7 +279,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V6, pleb, "join"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -310,7 +288,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V6, pleb, "invite", sender=creator
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -333,7 +310,6 @@ class EventAuthTestCase(unittest.TestCase):
         # A join without an invite is rejected.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _join_event(RoomVersions.V6, pleb),
                 auth_events.values(),
             )
@@ -341,7 +317,6 @@ class EventAuthTestCase(unittest.TestCase):
         # A user cannot be force-joined to a room.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _member_event(RoomVersions.V6, pleb, "join", sender=creator),
                 auth_events.values(),
             )
@@ -352,7 +327,6 @@ class EventAuthTestCase(unittest.TestCase):
         )
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _join_event(RoomVersions.V6, pleb),
                 auth_events.values(),
             )
@@ -363,7 +337,6 @@ class EventAuthTestCase(unittest.TestCase):
         )
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _join_event(RoomVersions.V6, pleb),
                 auth_events.values(),
             )
@@ -373,7 +346,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V6, pleb, "join"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -383,7 +355,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V6, pleb, "invite", sender=creator
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V6,
             _join_event(RoomVersions.V6, pleb),
             auth_events.values(),
         )
@@ -406,7 +377,6 @@ class EventAuthTestCase(unittest.TestCase):
 
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V6,
                 _join_event(RoomVersions.V6, pleb),
                 auth_events.values(),
             )
@@ -444,7 +414,6 @@ class EventAuthTestCase(unittest.TestCase):
             },
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V8,
             authorised_join_event,
             auth_events.values(),
         )
@@ -461,7 +430,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V8, "@inviter:foo.test"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V8,
             _join_event(
                 RoomVersions.V8,
                 pleb,
@@ -475,7 +443,6 @@ class EventAuthTestCase(unittest.TestCase):
         # A join which is missing an authorised server is rejected.
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V8,
                 _join_event(RoomVersions.V8, pleb),
                 auth_events.values(),
             )
@@ -489,7 +456,6 @@ class EventAuthTestCase(unittest.TestCase):
         )
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V8,
                 _join_event(
                     RoomVersions.V8,
                     pleb,
@@ -504,7 +470,6 @@ class EventAuthTestCase(unittest.TestCase):
         # *would* be valid, but is sent be a different user.)
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V8,
                 _member_event(
                     RoomVersions.V8,
                     pleb,
@@ -523,7 +488,6 @@ class EventAuthTestCase(unittest.TestCase):
         )
         with self.assertRaises(AuthError):
             event_auth.check_auth_rules_for_event(
-                RoomVersions.V8,
                 authorised_join_event,
                 auth_events.values(),
             )
@@ -533,7 +497,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V8, pleb, "leave"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V8,
             authorised_join_event,
             auth_events.values(),
         )
@@ -544,7 +507,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V8, pleb, "join"
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V8,
             _join_event(RoomVersions.V8, pleb),
             auth_events.values(),
         )
@@ -555,7 +517,6 @@ class EventAuthTestCase(unittest.TestCase):
             RoomVersions.V8, pleb, "invite", sender=creator
         )
         event_auth.check_auth_rules_for_event(
-            RoomVersions.V8,
             _join_event(RoomVersions.V8, pleb),
             auth_events.values(),
         )