@@ -29,6 +29,11 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
29
29
* regular event. Doing so means that the regular event should itself be
30
30
* rejected.
31
31
*
32
+ * We actually send two such events. On one of them, we reply to the
33
+ * incoming /event_auth request with the bogus outlier in
34
+ * the auth_events; for the other, we return a 404. This means we can
35
+ * exercise different code paths in Synapse.
36
+ *
32
37
* We finish up by sending a final, normal, event which should be accepted
33
38
* everywhere. This acts as a sentinel so that we can be sure that the
34
39
* events have all been correctly propagated.
@@ -42,6 +47,8 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
42
47
* | ... O
43
48
* | ^
44
49
* X .......
50
+ * | ^
51
+ * Y .......
45
52
* |
46
53
* S
47
54
*
@@ -53,6 +60,8 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
53
60
* O is an outlier, which should be rejected
54
61
* X is an event with O among its auth_events, which should be rejected
55
62
* as a side-effect of O being rejected
63
+ * Y is a second regular event with O in its auth_events, but we give a
64
+ * different reply to /event_auth
56
65
* S is the final regular event, which acts as a sentinel
57
66
*
58
67
* To check if the outlier is rejected, we simply request the event via
@@ -163,6 +172,19 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
163
172
eventAuthMap [sentEvent1 .EventID ()] = sentEventAuthEvents
164
173
t .Logf ("Created sent event 1 %s" , sentEvent1 .EventID ())
165
174
175
+ // another a regular event which refers to the outlier event, but
176
+ // this time we will give a different answer to /event_auth
177
+ sentEvent2 := srv .MustCreateEvent (t , room , b.Event {
178
+ Type : "m.room.message" ,
179
+ Sender : charlie ,
180
+ Content : map [string ]interface {}{"body" : "sentEvent1" },
181
+ AuthEvents : room .EventIDsOrReferences (sentEventAuthEvents ),
182
+ })
183
+ room .AddEvent (sentEvent2 )
184
+ // we deliberately add nothing to eventAuthMap for this event, to make /event_auth
185
+ // return a 404.
186
+ t .Logf ("Created sent event 2 %s" , sentEvent2 .EventID ())
187
+
166
188
// finally, a genuine regular event.
167
189
sentinelEvent := srv .MustCreateEvent (t , room , b.Event {
168
190
Type : "m.room.message" ,
@@ -178,6 +200,7 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
178
200
OriginServerTS : gomatrixserverlib .AsTimestamp (time .Now ()),
179
201
PDUs : []json.RawMessage {
180
202
sentEvent1 .JSON (),
203
+ sentEvent2 .JSON (),
181
204
sentinelEvent .JSON (),
182
205
},
183
206
})
@@ -209,4 +232,12 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
209
232
t .Errorf ("Expected a 404 when fetching sent event 1, but got %d" , res .StatusCode )
210
233
}
211
234
})
235
+
236
+ t .Run ("sent event 2 should be rejected" , func (t * testing.T ) {
237
+ res := alice .DoFunc (t , "GET" , []string {"_matrix" , "client" , "r0" , "rooms" , room .RoomID , "event" , sentEvent2 .EventID ()})
238
+ defer res .Body .Close ()
239
+ if res .StatusCode != 404 {
240
+ t .Errorf ("Expected a 404 when fetching sent event 2, but got %d" , res .StatusCode )
241
+ }
242
+ })
212
243
}
0 commit comments