mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2024-11-23 21:03:19 +00:00
2aaec82732
* add smtp configuration * add email confirm + reset templates * add email sender to testrig * flesh out the email sender interface * go fmt * golint * update from field with more clarity * tidy up the email formatting * fix tests * add email sender to processor * tidy client api processing a bit * further tidying in fromClientAPI * pin new account to user * send msg to processor on new account creation * generate confirm email uri * remove emailer from account processor again * add processCreateAccountFromClientAPI * move emailer accountprocessor => userprocessor * add email sender to user processor * SendConfirmEmail function * add noop email sender * use noop email sender in tests * only assemble message if callback is not nil * use noop email sender if no smtp host is defined * minify email html before sending * fix wrong email address * email confirm test * fmt * serve web hndler * add email confirm handler * init test log properly on testrig * log emails that *would* have been sent * go fmt ./... * unexport confirm email handler * updatedAt * test confirm email function * don't allow tokens older than 7 days * change error message a bit * add basic smtp docs * add a few more snippets * typo * add email sender to outbox tests * don't use dutch wikipedia link * don't minify email html
100 lines
4.1 KiB
Go
100 lines
4.1 KiB
Go
/*
|
|
GoToSocial
|
|
Copyright (C) 2021 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 account_test
|
|
|
|
import (
|
|
"git.iim.gay/grufwub/go-store/kv"
|
|
"github.com/go-fed/activity/pub"
|
|
"github.com/stretchr/testify/suite"
|
|
"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/messages"
|
|
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
|
"github.com/superseriousbusiness/gotosocial/internal/processing/account"
|
|
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
|
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
|
"github.com/superseriousbusiness/gotosocial/testrig"
|
|
)
|
|
|
|
type AccountStandardTestSuite struct {
|
|
// standard suite interfaces
|
|
suite.Suite
|
|
config *config.Config
|
|
db db.DB
|
|
tc typeutils.TypeConverter
|
|
storage *kv.KVStore
|
|
mediaHandler media.Handler
|
|
oauthServer oauth.Server
|
|
fromClientAPIChan chan messages.FromClientAPI
|
|
httpClient pub.HttpClient
|
|
transportController transport.Controller
|
|
federator federation.Federator
|
|
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
|
|
accountProcessor account.Processor
|
|
}
|
|
|
|
func (suite *AccountStandardTestSuite) 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 *AccountStandardTestSuite) SetupTest() {
|
|
suite.config = testrig.NewTestConfig()
|
|
suite.db = testrig.NewTestDB()
|
|
testrig.InitTestLog()
|
|
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
|
suite.storage = testrig.NewTestStorage()
|
|
suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage)
|
|
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
|
|
suite.fromClientAPIChan = make(chan messages.FromClientAPI, 100)
|
|
suite.httpClient = testrig.NewMockHTTPClient(nil)
|
|
suite.transportController = testrig.NewTestTransportController(suite.httpClient, suite.db)
|
|
suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.storage)
|
|
suite.sentEmails = make(map[string]string)
|
|
suite.emailSender = testrig.NewEmailSender("../../../web/template/", suite.sentEmails)
|
|
suite.accountProcessor = account.New(suite.db, suite.tc, suite.mediaHandler, suite.oauthServer, suite.fromClientAPIChan, suite.federator, suite.config)
|
|
testrig.StandardDBSetup(suite.db, nil)
|
|
testrig.StandardStorageSetup(suite.storage, "../../../testrig/media")
|
|
}
|
|
|
|
func (suite *AccountStandardTestSuite) TearDownTest() {
|
|
testrig.StandardDBTeardown(suite.db)
|
|
testrig.StandardStorageTeardown(suite.storage)
|
|
}
|