Skip to content

Commit

Permalink
Add empty request bodies to /forget calls in TestRoomForget (#652)
Browse files Browse the repository at this point in the history
* Add empty request bodies to /forget calls

* /join also needs an empty request body
  • Loading branch information
reivilibre authored Sep 27, 2023
1 parent 21187b3 commit 6cad09b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/csapi/apidoc_room_forget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestRoomForget(t *testing.T) {
t.Run("Can't forget room you're still in", func(t *testing.T) {
t.Parallel()
roomID := alice.CreateRoom(t, map[string]interface{}{"preset": "private_chat"})
res := alice.DoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
res := alice.DoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: http.StatusBadRequest,
JSON: []match.JSON{
Expand All @@ -47,7 +47,7 @@ func TestRoomForget(t *testing.T) {
},
})
alice.LeaveRoom(t, roomID)
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
res := alice.DoFunc(t, "GET", []string{"_matrix", "client", "v3", "rooms", roomID, "messages"})
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: http.StatusForbidden,
Expand All @@ -71,7 +71,7 @@ func TestRoomForget(t *testing.T) {
alice.LeaveRoom(t, roomID)
// Ensure Alice left the room
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncLeftFrom(alice.UserID, roomID))
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
bob.SendEventSynced(t, roomID, b.Event{
Type: "m.room.message",
Content: map[string]interface{}{
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestRoomForget(t *testing.T) {
alice.LeaveRoom(t, roomID)
// Ensure Alice left the room
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncLeftFrom(alice.UserID, roomID))
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
bob.SendEventSynced(t, roomID, b.Event{
Type: "m.room.message",
Content: map[string]interface{}{
Expand Down Expand Up @@ -197,9 +197,9 @@ func TestRoomForget(t *testing.T) {
bob.LeaveRoom(t, roomID)
// Ensure Bob has really left the room
alice.MustSyncUntil(t, client.SyncReq{}, client.SyncLeftFrom(bob.UserID, roomID))
bob.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
bob.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
// Try to re-join
joinRes := bob.DoFunc(t, "POST", []string{"_matrix", "client", "v3", "join", roomID})
joinRes := bob.DoFunc(t, "POST", []string{"_matrix", "client", "v3", "join", roomID}, client.WithJSONBody(t, struct{}{}))
must.MatchResponse(t, joinRes, match.HTTPResponse{
StatusCode: http.StatusForbidden,
JSON: []match.JSON{
Expand Down Expand Up @@ -251,11 +251,11 @@ func TestRoomForget(t *testing.T) {
// Bob rejects the invite
bob.LeaveRoom(t, roomID)
// Bob tries to forget about this room
bob.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
bob.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
// Alice also leaves the room
alice.LeaveRoom(t, roomID)
// Alice tries to forget about this room
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"})
alice.MustDoFunc(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "forget"}, client.WithJSONBody(t, struct{}{}))
})
})
}
Expand Down

0 comments on commit 6cad09b

Please sign in to comment.