summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/client/account/account_test.go21
-rw-r--r--internal/api/client/account/accountverify_test.go2
-rw-r--r--internal/api/client/admin/admin.go2
-rw-r--r--internal/api/client/admin/admin_test.go123
-rw-r--r--internal/api/client/admin/emojicreate.go20
-rw-r--r--internal/api/client/admin/emojicreate_test.go128
-rw-r--r--internal/api/client/fileserver/servefile_test.go8
-rw-r--r--internal/api/client/followrequest/followrequest_test.go17
-rw-r--r--internal/api/client/media/mediacreate_test.go8
-rw-r--r--internal/api/client/status/status_test.go19
-rw-r--r--internal/api/client/user/user_test.go19
-rw-r--r--internal/api/s2s/user/inboxpost_test.go16
-rw-r--r--internal/api/s2s/user/outboxget_test.go12
-rw-r--r--internal/api/s2s/user/repliesget_test.go12
-rw-r--r--internal/api/s2s/user/user_test.go7
-rw-r--r--internal/api/s2s/user/userget_test.go4
-rw-r--r--internal/api/s2s/webfinger/webfinger_test.go7
17 files changed, 345 insertions, 80 deletions
diff --git a/internal/api/client/account/account_test.go b/internal/api/client/account/account_test.go
index b642dbcb4..01c8c9599 100644
--- a/internal/api/client/account/account_test.go
+++ b/internal/api/client/account/account_test.go
@@ -16,6 +16,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
@@ -25,13 +26,14 @@ import (
type AccountStandardTestSuite struct {
// standard suite interfaces
suite.Suite
- db db.DB
- tc typeutils.TypeConverter
- storage *kv.KVStore
- federator federation.Federator
- processor processing.Processor
- emailSender email.Sender
- sentEmails map[string]string
+ db db.DB
+ tc typeutils.TypeConverter
+ storage *kv.KVStore
+ mediaManager media.Manager
+ federator federation.Federator
+ processor processing.Processor
+ emailSender email.Sender
+ sentEmails map[string]string
// standard suite models
testTokens map[string]*gtsmodel.Token
@@ -61,10 +63,11 @@ func (suite *AccountStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage()
testrig.InitTestLog()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.sentEmails = make(map[string]string)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", suite.sentEmails)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.accountModule = account.New(suite.processor).(*account.Module)
testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
diff --git a/internal/api/client/account/accountverify_test.go b/internal/api/client/account/accountverify_test.go
index 702eb0836..b5dfdd5e8 100644
--- a/internal/api/client/account/accountverify_test.go
+++ b/internal/api/client/account/accountverify_test.go
@@ -42,7 +42,7 @@ func (suite *AccountVerifyTestSuite) TestAccountVerifyGet() {
// set up the request
recorder := httptest.NewRecorder()
- ctx := suite.newContext(recorder, http.MethodPatch, nil, account.UpdateCredentialsPath, "")
+ ctx := suite.newContext(recorder, http.MethodGet, nil, account.VerifyPath, "")
// call the handler
suite.accountModule.AccountVerifyGETHandler(ctx)
diff --git a/internal/api/client/admin/admin.go b/internal/api/client/admin/admin.go
index f8ea03cc6..f5256c996 100644
--- a/internal/api/client/admin/admin.go
+++ b/internal/api/client/admin/admin.go
@@ -58,7 +58,7 @@ func New(processor processing.Processor) api.ClientModule {
// Route attaches all routes from this module to the given router
func (m *Module) Route(r router.Router) error {
- r.AttachHandler(http.MethodPost, EmojiPath, m.emojiCreatePOSTHandler)
+ r.AttachHandler(http.MethodPost, EmojiPath, m.EmojiCreatePOSTHandler)
r.AttachHandler(http.MethodPost, DomainBlocksPath, m.DomainBlocksPOSTHandler)
r.AttachHandler(http.MethodGet, DomainBlocksPath, m.DomainBlocksGETHandler)
r.AttachHandler(http.MethodGet, DomainBlocksPathWithID, m.DomainBlockGETHandler)
diff --git a/internal/api/client/admin/admin_test.go b/internal/api/client/admin/admin_test.go
new file mode 100644
index 000000000..da5b03949
--- /dev/null
+++ b/internal/api/client/admin/admin_test.go
@@ -0,0 +1,123 @@
+/*
+ GoToSocial
+ Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+package admin_test
+
+import (
+ "bytes"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+
+ "codeberg.org/gruf/go-store/kv"
+ "github.com/gin-gonic/gin"
+ "github.com/spf13/viper"
+ "github.com/stretchr/testify/suite"
+ "github.com/superseriousbusiness/gotosocial/internal/api/client/admin"
+ "github.com/superseriousbusiness/gotosocial/internal/config"
+ "github.com/superseriousbusiness/gotosocial/internal/db"
+ "github.com/superseriousbusiness/gotosocial/internal/email"
+ "github.com/superseriousbusiness/gotosocial/internal/federation"
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
+ "github.com/superseriousbusiness/gotosocial/internal/oauth"
+ "github.com/superseriousbusiness/gotosocial/internal/processing"
+ "github.com/superseriousbusiness/gotosocial/internal/typeutils"
+ "github.com/superseriousbusiness/gotosocial/testrig"
+)
+
+type AdminStandardTestSuite struct {
+ // standard suite interfaces
+ suite.Suite
+ db db.DB
+ tc typeutils.TypeConverter
+ storage *kv.KVStore
+ mediaManager media.Manager
+ federator federation.Federator
+ processor processing.Processor
+ emailSender email.Sender
+ sentEmails map[string]string
+
+ // standard suite models
+ testTokens map[string]*gtsmodel.Token
+ testClients map[string]*gtsmodel.Client
+ testApplications map[string]*gtsmodel.Application
+ testUsers map[string]*gtsmodel.User
+ testAccounts map[string]*gtsmodel.Account
+ testAttachments map[string]*gtsmodel.MediaAttachment
+ testStatuses map[string]*gtsmodel.Status
+
+ // module being tested
+ adminModule *admin.Module
+}
+
+func (suite *AdminStandardTestSuite) SetupSuite() {
+ suite.testTokens = testrig.NewTestTokens()
+ suite.testClients = testrig.NewTestClients()
+ suite.testApplications = testrig.NewTestApplications()
+ suite.testUsers = testrig.NewTestUsers()
+ suite.testAccounts = testrig.NewTestAccounts()
+ suite.testAttachments = testrig.NewTestAttachments()
+ suite.testStatuses = testrig.NewTestStatuses()
+}
+
+func (suite *AdminStandardTestSuite) SetupTest() {
+ testrig.InitTestConfig()
+ testrig.InitTestLog()
+
+ suite.db = testrig.NewTestDB()
+ suite.storage = testrig.NewTestStorage()
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
+ suite.sentEmails = make(map[string]string)
+ suite.emailSender = testrig.NewEmailSender("../../../../web/template/", suite.sentEmails)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
+ suite.adminModule = admin.New(suite.processor).(*admin.Module)
+ testrig.StandardDBSetup(suite.db, nil)
+ testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
+}
+
+func (suite *AdminStandardTestSuite) TearDownTest() {
+ testrig.StandardDBTeardown(suite.db)
+ testrig.StandardStorageTeardown(suite.storage)
+}
+
+func (suite *AdminStandardTestSuite) newContext(recorder *httptest.ResponseRecorder, requestMethod string, requestBody []byte, requestPath string, bodyContentType string) *gin.Context {
+ ctx, _ := gin.CreateTestContext(recorder)
+
+ ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["admin_account"])
+ ctx.Set(oauth.SessionAuthorizedToken, oauth.DBTokenToToken(suite.testTokens["admin_account"]))
+ ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["admin_account"])
+ ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["admin_account"])
+
+ protocol := viper.GetString(config.Keys.Protocol)
+ host := viper.GetString(config.Keys.Host)
+
+ baseURI := fmt.Sprintf("%s://%s", protocol, host)
+ requestURI := fmt.Sprintf("%s/%s", baseURI, requestPath)
+
+ ctx.Request = httptest.NewRequest(http.MethodPatch, requestURI, bytes.NewReader(requestBody)) // the endpoint we're hitting
+
+ if bodyContentType != "" {
+ ctx.Request.Header.Set("Content-Type", bodyContentType)
+ }
+
+ ctx.Request.Header.Set("accept", "application/json")
+
+ return ctx
+}
diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go
index 617add413..ef42d0a13 100644
--- a/internal/api/client/admin/emojicreate.go
+++ b/internal/api/client/admin/emojicreate.go
@@ -27,12 +27,11 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/validate"
)
-// emojiCreateRequest swagger:operation POST /api/v1/admin/custom_emojis emojiCreate
+// EmojiCreatePOSTHandler swagger:operation POST /api/v1/admin/custom_emojis emojiCreate
//
// Upload and create a new instance emoji.
//
@@ -74,7 +73,9 @@ import (
// description: forbidden
// '400':
// description: bad request
-func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
+// '409':
+// description: conflict -- domain/shortcode combo for emoji already exists
+func (m *Module) EmojiCreatePOSTHandler(c *gin.Context) {
l := logrus.WithFields(logrus.Fields{
"func": "emojiCreatePOSTHandler",
"request_uri": c.Request.RequestURI,
@@ -117,10 +118,10 @@ func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
return
}
- apiEmoji, err := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form)
- if err != nil {
- l.Debugf("error creating emoji: %s", err)
- c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ apiEmoji, errWithCode := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form)
+ if errWithCode != nil {
+ l.Debugf("error creating emoji: %s", errWithCode.Error())
+ c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})
return
}
@@ -133,10 +134,5 @@ func validateCreateEmoji(form *model.EmojiCreateRequest) error {
return errors.New("no emoji given")
}
- // a very superficial check to see if the media size limit is exceeded
- if form.Image.Size > media.EmojiMaxBytes {
- return fmt.Errorf("file size limit exceeded: limit is %d bytes but emoji was %d bytes", media.EmojiMaxBytes, form.Image.Size)
- }
-
return validate.EmojiShortcode(form.Shortcode)
}
diff --git a/internal/api/client/admin/emojicreate_test.go b/internal/api/client/admin/emojicreate_test.go
new file mode 100644
index 000000000..2b7476da1
--- /dev/null
+++ b/internal/api/client/admin/emojicreate_test.go
@@ -0,0 +1,128 @@
+package admin_test
+
+import (
+ "context"
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/stretchr/testify/suite"
+ "github.com/superseriousbusiness/gotosocial/internal/api/client/admin"
+ apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
+ "github.com/superseriousbusiness/gotosocial/internal/db"
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/testrig"
+)
+
+type EmojiCreateTestSuite struct {
+ AdminStandardTestSuite
+}
+
+func (suite *EmojiCreateTestSuite) TestEmojiCreate() {
+ // set up the request
+ requestBody, w, err := testrig.CreateMultipartFormData(
+ "image", "../../../../testrig/media/rainbow-original.png",
+ map[string]string{
+ "shortcode": "new_emoji",
+ })
+ if err != nil {
+ panic(err)
+ }
+ bodyBytes := requestBody.Bytes()
+ recorder := httptest.NewRecorder()
+ ctx := suite.newContext(recorder, http.MethodPost, bodyBytes, admin.EmojiPath, w.FormDataContentType())
+
+ // call the handler
+ suite.adminModule.EmojiCreatePOSTHandler(ctx)
+
+ // 1. we should have OK because our request was valid
+ suite.Equal(http.StatusOK, recorder.Code)
+
+ // 2. we should have no error message in the result body
+ result := recorder.Result()
+ defer result.Body.Close()
+
+ // check the response
+ b, err := ioutil.ReadAll(result.Body)
+ suite.NoError(err)
+ suite.NotEmpty(b)
+
+ // response should be an api model emoji
+ apiEmoji := &apimodel.Emoji{}
+ err = json.Unmarshal(b, apiEmoji)
+ suite.NoError(err)
+
+ // appropriate fields should be set
+ suite.Equal("new_emoji", apiEmoji.Shortcode)
+ suite.NotEmpty(apiEmoji.URL)
+ suite.NotEmpty(apiEmoji.StaticURL)
+ suite.True(apiEmoji.VisibleInPicker)
+
+ // emoji should be in the db
+ dbEmoji := &gtsmodel.Emoji{}
+ err = suite.db.GetWhere(context.Background(), []db.Where{{Key: "shortcode", Value: "new_emoji"}}, dbEmoji)
+ suite.NoError(err)
+
+ // check fields on the emoji
+ suite.NotEmpty(dbEmoji.ID)
+ suite.Equal("new_emoji", dbEmoji.Shortcode)
+ suite.Empty(dbEmoji.Domain)
+ suite.Empty(dbEmoji.ImageRemoteURL)
+ suite.Empty(dbEmoji.ImageStaticRemoteURL)
+ suite.Equal(apiEmoji.URL, dbEmoji.ImageURL)
+ suite.Equal(apiEmoji.StaticURL, dbEmoji.ImageStaticURL)
+ suite.NotEmpty(dbEmoji.ImagePath)
+ suite.NotEmpty(dbEmoji.ImageStaticPath)
+ suite.Equal("image/png", dbEmoji.ImageContentType)
+ suite.Equal("image/png", dbEmoji.ImageStaticContentType)
+ suite.Equal(36702, dbEmoji.ImageFileSize)
+ suite.Equal(10413, dbEmoji.ImageStaticFileSize)
+ suite.False(dbEmoji.Disabled)
+ suite.NotEmpty(dbEmoji.URI)
+ suite.True(dbEmoji.VisibleInPicker)
+ suite.Empty(dbEmoji.CategoryID)
+
+ // emoji should be in storage
+ emojiBytes, err := suite.storage.Get(dbEmoji.ImagePath)
+ suite.NoError(err)
+ suite.Len(emojiBytes, dbEmoji.ImageFileSize)
+ emojiStaticBytes, err := suite.storage.Get(dbEmoji.ImageStaticPath)
+ suite.NoError(err)
+ suite.Len(emojiStaticBytes, dbEmoji.ImageStaticFileSize)
+}
+
+func (suite *EmojiCreateTestSuite) TestEmojiCreateAlreadyExists() {
+ // set up the request -- use a shortcode that already exists for an emoji in the database
+ requestBody, w, err := testrig.CreateMultipartFormData(
+ "image", "../../../../testrig/media/rainbow-original.png",
+ map[string]string{
+ "shortcode": "rainbow",
+ })
+ if err != nil {
+ panic(err)
+ }
+ bodyBytes := requestBody.Bytes()
+ recorder := httptest.NewRecorder()
+ ctx := suite.newContext(recorder, http.MethodPost, bodyBytes, admin.EmojiPath, w.FormDataContentType())
+
+ // call the handler
+ suite.adminModule.EmojiCreatePOSTHandler(ctx)
+
+ suite.Equal(http.StatusConflict, recorder.Code)
+
+ result := recorder.Result()
+ defer result.Body.Close()
+
+ // check the response
+ b, err := ioutil.ReadAll(result.Body)
+ suite.NoError(err)
+ suite.NotEmpty(b)
+
+ suite.Equal(`{"error":"conflict: emoji with shortcode rainbow already exists"}`, string(b))
+}
+
+func TestEmojiCreateTestSuite(t *testing.T) {
+ suite.Run(t, &EmojiCreateTestSuite{})
+}
diff --git a/internal/api/client/fileserver/servefile_test.go b/internal/api/client/fileserver/servefile_test.go
index 18f54542a..5cd4b529b 100644
--- a/internal/api/client/fileserver/servefile_test.go
+++ b/internal/api/client/fileserver/servefile_test.go
@@ -51,7 +51,7 @@ type ServeFileTestSuite struct {
federator federation.Federator
tc typeutils.TypeConverter
processor processing.Processor
- mediaHandler media.Handler
+ mediaManager media.Manager
oauthServer oauth.Server
emailSender email.Sender
@@ -77,12 +77,12 @@ func (suite *ServeFileTestSuite) SetupSuite() {
testrig.InitTestLog()
suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, testrig.NewTestMediaManager(suite.db, suite.storage))
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, testrig.NewTestMediaManager(suite.db, suite.storage))
suite.tc = testrig.NewTestTypeConverter(suite.db)
- suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
// setup module being tested
diff --git a/internal/api/client/followrequest/followrequest_test.go b/internal/api/client/followrequest/followrequest_test.go
index 2d327f461..36b4912e9 100644
--- a/internal/api/client/followrequest/followrequest_test.go
+++ b/internal/api/client/followrequest/followrequest_test.go
@@ -33,6 +33,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/testrig"
@@ -40,11 +41,12 @@ import (
type FollowRequestStandardTestSuite struct {
suite.Suite
- db db.DB
- storage *kv.KVStore
- federator federation.Federator
- processor processing.Processor
- emailSender email.Sender
+ db db.DB
+ storage *kv.KVStore
+ mediaManager media.Manager
+ federator federation.Federator
+ processor processing.Processor
+ emailSender email.Sender
// standard suite models
testTokens map[string]*gtsmodel.Token
@@ -74,9 +76,10 @@ func (suite *FollowRequestStandardTestSuite) SetupTest() {
testrig.InitTestLog()
suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.followRequestModule = followrequest.New(suite.processor).(*followrequest.Module)
testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
diff --git a/internal/api/client/media/mediacreate_test.go b/internal/api/client/media/mediacreate_test.go
index 2d8042e33..ca0b6483f 100644
--- a/internal/api/client/media/mediacreate_test.go
+++ b/internal/api/client/media/mediacreate_test.go
@@ -54,9 +54,9 @@ type MediaCreateTestSuite struct {
suite.Suite
db db.DB
storage *kv.KVStore
+ mediaManager media.Manager
federator federation.Federator
tc typeutils.TypeConverter
- mediaHandler media.Handler
oauthServer oauth.Server
emailSender email.Sender
processor processing.Processor
@@ -84,11 +84,11 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage()
suite.tc = testrig.NewTestTypeConverter(suite.db)
- suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
// setup module being tested
suite.mediaModule = mediamodule.New(suite.processor).(*mediamodule.Module)
diff --git a/internal/api/client/status/status_test.go b/internal/api/client/status/status_test.go
index dd037f6f4..c6e5b354f 100644
--- a/internal/api/client/status/status_test.go
+++ b/internal/api/client/status/status_test.go
@@ -26,6 +26,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/testrig"
@@ -34,12 +35,13 @@ import (
type StatusStandardTestSuite struct {
// standard suite interfaces
suite.Suite
- db db.DB
- tc typeutils.TypeConverter
- federator federation.Federator
- emailSender email.Sender
- processor processing.Processor
- storage *kv.KVStore
+ db db.DB
+ tc typeutils.TypeConverter
+ mediaManager media.Manager
+ federator federation.Federator
+ emailSender email.Sender
+ processor processing.Processor
+ storage *kv.KVStore
// standard suite models
testTokens map[string]*gtsmodel.Token
@@ -70,9 +72,10 @@ func (suite *StatusStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB()
suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.storage = testrig.NewTestStorage()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.statusModule = status.New(suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
diff --git a/internal/api/client/user/user_test.go b/internal/api/client/user/user_test.go
index d60bf2f1a..e84a78cde 100644
--- a/internal/api/client/user/user_test.go
+++ b/internal/api/client/user/user_test.go
@@ -26,6 +26,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/testrig"
@@ -33,12 +34,13 @@ import (
type UserStandardTestSuite struct {
suite.Suite
- db db.DB
- tc typeutils.TypeConverter
- federator federation.Federator
- emailSender email.Sender
- processor processing.Processor
- storage *kv.KVStore
+ db db.DB
+ tc typeutils.TypeConverter
+ mediaManager media.Manager
+ federator federation.Federator
+ emailSender email.Sender
+ processor processing.Processor
+ storage *kv.KVStore
testTokens map[string]*gtsmodel.Token
testClients map[string]*gtsmodel.Client
@@ -62,10 +64,11 @@ func (suite *UserStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage()
suite.tc = testrig.NewTestTypeConverter(suite.db)
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.sentEmails = make(map[string]string)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", suite.sentEmails)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.userModule = user.New(suite.processor).(*user.Module)
testrig.StandardDBSetup(suite.db, suite.testAccounts)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
diff --git a/internal/api/s2s/user/inboxpost_test.go b/internal/api/s2s/user/inboxpost_test.go
index 7cd9ce93a..2f43799c8 100644
--- a/internal/api/s2s/user/inboxpost_test.go
+++ b/internal/api/s2s/user/inboxpost_test.go
@@ -84,9 +84,9 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
body := bytes.NewReader(bodyJson)
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -184,9 +184,9 @@ func (suite *InboxPostTestSuite) TestPostUnblock() {
body := bytes.NewReader(bodyJson)
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -274,9 +274,9 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
body := bytes.NewReader(bodyJson)
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -393,9 +393,9 @@ func (suite *InboxPostTestSuite) TestPostDelete() {
body := bytes.NewReader(bodyJson)
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
err = processor.Start(context.Background())
suite.NoError(err)
userModule := user.New(processor).(*user.Module)
diff --git a/internal/api/s2s/user/outboxget_test.go b/internal/api/s2s/user/outboxget_test.go
index 2591a80f1..3f5b54c07 100644
--- a/internal/api/s2s/user/outboxget_test.go
+++ b/internal/api/s2s/user/outboxget_test.go
@@ -45,9 +45,9 @@ func (suite *OutboxGetTestSuite) TestGetOutbox() {
targetAccount := suite.testAccounts["local_account_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -100,9 +100,9 @@ func (suite *OutboxGetTestSuite) TestGetOutboxFirstPage() {
targetAccount := suite.testAccounts["local_account_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -155,9 +155,9 @@ func (suite *OutboxGetTestSuite) TestGetOutboxNextPage() {
targetAccount := suite.testAccounts["local_account_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
diff --git a/internal/api/s2s/user/repliesget_test.go b/internal/api/s2s/user/repliesget_test.go
index d128e30da..81249091c 100644
--- a/internal/api/s2s/user/repliesget_test.go
+++ b/internal/api/s2s/user/repliesget_test.go
@@ -48,9 +48,9 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
targetStatus := suite.testStatuses["local_account_1_status_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -109,9 +109,9 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
targetStatus := suite.testStatuses["local_account_1_status_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
@@ -173,9 +173,9 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
targetStatus := suite.testStatuses["local_account_1_status_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
diff --git a/internal/api/s2s/user/user_test.go b/internal/api/s2s/user/user_test.go
index 43b835165..b1be59073 100644
--- a/internal/api/s2s/user/user_test.go
+++ b/internal/api/s2s/user/user_test.go
@@ -27,6 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
@@ -38,6 +39,7 @@ type UserStandardTestSuite struct {
suite.Suite
db db.DB
tc typeutils.TypeConverter
+ mediaManager media.Manager
federator federation.Federator
emailSender email.Sender
processor processing.Processor
@@ -77,9 +79,10 @@ func (suite *UserStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB()
suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.storage = testrig.NewTestStorage()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.userModule = user.New(suite.processor).(*user.Module)
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
suite.securityModule = security.New(suite.db, suite.oauthServer).(*security.Module)
diff --git a/internal/api/s2s/user/userget_test.go b/internal/api/s2s/user/userget_test.go
index 2f3109c92..a764f6993 100644
--- a/internal/api/s2s/user/userget_test.go
+++ b/internal/api/s2s/user/userget_test.go
@@ -46,9 +46,9 @@ func (suite *UserGetTestSuite) TestGetUser() {
targetAccount := suite.testAccounts["local_account_1"]
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
- federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
+ federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
- processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender)
+ processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager)
userModule := user.New(processor).(*user.Module)
// setup request
diff --git a/internal/api/s2s/webfinger/webfinger_test.go b/internal/api/s2s/webfinger/webfinger_test.go
index 7e57f7e45..d7b1647b0 100644
--- a/internal/api/s2s/webfinger/webfinger_test.go
+++ b/internal/api/s2s/webfinger/webfinger_test.go
@@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/email"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
@@ -43,6 +44,7 @@ type WebfingerStandardTestSuite struct {
suite.Suite
db db.DB
tc typeutils.TypeConverter
+ mediaManager media.Manager
federator federation.Federator
emailSender email.Sender
processor processing.Processor
@@ -80,9 +82,10 @@ func (suite *WebfingerStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB()
suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.storage = testrig.NewTestStorage()
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
+ suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage, suite.mediaManager)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
- suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender)
+ suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager)
suite.webfingerModule = webfinger.New(suite.processor).(*webfinger.Module)
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
suite.securityModule = security.New(suite.db, suite.oauthServer).(*security.Module)