Skip to content

Commit

Permalink
Add test to make sure /messages behaves as expected for non-existen…
Browse files Browse the repository at this point in the history
…t `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]>
  • Loading branch information
MadLittleMods and kegsay authored May 11, 2022
1 parent 6e5552c commit 15deea3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/csapi/room_messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ func TestSendAndFetchMessage(t *testing.T) {
})
}

// With a non-existent room_id, GET /rooms/:room_id/messages returns 403
// forbidden ("You aren't a member of the room").
func TestFetchMessagesFromNonExistentRoom(t *testing.T) {
deployment := Deploy(t, b.BlueprintAlice)
defer deployment.Destroy(t)

alice := deployment.Client(t, "hs1", "@alice:hs1")
roomID := "!does-not-exist:hs1"

// then request messages from the room
queryParams := url.Values{}
queryParams.Set("dir", "b")
res := alice.DoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithQueries(queryParams))
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: http.StatusForbidden,
})
}

// sytest: PUT /rooms/:room_id/send/:event_type/:txn_id sends a message
// sytest: PUT /rooms/:room_id/send/:event_type/:txn_id deduplicates the same txn id
func TestSendMessageWithTxn(t *testing.T) {
Expand Down

0 comments on commit 15deea3

Please sign in to comment.