@@ -33,6 +33,7 @@ class MockEvent:
33
33
"""Mock of an event, only implementing the fields the DomainRuleChecker module will
34
34
use.
35
35
"""
36
+
36
37
sender : str
37
38
membership : Optional [str ] = None
38
39
@@ -42,6 +43,7 @@ class MockPublicRoomListManager:
42
43
"""Mock of a synapse.module_api.PublicRoomListManager, only implementing the method
43
44
the DomainRuleChecker module will use.
44
45
"""
46
+
45
47
_published : bool
46
48
47
49
async def room_is_in_public_room_list (self , room_id : str ) -> bool :
@@ -53,6 +55,7 @@ class MockModuleApi:
53
55
"""Mock of a synapse.module_api.ModuleApi, only implementing the methods the
54
56
DomainRuleChecker module will use.
55
57
"""
58
+
56
59
_new_room : bool
57
60
_published : bool
58
61
@@ -89,7 +92,12 @@ async def get_room_state(self, *args, **kwargs):
89
92
# reactor to run asynchronous code.
90
93
class DomainRuleCheckerTestCase (unittest .HomeserverTestCase ):
91
94
def _test_user_may_invite (
92
- self , config , inviter , invitee , new_room , published ,
95
+ self ,
96
+ config ,
97
+ inviter ,
98
+ invitee ,
99
+ new_room ,
100
+ published ,
93
101
) -> bool :
94
102
check = DomainRuleChecker (config , MockModuleApi (new_room , published ))
95
103
return self .get_success (check .user_may_invite (inviter , invitee , "room" ))
@@ -106,33 +114,53 @@ def test_allowed(self):
106
114
107
115
self .assertTrue (
108
116
self ._test_user_may_invite (
109
- config , "test:source_one" , "test:target_one" , False , False ,
117
+ config ,
118
+ "test:source_one" ,
119
+ "test:target_one" ,
120
+ False ,
121
+ False ,
110
122
),
111
123
)
112
124
113
125
self .assertTrue (
114
126
self ._test_user_may_invite (
115
- config , "test:source_one" , "test:target_two" , False , False ,
127
+ config ,
128
+ "test:source_one" ,
129
+ "test:target_two" ,
130
+ False ,
131
+ False ,
116
132
),
117
133
)
118
134
119
135
self .assertTrue (
120
136
self ._test_user_may_invite (
121
- config , "test:source_two" , "test:target_two" , False , False ,
137
+ config ,
138
+ "test:source_two" ,
139
+ "test:target_two" ,
140
+ False ,
141
+ False ,
122
142
),
123
143
)
124
144
125
145
# User can invite internal user to a published room
126
146
self .assertTrue (
127
147
self ._test_user_may_invite (
128
- config , "test:source_one" , "test1:target_one" , False , True ,
148
+ config ,
149
+ "test:source_one" ,
150
+ "test1:target_one" ,
151
+ False ,
152
+ True ,
129
153
),
130
154
)
131
155
132
156
# User can invite external user to a non-published room
133
157
self .assertTrue (
134
158
self ._test_user_may_invite (
135
- config , "test:source_one" , "test:target_two" , False , False ,
159
+ config ,
160
+ "test:source_one" ,
161
+ "test:target_two" ,
162
+ False ,
163
+ False ,
136
164
),
137
165
)
138
166
@@ -148,12 +176,20 @@ def test_disallowed(self):
148
176
149
177
self .assertFalse (
150
178
self ._test_user_may_invite (
151
- config , "test:source_one" , "test:target_three" , False , False ,
179
+ config ,
180
+ "test:source_one" ,
181
+ "test:target_three" ,
182
+ False ,
183
+ False ,
152
184
)
153
185
)
154
186
self .assertFalse (
155
187
self ._test_user_may_invite (
156
- config , "test:source_two" , "test:target_three" , False , False ,
188
+ config ,
189
+ "test:source_two" ,
190
+ "test:target_three" ,
191
+ False ,
192
+ False ,
157
193
)
158
194
)
159
195
self .assertFalse (
@@ -185,7 +221,11 @@ def test_default_allow(self):
185
221
186
222
self .assertTrue (
187
223
self ._test_user_may_invite (
188
- config , "test:source_three" , "test:target_one" , False , False ,
224
+ config ,
225
+ "test:source_three" ,
226
+ "test:target_one" ,
227
+ False ,
228
+ False ,
189
229
)
190
230
)
191
231
@@ -200,7 +240,11 @@ def test_default_deny(self):
200
240
201
241
self .assertFalse (
202
242
self ._test_user_may_invite (
203
- config , "test:source_three" , "test:target_one" , False , False ,
243
+ config ,
244
+ "test:source_three" ,
245
+ "test:target_one" ,
246
+ False ,
247
+ False ,
204
248
)
205
249
)
206
250
0 commit comments