diff --git a/tests/csapi/apidoc_content_test.go b/tests/csapi/apidoc_content_test.go index be8724c1..522f6e2e 100644 --- a/tests/csapi/apidoc_content_test.go +++ b/tests/csapi/apidoc_content_test.go @@ -8,9 +8,13 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" + "github.com/matrix-org/complement/runtime" ) func TestContent(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) diff --git a/tests/media_filename_test.go b/tests/media_filename_test.go index 709174f2..d5a857d5 100644 --- a/tests/media_filename_test.go +++ b/tests/media_filename_test.go @@ -41,6 +41,8 @@ func TestMediaFilenames(t *testing.T) { var filename = filename t.Run(fmt.Sprintf("Can download file '%s'", filename), func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) t.Parallel() mxcUri := alice.UploadContent(t, data.MatrixPng, filename, "image/png") @@ -69,6 +71,8 @@ func TestMediaFilenames(t *testing.T) { // sytest: Can download specifying a different ASCII file name t.Run("Can download specifying a different ASCII file name", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) t.Parallel() mxcUri := alice.UploadContent(t, data.MatrixPng, asciiFileName, "image/png") @@ -107,6 +111,8 @@ func TestMediaFilenames(t *testing.T) { // sytest: Can download specifying a different Unicode file name t.Run("Can download specifying a different Unicode file name", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) t.Parallel() mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png") @@ -136,6 +142,8 @@ func TestMediaFilenames(t *testing.T) { // sytest: Can download with Unicode file name locally t.Run("Can download with Unicode file name locally", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) t.Parallel() mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png") @@ -161,6 +169,8 @@ func TestMediaFilenames(t *testing.T) { // sytest: Can download with Unicode file name over federation t.Run("Can download with Unicode file name over federation", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) t.Parallel() mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png") @@ -185,11 +195,12 @@ func TestMediaFilenames(t *testing.T) { }) t.Run("Will serve safe media types as inline", func(t *testing.T) { - if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit { + if runtime.Homeserver != runtime.Conduwuit { // We need to check that this security behaviour is being correctly run in - // Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume + // conduwuit, but since this is not part of the Matrix spec we do not assume // other homeservers are doing so. - t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver") + // Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default + t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver") } t.Parallel() @@ -221,11 +232,12 @@ func TestMediaFilenames(t *testing.T) { }) t.Run("Will serve safe media types with parameters as inline", func(t *testing.T) { - if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit { + if runtime.Homeserver != runtime.Conduwuit { // We need to check that this security behaviour is being correctly run in - // Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume + // conduwuit, but since this is not part of the Matrix spec we do not assume // other homeservers are doing so. - t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver") + // Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default + t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver") } t.Parallel() @@ -259,11 +271,12 @@ func TestMediaFilenames(t *testing.T) { }) t.Run("Will serve unsafe media types as attachments", func(t *testing.T) { - if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit { + if runtime.Homeserver != runtime.Conduwuit { // We need to check that this security behaviour is being correctly run in - // Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume + // conduwuit, but since this is not part of the Matrix spec we do not assume // other homeservers are doing so. - t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver") + // Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default + t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver") } t.Parallel() diff --git a/tests/media_nofilename_test.go b/tests/media_nofilename_test.go index e7042bae..d72791af 100644 --- a/tests/media_nofilename_test.go +++ b/tests/media_nofilename_test.go @@ -10,10 +10,14 @@ import ( "github.com/matrix-org/complement/federation" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/must" + "github.com/matrix-org/complement/runtime" ) // Can handle uploads and remote/local downloads without a file name func TestMediaWithoutFileName(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) diff --git a/tests/media_thumbnail_test.go b/tests/media_thumbnail_test.go index 19a8cb5b..03f9cc8d 100644 --- a/tests/media_thumbnail_test.go +++ b/tests/media_thumbnail_test.go @@ -36,7 +36,12 @@ func TestLocalPngThumbnail(t *testing.T) { uri := alice.UploadContent(t, data.LargePng, fileName, contentType) - fetchAndValidateThumbnail(t, alice, uri, false) + t.Run("test /_matrix/media/v3 endpoint", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) + fetchAndValidateThumbnail(t, alice, uri, false) + }) + t.Run("test /_matrix/client/v1/media endpoint", func(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) fetchAndValidateThumbnail(t, alice, uri, true) @@ -57,7 +62,11 @@ func TestRemotePngThumbnail(t *testing.T) { uri := alice.UploadContent(t, data.LargePng, fileName, contentType) - fetchAndValidateThumbnail(t, bob, uri, false) + t.Run("test /_matrix/media/v3 endpoint", func(t *testing.T) { + // Synapse no longer allows downloads over the unauthenticated media endpoints by default + runtime.SkipIf(t, runtime.Synapse) + fetchAndValidateThumbnail(t, bob, uri, false) + }) t.Run("test /_matrix/client/v1/media endpoint", func(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) @@ -94,7 +103,7 @@ func TestFederationThumbnail(t *testing.T) { uri := alice.UploadContent(t, data.LargePng, fileName, contentType) mediaOrigin, mediaId := client.SplitMxc(uri) - path := []string{"_matrix", "media", "v3", "thumbnail", mediaOrigin, mediaId} + path := []string{"_matrix", "client", "v1", "media", "thumbnail", mediaOrigin, mediaId} res := alice.MustDo(t, "GET", path, client.WithQueries(url.Values{ "width": []string{"32"}, "height": []string{"32"},