From 3aee55c849ca6675503e63886c3cbaad6b9ac582 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 2 Dec 2021 21:30:49 +0100 Subject: [PATCH 1/5] improve existing alias tests --- tests/csapi/apidoc_room_alias_test.go | 54 +++++++++++++-------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index 52323369..73007999 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -1,77 +1,75 @@ package csapi_tests import ( + "net/http" "testing" - "github.com/tidwall/gjson" - "github.com/matrix-org/complement/internal/b" "github.com/matrix-org/complement/internal/client" "github.com/matrix-org/complement/internal/match" "github.com/matrix-org/complement/internal/must" ) +func setRoomAliasResp(t *testing.T, c *client.CSAPI, roomID, roomAlias string) *http.Response { + return c.MustDoFunc(t, "PUT", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}, client.WithJSONBody(t, map[string]interface{}{ + "room_id": roomID, + })) +} + +func getRoomAliasResp(t *testing.T, c *client.CSAPI, roomAlias string) *http.Response { + return c.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}) +} + +func listRoomAliasesResp(t *testing.T, c *client.CSAPI, roomID string) *http.Response { + return c.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "aliases"}) +} + func TestRoomAlias(t *testing.T) { deployment := Deploy(t, b.BlueprintAlice) defer deployment.Destroy(t) - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Client(t, "hs1", "@alice:hs1") t.Run("Parallel", func(t *testing.T) { + // sytest: PUT /directory/room/:room_alias creates alias t.Run("PUT /directory/room/:room_alias creates alias", func(t *testing.T) { t.Parallel() - roomID := authedClient.CreateRoom(t, map[string]interface{}{ - "visibility": "public", - "preset": "public_chat", - }) - roomAlias := "#room_alias_test:hs1" + roomID := alice.CreateRoom(t, map[string]interface{}{}) - reqBody := client.WithJSONBody(t, map[string]interface{}{ - "room_id": roomID, - }) + roomAlias := "#room_alias_test:hs1" - _ = authedClient.MustDoFunc(t, "PUT", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}, reqBody) + setRoomAliasResp(t, alice, roomID, roomAlias) - res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}) + res := getRoomAliasResp(t, alice, roomAlias) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ - match.JSONKeyPresent("room_id"), - match.JSONKeyTypeEqual("room_id", gjson.String), match.JSONKeyEqual("room_id", roomID), }, }) }) + // sytest: GET /rooms/:room_id/aliases lists aliases t.Run("GET /rooms/:room_id/aliases lists aliases", func(t *testing.T) { t.Parallel() - roomID := authedClient.CreateRoom(t, map[string]interface{}{ - "visibility": "public", - "preset": "public_chat", - }) + roomID := alice.CreateRoom(t, map[string]interface{}{}) - res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "aliases"}) + res := listRoomAliasesResp(t, alice, roomID) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ - match.JSONKeyPresent("aliases"), match.JSONKeyEqual("aliases", []interface{}{}), }, }) roomAlias := "#room_alias:hs1" - reqBody := client.WithJSONBody(t, map[string]interface{}{ - "room_id": roomID, - }) - - _ = authedClient.MustDoFunc(t, "PUT", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}, reqBody) + setRoomAliasResp(t, alice, roomID, roomAlias) - res = authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "aliases"}) + res = listRoomAliasesResp(t, alice, roomID) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ - match.JSONKeyPresent("aliases"), match.JSONKeyEqual("aliases", []interface{}{roomAlias}), }, }) From a8fc13bbe652b4f0af9b752c22ec8ca4a1c691d0 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 2 Dec 2021 23:40:58 +0100 Subject: [PATCH 2/5] add tests --- tests/csapi/apidoc_room_alias_test.go | 402 +++++++++++++++++++++++++- 1 file changed, 395 insertions(+), 7 deletions(-) diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index 73007999..5d16509b 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -4,39 +4,57 @@ import ( "net/http" "testing" + "github.com/tidwall/gjson" + "github.com/matrix-org/complement/internal/b" "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" ) func setRoomAliasResp(t *testing.T, c *client.CSAPI, roomID, roomAlias string) *http.Response { - return c.MustDoFunc(t, "PUT", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}, client.WithJSONBody(t, map[string]interface{}{ + return c.DoFunc(t, "PUT", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}, client.WithJSONBody(t, map[string]interface{}{ "room_id": roomID, })) } func getRoomAliasResp(t *testing.T, c *client.CSAPI, roomAlias string) *http.Response { - return c.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}) + return c.DoFunc(t, "GET", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}) +} + +func deleteRoomAliasResp(t *testing.T, c *client.CSAPI, roomAlias string) *http.Response { + return c.DoFunc(t, "DELETE", []string{"_matrix", "client", "r0", "directory", "room", roomAlias}) } func listRoomAliasesResp(t *testing.T, c *client.CSAPI, roomID string) *http.Response { - return c.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "aliases"}) + return c.DoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "aliases"}) +} + +func setCanonicalAlias(t *testing.T, c *client.CSAPI, roomID string, roomAlias string, altAliases *[]string) *http.Response { + content := map[string]interface{}{ + "alias": roomAlias, + } + if altAliases != nil { + content["alt_aliases"] = altAliases + } + + return c.DoFunc(t, "PUT", []string{"_matrix", "client", "r0", "rooms", roomID, "state", "m.room.canonical_alias"}, client.WithJSONBody(t, content)) } func TestRoomAlias(t *testing.T) { - deployment := Deploy(t, b.BlueprintAlice) + deployment := Deploy(t, b.BlueprintOneToOneRoom) defer deployment.Destroy(t) alice := deployment.Client(t, "hs1", "@alice:hs1") - t.Run("Parallel", func(t *testing.T) { + t.Run("Parallel", func(t *testing.T) { // sytest: PUT /directory/room/:room_alias creates alias t.Run("PUT /directory/room/:room_alias creates alias", func(t *testing.T) { t.Parallel() roomID := alice.CreateRoom(t, map[string]interface{}{}) - roomAlias := "#room_alias_test:hs1" + roomAlias := "#creates_alias:hs1" setRoomAliasResp(t, alice, roomID, roomAlias) @@ -62,7 +80,7 @@ func TestRoomAlias(t *testing.T) { }, }) - roomAlias := "#room_alias:hs1" + roomAlias := "#lists_aliases:hs1" setRoomAliasResp(t, alice, roomID, roomAlias) @@ -76,3 +94,373 @@ func TestRoomAlias(t *testing.T) { }) }) } + +func TestRoomDeleteAlias(t *testing.T) { + deployment := Deploy(t, b.BlueprintOneToOneRoom) + defer deployment.Destroy(t) + alice := deployment.Client(t, "hs1", "@alice:hs1") + bob := deployment.Client(t, "hs1", "@bob:hs1") + + t.Run("Parallel", func(t *testing.T) { + // sytest: Alias creators can delete alias with no ops + t.Run("Alias creators can delete alias with no ops", func(t *testing.T) { + t.Parallel() + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + bob.JoinRoom(t, roomID, nil) + // todo: replace with `SyncUntilJoined` + bob.SyncUntilTimelineHas(t, roomID, func(event gjson.Result) bool { + return event.Get("type").Str == "m.room.member" && + event.Get("content.membership").Str == "join" && + event.Get("state_key").Str == bob.UserID + }) + + roomAlias := "#no_ops_delete:hs1" + + res := setRoomAliasResp(t, bob, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + // An extra check to make sure we're not being racy rn + res = getRoomAliasResp(t, bob, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyEqual("room_id", roomID), + }, + }) + + res = deleteRoomAliasResp(t, bob, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + }) + + // sytest: Alias creators can delete canonical alias with no ops + t.Run("Alias creators can delete canonical alias with no ops", func(t *testing.T) { + t.Parallel() + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + bob.JoinRoom(t, roomID, nil) + // todo: replace with `SyncUntilJoined` + bob.SyncUntilTimelineHas(t, roomID, func(event gjson.Result) bool { + return event.Get("type").Str == "m.room.member" && + event.Get("content.membership").Str == "join" && + event.Get("state_key").Str == bob.UserID + }) + + roomAlias := "#no_ops_delete:hs1" + + res := setRoomAliasResp(t, bob, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + // An extra check to make sure we're not being racy rn + res = getRoomAliasResp(t, bob, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyEqual("room_id", roomID), + }, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyPresent("event_id"), + }, + }) + + res = deleteRoomAliasResp(t, bob, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + }) + + // sytest: Deleting a non-existent alias should return a 404 + t.Run("Deleting a non-existent alias should return a 404", func(t *testing.T) { + t.Parallel() + + roomAlias := "#scatman_portal:hs1" + + res := deleteRoomAliasResp(t, bob, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_NOT_FOUND"), + }, + }) + }) + + // sytest: Only room members can list aliases of a room + t.Run("Only room members can list aliases of a room", func(t *testing.T) { + t.Parallel() + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + roomAlias := "#room_members_list:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + // An extra check to make sure we're not being racy rn + res = getRoomAliasResp(t, alice, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyEqual("room_id", roomID), + }, + }) + + res = listRoomAliasesResp(t, bob, roomID) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 403, + }) + }) + }) +} + +func TestRoomCanonicalAlias(t *testing.T) { + deployment := Deploy(t, b.BlueprintAlice) + defer deployment.Destroy(t) + alice := deployment.Client(t, "hs1", "@alice:hs1") + + t.Run("Parallel", func(t *testing.T) { + + // The original sytest has been split out into three tests, the test name only pertained to the first. + // sytest: Canonical alias can be set + t.Run("m.room.canonical_alias accepts present aliases", func(t *testing.T) { + + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#accepts_present_aliases:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyPresent("event_id"), + }, + }) + }) + + // part of "Canonical alias can be set" + t.Run("m.room.canonical_alias rejects missing aliases", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2068 + + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#rejects_missing:hs1" + + res := setCanonicalAlias(t, alice, roomID, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_BAD_ALIAS"), + }, + }) + }) + + // part of "Canonical alias can be set" + t.Run("m.room.canonical_alias rejects invalid aliases", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2069 + + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "%invalid_aliases:hs1" + + res := setCanonicalAlias(t, alice, roomID, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_INVALID_PARAM"), + }, + }) + }) + + t.Run("m.room.canonical_alias setting rejects deleted aliases", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2068 + + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#deleted_aliases:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = deleteRoomAliasResp(t, alice, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + // An extra check to make sure we're not being racy rn + res = getRoomAliasResp(t, alice, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 404, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_BAD_ALIAS"), + }, + }) + }) + + t.Run("m.room.canonical_alias rejects alias pointing to different local room", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2068 + + room1 := alice.CreateRoom(t, map[string]interface{}{}) + room2 := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#diffroom1:hs1" + + res := setRoomAliasResp(t, alice, room1, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, room2, roomAlias, nil) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_BAD_ALIAS"), + }, + }) + }) + + // The original sytest has been split out into three tests, the test name only pertained to the first. + // sytest: Canonical alias can include alt_aliases + t.Run("m.room.canonical_alias accepts present alt_aliases", func(t *testing.T) { + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#alt_present_alias:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, &[]string{roomAlias}) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyPresent("event_id"), + }, + }) + }) + + // part of "Canonical alias can include alt_aliases" + t.Run("m.room.canonical_alias rejects missing aliases", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2068 + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#alt_missing:hs1" + wrongRoomAlias := "#alt_missing_wrong:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, &[]string{wrongRoomAlias}) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_BAD_ALIAS"), + }, + }) + }) + + // part of "Canonical alias can include alt_aliases" + t.Run("m.room.canonical_alias rejects invalid aliases", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2069 + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + roomAlias := "#alt_invalid:hs1" + wrongRoomAlias := "%alt_invalid_wrong:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, roomID, roomAlias, &[]string{wrongRoomAlias}) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_INVALID_PARAM"), + }, + }) + }) + + // part of "Canonical alias can include alt_aliases" + t.Run("m.room.canonical_alias rejects alt_alias pointing to different local room", func(t *testing.T) { + runtime.SkipIf(t, runtime.Dendrite) // FIXME https://github.com/matrix-org/dendrite/issues/2068 + + room1 := alice.CreateRoom(t, map[string]interface{}{}) + room2 := alice.CreateRoom(t, map[string]interface{}{}) + + t.Parallel() + + room1Alias := "#alt_room1:hs1" + room2Alias := "#alt_room2:hs1" + + res := setRoomAliasResp(t, alice, room1, room1Alias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setRoomAliasResp(t, alice, room2, room2Alias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + res = setCanonicalAlias(t, alice, room2, room2Alias, &[]string{room1Alias}) + + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 400, + JSON: []match.JSON{ + match.JSONKeyEqual("errcode", "M_BAD_ALIAS"), + }, + }) + }) + }) +} From 79473279607ce85e3e1fdeab9444376b791946ea Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 2 Dec 2021 23:43:05 +0100 Subject: [PATCH 3/5] rearrange test --- tests/csapi/apidoc_room_alias_test.go | 55 ++++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index 5d16509b..af1b7a2b 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -46,6 +46,7 @@ func TestRoomAlias(t *testing.T) { deployment := Deploy(t, b.BlueprintOneToOneRoom) defer deployment.Destroy(t) alice := deployment.Client(t, "hs1", "@alice:hs1") + bob := deployment.Client(t, "hs1", "@bob:hs1") t.Run("Parallel", func(t *testing.T) { // sytest: PUT /directory/room/:room_alias creates alias @@ -92,6 +93,33 @@ func TestRoomAlias(t *testing.T) { }, }) }) + + // sytest: Only room members can list aliases of a room + t.Run("Only room members can list aliases of a room", func(t *testing.T) { + t.Parallel() + roomID := alice.CreateRoom(t, map[string]interface{}{}) + + roomAlias := "#room_members_list:hs1" + + res := setRoomAliasResp(t, alice, roomID, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + }) + + // An extra check to make sure we're not being racy rn + res = getRoomAliasResp(t, alice, roomAlias) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 200, + JSON: []match.JSON{ + match.JSONKeyEqual("room_id", roomID), + }, + }) + + res = listRoomAliasesResp(t, bob, roomID) + must.MatchResponse(t, res, match.HTTPResponse{ + StatusCode: 403, + }) + }) }) } @@ -195,33 +223,6 @@ func TestRoomDeleteAlias(t *testing.T) { }, }) }) - - // sytest: Only room members can list aliases of a room - t.Run("Only room members can list aliases of a room", func(t *testing.T) { - t.Parallel() - roomID := alice.CreateRoom(t, map[string]interface{}{}) - - roomAlias := "#room_members_list:hs1" - - res := setRoomAliasResp(t, alice, roomID, roomAlias) - must.MatchResponse(t, res, match.HTTPResponse{ - StatusCode: 200, - }) - - // An extra check to make sure we're not being racy rn - res = getRoomAliasResp(t, alice, roomAlias) - must.MatchResponse(t, res, match.HTTPResponse{ - StatusCode: 200, - JSON: []match.JSON{ - match.JSONKeyEqual("room_id", roomID), - }, - }) - - res = listRoomAliasesResp(t, bob, roomID) - must.MatchResponse(t, res, match.HTTPResponse{ - StatusCode: 403, - }) - }) }) } From 2191523cfb242980118bb4eaef95a31aa30158af Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 2 Dec 2021 23:59:06 +0100 Subject: [PATCH 4/5] fix test failures --- tests/csapi/apidoc_room_alias_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index af1b7a2b..373a37a4 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -178,7 +178,7 @@ func TestRoomDeleteAlias(t *testing.T) { event.Get("state_key").Str == bob.UserID }) - roomAlias := "#no_ops_delete:hs1" + roomAlias := "#no_ops_delete_canonical:hs1" res := setRoomAliasResp(t, bob, roomID, roomAlias) must.MatchResponse(t, res, match.HTTPResponse{ @@ -217,7 +217,7 @@ func TestRoomDeleteAlias(t *testing.T) { res := deleteRoomAliasResp(t, bob, roomAlias) must.MatchResponse(t, res, match.HTTPResponse{ - StatusCode: 400, + StatusCode: 404, JSON: []match.JSON{ match.JSONKeyEqual("errcode", "M_NOT_FOUND"), }, From 2f776cb34be45860a0e7f28336734ef4225b2e36 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Fri, 3 Dec 2021 00:17:05 +0100 Subject: [PATCH 5/5] fix synapse public_chat weirdness https://github.com/matrix-org/synapse/issues/11498 --- tests/csapi/apidoc_room_alias_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index 373a37a4..a86db07a 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -133,7 +133,9 @@ func TestRoomDeleteAlias(t *testing.T) { // sytest: Alias creators can delete alias with no ops t.Run("Alias creators can delete alias with no ops", func(t *testing.T) { t.Parallel() - roomID := alice.CreateRoom(t, map[string]interface{}{}) + roomID := alice.CreateRoom(t, map[string]interface{}{ + "preset": "public_chat", + }) bob.JoinRoom(t, roomID, nil) // todo: replace with `SyncUntilJoined` @@ -168,7 +170,9 @@ func TestRoomDeleteAlias(t *testing.T) { // sytest: Alias creators can delete canonical alias with no ops t.Run("Alias creators can delete canonical alias with no ops", func(t *testing.T) { t.Parallel() - roomID := alice.CreateRoom(t, map[string]interface{}{}) + roomID := alice.CreateRoom(t, map[string]interface{}{ + "preset": "public_chat", + }) bob.JoinRoom(t, roomID, nil) // todo: replace with `SyncUntilJoined`