Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip tests requiring unauthenticated media on Synapse #747

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/csapi/apidoc_content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 14 additions & 9 deletions tests/media_filename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestMediaFilenames(t *testing.T) {
var filename = filename

t.Run(fmt.Sprintf("Can download file '%s'", filename), func(t *testing.T) {
runtime.SkipIf(t, runtime.Synapse)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we would want to keep these tests but change them to use authentication?

I think I'd prefer to disable authenticated media when testing with complement rather than not test these paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests already exist with authentication, see e.g. L56 for this one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, fair enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment or something like "Synapse doesn't support unauthenticated media anymore"?

t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, filename, "image/png")
Expand Down Expand Up @@ -69,6 +70,7 @@ 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) {
runtime.SkipIf(t, runtime.Synapse)
t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, asciiFileName, "image/png")
Expand Down Expand Up @@ -107,6 +109,7 @@ 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) {
runtime.SkipIf(t, runtime.Synapse)
t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
Expand Down Expand Up @@ -136,6 +139,7 @@ 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) {
runtime.SkipIf(t, runtime.Synapse)
t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
Expand All @@ -161,6 +165,7 @@ 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) {
runtime.SkipIf(t, runtime.Synapse)
t.Parallel()

mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
Expand All @@ -185,11 +190,11 @@ 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")
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
}
t.Parallel()

Expand Down Expand Up @@ -221,11 +226,11 @@ 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")
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
}
t.Parallel()

Expand Down Expand Up @@ -259,11 +264,11 @@ 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")
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
}
t.Parallel()

Expand Down
3 changes: 3 additions & 0 deletions tests/media_nofilename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ 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) {
runtime.SkipIf(t, runtime.Synapse)

deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)

Expand Down
13 changes: 10 additions & 3 deletions tests/media_thumbnail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ 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) {
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)
Expand All @@ -57,7 +61,10 @@ 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) {
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)
Expand Down Expand Up @@ -94,7 +101,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"},
Expand Down
Loading