@@ -2,7 +2,6 @@ package tests
22
33import (
44 "bytes"
5- "strings"
65 "testing"
76
87 "github.com/matrix-org/complement"
@@ -245,19 +244,9 @@ func TestRestrictedMediaUnstable(t *testing.T) {
245244 // it's []byte is available at aliceOriginalProfileBytes
246245 // We will reuse that and copy it
247246
248- // There seem to be no existing utilities to split an mxc uri into it's components, which is needed for the copy endpoint.
249- // Mxc uri's are formatted as "mxc://server_name/media_id"
250-
251- // Cut the "mxc://" off the front
252- existSplitMxc , found := strings .CutPrefix (aliceGlobalProfileAvatarMxcUri , "mxc://" )
253- if ! found {
254- t .Fatalf ("mxc was malformed %s" , aliceGlobalProfileAvatarMxcUri )
255- }
256- // Split the remaining into the server name and the media id
257- mxcComponents := strings .Split (existSplitMxc , "/" )
258-
247+ originalOrigin , originalMediaID := client .SplitMxc (aliceGlobalProfileAvatarMxcUri )
259248 // Use bob to make the copy. The media should be viewable as it's a global profile
260- res := bob .MustDo (t , "POST" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc3911" , "media" , "copy" , mxcComponents [ 0 ], mxcComponents [ 1 ] }, client .WithJSONBody (t , map [string ]any {}))
249+ res := bob .MustDo (t , "POST" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc3911" , "media" , "copy" , originalOrigin , originalMediaID }, client .WithJSONBody (t , map [string ]any {}))
261250
262251 body := client .ParseJSON (t , res )
263252 newMxcUri := client .GetJSONFieldStr (t , body , "content_uri" )
@@ -267,6 +256,9 @@ func TestRestrictedMediaUnstable(t *testing.T) {
267256 t .Fatalf ("Media is differing and should be identical" )
268257 }
269258
259+ if newMxcUri == aliceGlobalProfileAvatarMxcUri {
260+ t .Fatalf ("MXC match and should be different" )
261+ }
270262 })
271263
272264 t .Run ("TestMediaCopyNonexistingFile" , func (t * testing.T ) {
0 commit comments