summaryrefslogtreecommitdiff
path: root/internal/api/activitypub/users/inboxpost_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-02-03 20:03:05 +0000
committerLibravatar GitHub <noreply@github.com>2023-02-03 20:03:05 +0000
commit33aee1b1e974e99182a95ce1a05e2be924d19bb2 (patch)
tree1471623039f70325a0b7a1c25dd4fe3afc883970 /internal/api/activitypub/users/inboxpost_test.go
parent[feature/frogend] (Mastodon) domain block CSV import (#1390) (diff)
downloadgotosocial-33aee1b1e974e99182a95ce1a05e2be924d19bb2.tar.xz
[chore] reformat GetAccount() functionality, support updating accounts based on last_fetch (#1411)
* reformat GetAccount() functionality, and add UpdateAccount() function. * use fetched_at instead of last_webfingered_at * catch local "not found" errors. small formatting / error string changes * remove now unused error type * return nil when wrapping nil error * update expected error messages * return correct url for foss satan webfinger * add AP model for Some_User * normalize local domain * return notretrievable where appropriate * expose NewErrNotRetrievable * ensure webfinger for new accounts searched by uri * update local account short circuit * allow enrich to fail for already-known accounts * remove unused LastWebfingeredAt * expose test maps on mock http client * update Update test * reformat GetAccount() functionality, and add UpdateAccount() function. * use fetched_at instead of last_webfingered_at * catch local "not found" errors. small formatting / error string changes * remove nil error checks (we shouldn't be passing nil errors to newError() initializers) * remove mutex unlock on transport init fail (it hasn't yet been locked!) * woops add back the error wrapping to use ErrNotRetrievable * caches were never being started... :see_no_evil: --------- Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/api/activitypub/users/inboxpost_test.go')
-rw-r--r--internal/api/activitypub/users/inboxpost_test.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/internal/api/activitypub/users/inboxpost_test.go b/internal/api/activitypub/users/inboxpost_test.go
index 26ee950ec..e43532e80 100644
--- a/internal/api/activitypub/users/inboxpost_test.go
+++ b/internal/api/activitypub/users/inboxpost_test.go
@@ -32,6 +32,7 @@ import (
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
+ "github.com/superseriousbusiness/activity/streams/vocab"
"github.com/superseriousbusiness/gotosocial/internal/api/activitypub/users"
"github.com/superseriousbusiness/gotosocial/internal/concurrency"
"github.com/superseriousbusiness/gotosocial/internal/db"
@@ -237,10 +238,11 @@ func (suite *InboxPostTestSuite) TestPostUnblock() {
}
func (suite *InboxPostTestSuite) TestPostUpdate() {
+ receivingAccount := suite.testAccounts["local_account_1"]
updatedAccount := *suite.testAccounts["remote_account_1"]
updatedAccount.DisplayName = "updated display name!"
- // ad an emoji to the account; because we're serializing this remote
+ // add an emoji to the account; because we're serializing this remote
// account from our own instance, we need to cheat a bit to get the emoji
// to work properly, just for this test
testEmoji := &gtsmodel.Emoji{}
@@ -251,8 +253,6 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
asAccount, err := suite.tc.AccountToAS(context.Background(), &updatedAccount)
suite.NoError(err)
- receivingAccount := suite.testAccounts["local_account_1"]
-
// create an update
update := streams.NewActivityStreamsUpdate()
@@ -294,7 +294,14 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
clientWorker := concurrency.NewWorkerPool[messages.FromClientAPI](-1, -1)
fedWorker := concurrency.NewWorkerPool[messages.FromFederator](-1, -1)
- tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil, "../../../../testrig/media"), suite.db, fedWorker)
+ // use a different version of the mock http client which serves the updated
+ // version of the remote account, as though it had been updated there too;
+ // this is needed so it can be dereferenced + updated properly
+ mockHTTPClient := testrig.NewMockHTTPClient(nil, "../../../../testrig/media")
+ mockHTTPClient.TestRemotePeople = map[string]vocab.ActivityStreamsPerson{
+ updatedAccount.URI: asAccount,
+ }
+ tc := testrig.NewTestTransportController(mockHTTPClient, suite.db, fedWorker)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager, fedWorker)
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager, clientWorker, fedWorker)
@@ -346,8 +353,8 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
// emojis should be updated
suite.Contains(dbUpdatedAccount.EmojiIDs, testEmoji.ID)
- // account should be freshly webfingered
- suite.WithinDuration(time.Now(), dbUpdatedAccount.LastWebfingeredAt, 10*time.Second)
+ // account should be freshly fetched
+ suite.WithinDuration(time.Now(), dbUpdatedAccount.FetchedAt, 10*time.Second)
// everything else should be the same as it was before
suite.EqualValues(updatedAccount.Username, dbUpdatedAccount.Username)