Skip to content
Snippets Groups Projects
Commit 950cd561 authored by Travis Ralston's avatar Travis Ralston
Browse files

Finish the upload test

parent 9054f3a8
No related branches found
No related tags found
No related merge requests found
package test package test
import ( import (
"fmt"
"log" "log"
"net/http"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -35,13 +37,28 @@ func (s *UploadTestSuite) TearDownSuite() { ...@@ -35,13 +37,28 @@ func (s *UploadTestSuite) TearDownSuite() {
func (s *UploadTestSuite) TestUpload() { func (s *UploadTestSuite) TestUpload() {
t := s.T() t := s.T()
client := s.deps.Homeservers[0].UnprivilegedUsers[0].WithCsUrl(s.deps.Machines[0].HttpUrl) client1 := s.deps.Homeservers[0].UnprivilegedUsers[0].WithCsUrl(s.deps.Machines[0].HttpUrl)
client2 := &test_internals.MatrixClient{
ClientServerUrl: s.deps.Machines[1].HttpUrl, // deliberately the second machine
ServerName: s.deps.Homeservers[1].ServerName, // deliberately the second machine
AccessToken: "", // no auth for downloads
UserId: "", // no auth for downloads
}
contentType, img, err := test_internals.MakeTestImage(512, 512) contentType, img, err := test_internals.MakeTestImage(512, 512)
res, err := client.Upload("image"+util.ExtensionForContentType(contentType), contentType, img) res, err := client1.Upload("image"+util.ExtensionForContentType(contentType), contentType, img)
assert.NoError(t, err) assert.NoError(t, err)
log.Println(res.MxcUri) // TODO: Test download (from other instance) matches what we uploaded
assert.NotEmpty(t, res.MxcUri) assert.NotEmpty(t, res.MxcUri)
origin, mediaId, err := util.SplitMxc(res.MxcUri)
assert.NoError(t, err)
assert.Equal(t, origin, client1.ServerName)
assert.NotEmpty(t, mediaId)
raw, err := client2.DoRaw("GET", fmt.Sprintf("/_matrix/media/v3/download/%s/%s", origin, mediaId), nil, "", nil)
assert.NoError(t, err)
assert.Equal(t, raw.StatusCode, http.StatusOK)
test_internals.AssertIsTestImage(t, raw.Body)
} }
func TestUploadTestSuite(t *testing.T) { func TestUploadTestSuite(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment