gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

webfinger_test.go (4201B)


      1 // GoToSocial
      2 // Copyright (C) GoToSocial Authors admin@gotosocial.org
      3 // SPDX-License-Identifier: AGPL-3.0-or-later
      4 //
      5 // This program is free software: you can redistribute it and/or modify
      6 // it under the terms of the GNU Affero General Public License as published by
      7 // the Free Software Foundation, either version 3 of the License, or
      8 // (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU Affero General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU Affero General Public License
     16 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 package webfinger_test
     19 
     20 import (
     21 	"github.com/stretchr/testify/suite"
     22 	"github.com/superseriousbusiness/gotosocial/internal/api/wellknown/webfinger"
     23 	"github.com/superseriousbusiness/gotosocial/internal/db"
     24 	"github.com/superseriousbusiness/gotosocial/internal/email"
     25 	"github.com/superseriousbusiness/gotosocial/internal/federation"
     26 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
     27 	"github.com/superseriousbusiness/gotosocial/internal/media"
     28 	"github.com/superseriousbusiness/gotosocial/internal/oauth"
     29 	"github.com/superseriousbusiness/gotosocial/internal/processing"
     30 	"github.com/superseriousbusiness/gotosocial/internal/state"
     31 	"github.com/superseriousbusiness/gotosocial/internal/storage"
     32 	"github.com/superseriousbusiness/gotosocial/internal/typeutils"
     33 	"github.com/superseriousbusiness/gotosocial/internal/visibility"
     34 	"github.com/superseriousbusiness/gotosocial/testrig"
     35 )
     36 
     37 type WebfingerStandardTestSuite struct {
     38 	// standard suite interfaces
     39 	suite.Suite
     40 	db           db.DB
     41 	state        state.State
     42 	tc           typeutils.TypeConverter
     43 	mediaManager *media.Manager
     44 	federator    federation.Federator
     45 	emailSender  email.Sender
     46 	processor    *processing.Processor
     47 	storage      *storage.Driver
     48 	oauthServer  oauth.Server
     49 
     50 	// standard suite models
     51 	testTokens       map[string]*gtsmodel.Token
     52 	testClients      map[string]*gtsmodel.Client
     53 	testApplications map[string]*gtsmodel.Application
     54 	testUsers        map[string]*gtsmodel.User
     55 	testAccounts     map[string]*gtsmodel.Account
     56 	testAttachments  map[string]*gtsmodel.MediaAttachment
     57 	testStatuses     map[string]*gtsmodel.Status
     58 
     59 	// module being tested
     60 	webfingerModule *webfinger.Module
     61 }
     62 
     63 func (suite *WebfingerStandardTestSuite) SetupSuite() {
     64 	suite.testTokens = testrig.NewTestTokens()
     65 	suite.testClients = testrig.NewTestClients()
     66 	suite.testApplications = testrig.NewTestApplications()
     67 	suite.testUsers = testrig.NewTestUsers()
     68 	suite.testAccounts = testrig.NewTestAccounts()
     69 	suite.testAttachments = testrig.NewTestAttachments()
     70 	suite.testStatuses = testrig.NewTestStatuses()
     71 }
     72 
     73 func (suite *WebfingerStandardTestSuite) SetupTest() {
     74 	suite.state.Caches.Init()
     75 	testrig.StartWorkers(&suite.state)
     76 
     77 	testrig.InitTestLog()
     78 	testrig.InitTestConfig()
     79 
     80 	suite.db = testrig.NewTestDB(&suite.state)
     81 	suite.state.DB = suite.db
     82 	suite.tc = testrig.NewTestTypeConverter(suite.db)
     83 
     84 	testrig.StartTimelines(
     85 		&suite.state,
     86 		visibility.NewFilter(&suite.state),
     87 		suite.tc,
     88 	)
     89 
     90 	suite.storage = testrig.NewInMemoryStorage()
     91 	suite.state.Storage = suite.storage
     92 	suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
     93 	suite.federator = testrig.NewTestFederator(&suite.state, testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../../testrig/media")), suite.mediaManager)
     94 	suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
     95 	suite.processor = testrig.NewTestProcessor(&suite.state, suite.federator, suite.emailSender, suite.mediaManager)
     96 	suite.webfingerModule = webfinger.New(suite.processor)
     97 	suite.oauthServer = testrig.NewTestOauthServer(suite.db)
     98 	testrig.StandardDBSetup(suite.db, suite.testAccounts)
     99 	testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
    100 }
    101 
    102 func (suite *WebfingerStandardTestSuite) TearDownTest() {
    103 	testrig.StandardDBTeardown(suite.db)
    104 	testrig.StandardStorageTeardown(suite.storage)
    105 	testrig.StopWorkers(&suite.state)
    106 }