Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions tests/federation_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/matrix-org/complement/runtime"
"github.com/matrix-org/complement/should"
"github.com/matrix-org/gomatrixserverlib/spec"
"github.com/tidwall/gjson"
)

// Test for https://github.com/matrix-org/dendrite/issues/3004
Expand Down Expand Up @@ -91,14 +92,57 @@ func TestACLs(t *testing.T) {
"body": "I should be visible",
},
})
// wait for the sentinel event to come down sync
alice.MustSyncUntil(t, client.SyncReq{Since: aliceSince}, client.SyncTimelineHasEventID(sentinelRoom, sentinelEventID))
charlie.MustSyncUntil(t, client.SyncReq{Since: charlieSince}, client.SyncTimelineHasEventID(sentinelRoom, sentinelEventID))

// Verify with alice and charlie that we never received eventID
// Bob starts typing in both rooms
bob.SendTyping(t, roomID, true, 10000)
bob.SendTyping(t, sentinelRoom, true, 10000)
Comment on lines +96 to +98
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we can split the tests for PDU's vs EDU's


// And sets read markers on both rooms
reqBody := client.WithJSONBody(t, map[string]interface{}{
"m.fully_read": eventID,
"m.read": eventID,
})
bob.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "read_markers"}, reqBody)

reqBody = client.WithJSONBody(t, map[string]interface{}{
"m.fully_read": sentinelEventID,
"m.read": sentinelEventID,
})
bob.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", sentinelRoom, "read_markers"}, reqBody)

// wait for the sentinel event, read receipts and typing EDUs to come down sync
hasReadReceipt := client.SyncEphemeralHas(sentinelRoom, func(result gjson.Result) bool {
return result.Get("type").Str == "m.receipt"
})
hasTyping := client.SyncEphemeralHas(roomID, func(result gjson.Result) bool {
return result.Get("type").Str == "m.typing"
})

alice.MustSyncUntil(t,
client.SyncReq{Since: aliceSince},
client.SyncTimelineHasEventID(sentinelRoom, sentinelEventID),
hasReadReceipt, hasTyping,
)
charlie.MustSyncUntil(t,
client.SyncReq{Since: charlieSince},
client.SyncTimelineHasEventID(sentinelRoom, sentinelEventID),
hasReadReceipt, hasTyping,
)

// Verify with alice and charlie that we never received eventID and the typing EDU
for _, user := range []*client.CSAPI{alice, charlie} {
syncResp, _ := user.MustSync(t, client.SyncReq{})

t.Logf("sync response: %s", syncResp.Raw)

// No one should be typing, no read receipts, per MSC4163
ephemerals := syncResp.Get("rooms.join." + roomID + ".ephemeral")
must.MatchGJSON(t, ephemerals, match.JSONKeyArrayOfSize("events", 0))

// But on the sentinel room, we should have a read receipt and a fully read receipt
ephemerals = syncResp.Get("rooms.join." + sentinelRoom + ".ephemeral")
must.MatchGJSON(t, ephemerals, match.JSONKeyArrayOfSize("events", 2))

// we don't expect eventID (blocked) to be in the sync response
events := should.GetTimelineEventIDs(syncResp, roomID)
must.NotContainSubset(t, events, []string{eventID})
Expand Down
Loading