Skip to content

Commit 9e9f6d3

Browse files
authored
Skip tests requiring unauthenticated media on Synapse (#747)
These will be expected to fail when Synapse enforces authenticated media by default in element-hq/synapse#17889
1 parent fde26d9 commit 9e9f6d3

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

tests/csapi/apidoc_content_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ import (
88
"github.com/matrix-org/complement"
99
"github.com/matrix-org/complement/helpers"
1010
"github.com/matrix-org/complement/internal/data"
11+
"github.com/matrix-org/complement/runtime"
1112
)
1213

1314
func TestContent(t *testing.T) {
15+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
16+
runtime.SkipIf(t, runtime.Synapse)
17+
1418
deployment := complement.Deploy(t, 1)
1519
defer deployment.Destroy(t)
1620

tests/media_filename_test.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func TestMediaFilenames(t *testing.T) {
4141
var filename = filename
4242

4343
t.Run(fmt.Sprintf("Can download file '%s'", filename), func(t *testing.T) {
44+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
45+
runtime.SkipIf(t, runtime.Synapse)
4446
t.Parallel()
4547

4648
mxcUri := alice.UploadContent(t, data.MatrixPng, filename, "image/png")
@@ -69,6 +71,8 @@ func TestMediaFilenames(t *testing.T) {
6971

7072
// sytest: Can download specifying a different ASCII file name
7173
t.Run("Can download specifying a different ASCII file name", func(t *testing.T) {
74+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
75+
runtime.SkipIf(t, runtime.Synapse)
7276
t.Parallel()
7377

7478
mxcUri := alice.UploadContent(t, data.MatrixPng, asciiFileName, "image/png")
@@ -107,6 +111,8 @@ func TestMediaFilenames(t *testing.T) {
107111

108112
// sytest: Can download specifying a different Unicode file name
109113
t.Run("Can download specifying a different Unicode file name", func(t *testing.T) {
114+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
115+
runtime.SkipIf(t, runtime.Synapse)
110116
t.Parallel()
111117

112118
mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
@@ -136,6 +142,8 @@ func TestMediaFilenames(t *testing.T) {
136142

137143
// sytest: Can download with Unicode file name locally
138144
t.Run("Can download with Unicode file name locally", func(t *testing.T) {
145+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
146+
runtime.SkipIf(t, runtime.Synapse)
139147
t.Parallel()
140148

141149
mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
@@ -161,6 +169,8 @@ func TestMediaFilenames(t *testing.T) {
161169

162170
// sytest: Can download with Unicode file name over federation
163171
t.Run("Can download with Unicode file name over federation", func(t *testing.T) {
172+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
173+
runtime.SkipIf(t, runtime.Synapse)
164174
t.Parallel()
165175

166176
mxcUri := alice.UploadContent(t, data.MatrixPng, unicodeFileName, "image/png")
@@ -185,11 +195,12 @@ func TestMediaFilenames(t *testing.T) {
185195
})
186196

187197
t.Run("Will serve safe media types as inline", func(t *testing.T) {
188-
if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit {
198+
if runtime.Homeserver != runtime.Conduwuit {
189199
// We need to check that this security behaviour is being correctly run in
190-
// Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume
200+
// conduwuit, but since this is not part of the Matrix spec we do not assume
191201
// other homeservers are doing so.
192-
t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver")
202+
// Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default
203+
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
193204
}
194205
t.Parallel()
195206

@@ -221,11 +232,12 @@ func TestMediaFilenames(t *testing.T) {
221232
})
222233

223234
t.Run("Will serve safe media types with parameters as inline", func(t *testing.T) {
224-
if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit {
235+
if runtime.Homeserver != runtime.Conduwuit {
225236
// We need to check that this security behaviour is being correctly run in
226-
// Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume
237+
// conduwuit, but since this is not part of the Matrix spec we do not assume
227238
// other homeservers are doing so.
228-
t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver")
239+
// Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default
240+
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
229241
}
230242
t.Parallel()
231243

@@ -259,11 +271,12 @@ func TestMediaFilenames(t *testing.T) {
259271
})
260272

261273
t.Run("Will serve unsafe media types as attachments", func(t *testing.T) {
262-
if runtime.Homeserver != runtime.Synapse && runtime.Homeserver != runtime.Conduwuit {
274+
if runtime.Homeserver != runtime.Conduwuit {
263275
// We need to check that this security behaviour is being correctly run in
264-
// Synapse or conduwuit, but since this is not part of the Matrix spec we do not assume
276+
// conduwuit, but since this is not part of the Matrix spec we do not assume
265277
// other homeservers are doing so.
266-
t.Skip("Skipping test of Content-Disposition header requirements on non-Synapse and non-conduwuit homeserver")
278+
// Skip Synapse because it no longer allows downloads over the unauthenticated media endpoints by default
279+
t.Skip("Skipping test of Content-Disposition header requirements on non-conduwuit homeserver")
267280
}
268281
t.Parallel()
269282

tests/media_nofilename_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import (
1010
"github.com/matrix-org/complement/federation"
1111
"github.com/matrix-org/complement/helpers"
1212
"github.com/matrix-org/complement/must"
13+
"github.com/matrix-org/complement/runtime"
1314
)
1415

1516
// Can handle uploads and remote/local downloads without a file name
1617
func TestMediaWithoutFileName(t *testing.T) {
18+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
19+
runtime.SkipIf(t, runtime.Synapse)
20+
1721
deployment := complement.Deploy(t, 1)
1822
defer deployment.Destroy(t)
1923

tests/media_thumbnail_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ func TestLocalPngThumbnail(t *testing.T) {
3636

3737
uri := alice.UploadContent(t, data.LargePng, fileName, contentType)
3838

39-
fetchAndValidateThumbnail(t, alice, uri, false)
39+
t.Run("test /_matrix/media/v3 endpoint", func(t *testing.T) {
40+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
41+
runtime.SkipIf(t, runtime.Synapse)
42+
fetchAndValidateThumbnail(t, alice, uri, false)
43+
})
44+
4045
t.Run("test /_matrix/client/v1/media endpoint", func(t *testing.T) {
4146
runtime.SkipIf(t, runtime.Dendrite)
4247
fetchAndValidateThumbnail(t, alice, uri, true)
@@ -57,7 +62,11 @@ func TestRemotePngThumbnail(t *testing.T) {
5762

5863
uri := alice.UploadContent(t, data.LargePng, fileName, contentType)
5964

60-
fetchAndValidateThumbnail(t, bob, uri, false)
65+
t.Run("test /_matrix/media/v3 endpoint", func(t *testing.T) {
66+
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
67+
runtime.SkipIf(t, runtime.Synapse)
68+
fetchAndValidateThumbnail(t, bob, uri, false)
69+
})
6170

6271
t.Run("test /_matrix/client/v1/media endpoint", func(t *testing.T) {
6372
runtime.SkipIf(t, runtime.Dendrite)
@@ -94,7 +103,7 @@ func TestFederationThumbnail(t *testing.T) {
94103
uri := alice.UploadContent(t, data.LargePng, fileName, contentType)
95104
mediaOrigin, mediaId := client.SplitMxc(uri)
96105

97-
path := []string{"_matrix", "media", "v3", "thumbnail", mediaOrigin, mediaId}
106+
path := []string{"_matrix", "client", "v1", "media", "thumbnail", mediaOrigin, mediaId}
98107
res := alice.MustDo(t, "GET", path, client.WithQueries(url.Values{
99108
"width": []string{"32"},
100109
"height": []string{"32"},

0 commit comments

Comments
 (0)