Skip to content

Commit 7b65328

Browse files
committed
address feedback
1 parent d473269 commit 7b65328

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

client/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (c *CSAPI) DownloadContentAuthenticated(t ct.TestLike, mxcUri string) ([]by
152152

153153
// UncheckedDownloadContentAuthenticated makes the raw request for a piece of media and returns the http.Response.
154154
// Response is unchecked in any way. The existing DownloadContentAuthenticated() should have been a "Must" variant. Rather
155-
// than refactor that across the code base, this version just uses an explict name
155+
// than refactor that across the code base, this version just uses an explicit name
156156
func (c *CSAPI) UncheckedDownloadContentAuthenticated(t ct.TestLike, mxcUri string) *http.Response {
157157
t.Helper()
158158
origin, mediaId := SplitMxc(mxcUri)
@@ -635,13 +635,15 @@ func (c *CSAPI) MustGenerateOneTimeKeys(t ct.TestLike, otkCount uint) (deviceKey
635635

636636
// MustSetDisplayName sets the global display name for this account or fails the test.
637637
func (c *CSAPI) MustSetDisplayName(t ct.TestLike, displayname string) {
638+
t.Helper()
638639
c.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "profile", c.UserID, "displayname"}, WithJSONBody(t, map[string]any{
639640
"displayname": displayname,
640641
}))
641642
}
642643

643644
// MustSetDisplayName sets the global display name for this account or fails the test.
644645
func (c *CSAPI) MustSetProfileAvatar(t ct.TestLike, mxcUri string) {
646+
t.Helper()
645647
c.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "profile", c.UserID, "avatar_url"}, WithJSONBody(t, map[string]any{
646648
"avatar_url": mxcUri,
647649
}))

tests/msc3911/cs_api_restricted_media_test.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package tests
22

33
import (
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

Comments
 (0)