Skip to content

Commit 15deea3

Browse files
Add test to make sure /messages behaves as expected for non-existent room_id's (#369)
* Add test to make sure /messages behaves as expected for non-existent room_ids Tests for Synapse regression fix: matrix-org/synapse#12683 Issue: matrix-org/synapse#12678 * Explain why 403 * Remove dendrite skip Co-authored-by: Kegan Dougal <[email protected]>
1 parent 6e5552c commit 15deea3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/csapi/room_messages_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ func TestSendAndFetchMessage(t *testing.T) {
5959
})
6060
}
6161

62+
// With a non-existent room_id, GET /rooms/:room_id/messages returns 403
63+
// forbidden ("You aren't a member of the room").
64+
func TestFetchMessagesFromNonExistentRoom(t *testing.T) {
65+
deployment := Deploy(t, b.BlueprintAlice)
66+
defer deployment.Destroy(t)
67+
68+
alice := deployment.Client(t, "hs1", "@alice:hs1")
69+
roomID := "!does-not-exist:hs1"
70+
71+
// then request messages from the room
72+
queryParams := url.Values{}
73+
queryParams.Set("dir", "b")
74+
res := alice.DoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithQueries(queryParams))
75+
must.MatchResponse(t, res, match.HTTPResponse{
76+
StatusCode: http.StatusForbidden,
77+
})
78+
}
79+
6280
// sytest: PUT /rooms/:room_id/send/:event_type/:txn_id sends a message
6381
// sytest: PUT /rooms/:room_id/send/:event_type/:txn_id deduplicates the same txn id
6482
func TestSendMessageWithTxn(t *testing.T) {

0 commit comments

Comments
 (0)