@@ -29,6 +29,11 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
2929 * regular event. Doing so means that the regular event should itself be
3030 * rejected.
3131 *
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+ *
3237 * We finish up by sending a final, normal, event which should be accepted
3338 * everywhere. This acts as a sentinel so that we can be sure that the
3439 * events have all been correctly propagated.
@@ -42,6 +47,8 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
4247 * | ... O
4348 * | ^
4449 * X .......
50+ * | ^
51+ * Y .......
4552 * |
4653 * S
4754 *
@@ -53,6 +60,8 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
5360 * O is an outlier, which should be rejected
5461 * X is an event with O among its auth_events, which should be rejected
5562 * 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
5665 * S is the final regular event, which acts as a sentinel
5766 *
5867 * To check if the outlier is rejected, we simply request the event via
@@ -163,6 +172,19 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
163172 eventAuthMap [sentEvent1 .EventID ()] = sentEventAuthEvents
164173 t .Logf ("Created sent event 1 %s" , sentEvent1 .EventID ())
165174
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+
166188 // finally, a genuine regular event.
167189 sentinelEvent := srv .MustCreateEvent (t , room , b.Event {
168190 Type : "m.room.message" ,
@@ -178,6 +200,7 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
178200 OriginServerTS : gomatrixserverlib .AsTimestamp (time .Now ()),
179201 PDUs : []json.RawMessage {
180202 sentEvent1 .JSON (),
203+ sentEvent2 .JSON (),
181204 sentinelEvent .JSON (),
182205 },
183206 })
@@ -209,4 +232,12 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) {
209232 t .Errorf ("Expected a 404 when fetching sent event 1, but got %d" , res .StatusCode )
210233 }
211234 })
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+ })
212243}
0 commit comments