From 390ef4e1a78ee90d2fe628feb07930792e50d876 Mon Sep 17 00:00:00 2001 From: Andrew Doh Date: Sun, 24 Jul 2022 03:32:44 -0700 Subject: [PATCH 1/6] add complement test for getting joined_members after leaving. Signed-off-by: Andrew Doh --- tests/csapi/apidoc_room_state_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index 83cec69a..2fa73c56 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -1,6 +1,7 @@ package csapi_tests import ( + "net/http" "net/url" "testing" @@ -320,5 +321,18 @@ func TestRoomState(t *testing.T) { }, }) }) + t.Run("GET /rooms/:room_id/joined_members test to ensure user cannot request joined_members after leaving room", func(t *testing.T) { + t.Parallel() + roomID := authedClient.CreateRoom(t, map[string]interface{}{}) + authedClient.LeaveRoom(t, roomID) + res := authedClient.DoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "joined_members"}) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: http.StatusForbidden, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_FORBIDDEN"), + match.JSONKeyEqual("error", "Getting joined members after leaving room is forbidden."), + }, + }) + }) }) } From cc8a06ed50ab62658e79235d7a6f83cf92f97288 Mon Sep 17 00:00:00 2001 From: Andrew Doh Date: Sun, 24 Jul 2022 12:27:16 -0700 Subject: [PATCH 2/6] change response match to be consistent with synapse error message. Signed-off-by: Andrew Doh --- tests/csapi/apidoc_room_state_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index 2fa73c56..f770ffb5 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -330,7 +330,7 @@ func TestRoomState(t *testing.T) { StatusCode: http.StatusForbidden, JSON: []match.JSON{ match.JSONKeyEqual("errcode", "M_FORBIDDEN"), - match.JSONKeyEqual("error", "Getting joined members after leaving room is forbidden."), + match.JSONKeyEqual("error", "Getting joined members after leaving is forbidden."), }, }) }) From 511286e7501f18e3888402185afdfe1e1b99f085 Mon Sep 17 00:00:00 2001 From: andrew do Date: Mon, 25 Jul 2022 10:10:48 -0700 Subject: [PATCH 3/6] Update tests/csapi/apidoc_room_state_test.go Co-authored-by: David Robertson --- tests/csapi/apidoc_room_state_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index f770ffb5..4c3bedea 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -321,7 +321,7 @@ func TestRoomState(t *testing.T) { }, }) }) - t.Run("GET /rooms/:room_id/joined_members test to ensure user cannot request joined_members after leaving room", func(t *testing.T) { + t.Run("GET /rooms/:room_id/joined_members is forbidden after leaving room", func(t *testing.T) { t.Parallel() roomID := authedClient.CreateRoom(t, map[string]interface{}{}) authedClient.LeaveRoom(t, roomID) From 2e336ff5afdf95d6a63f73c8dcd0331b0d897810 Mon Sep 17 00:00:00 2001 From: Andrew Doh Date: Mon, 25 Jul 2022 10:13:15 -0700 Subject: [PATCH 4/6] relax test check, due to localization and not being a part of th spec. Signed-off-by: Andrew Doh --- tests/csapi/apidoc_room_state_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index 4c3bedea..c2c5c977 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -330,7 +330,6 @@ func TestRoomState(t *testing.T) { StatusCode: http.StatusForbidden, JSON: []match.JSON{ match.JSONKeyEqual("errcode", "M_FORBIDDEN"), - match.JSONKeyEqual("error", "Getting joined members after leaving is forbidden."), }, }) }) From 91d0493490a2edd658f28b57593dc7f12828c878 Mon Sep 17 00:00:00 2001 From: Andrew Doh Date: Wed, 3 Aug 2022 10:03:02 -0700 Subject: [PATCH 5/6] remove duplicate import. Signed-off-by: Andrew Doh --- tests/csapi/apidoc_room_state_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index aff051fd..eebfb034 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -1,7 +1,6 @@ package csapi_tests import ( - "net/http" "net/url" "testing" "time" From 02ad6eb67416c4804be7b985b06f7136bfbbe8fb Mon Sep 17 00:00:00 2001 From: Andrew Doh Date: Sun, 14 Aug 2022 21:02:32 -0700 Subject: [PATCH 6/6] skip test for dendrite. Signed-off-by: Andrew Doh --- tests/csapi/apidoc_room_state_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index eebfb034..d7763520 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -11,6 +11,7 @@ import ( "github.com/matrix-org/complement/internal/client" "github.com/matrix-org/complement/internal/match" "github.com/matrix-org/complement/internal/must" + "github.com/matrix-org/complement/runtime" "net/http" ) @@ -329,6 +330,7 @@ func TestRoomState(t *testing.T) { }) }) t.Run("GET /rooms/:room_id/joined_members is forbidden after leaving room", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // https://github.com/matrix-org/complement/pull/424 t.Parallel() roomID := authedClient.CreateRoom(t, map[string]interface{}{}) authedClient.LeaveRoom(t, roomID)