diff options
author | 2024-02-14 11:13:38 +0000 | |
---|---|---|
committer | 2024-02-14 12:13:38 +0100 | |
commit | 2bafd7daf542d985ee76d9079a30a602cb7be827 (patch) | |
tree | 8817fe6f202155d660d75c17cd78ff5dae3d4530 /internal/federation/dereferencing/account_test.go | |
parent | [feature] Add metrics for instance user count, statuses count and federating ... (diff) | |
download | gotosocial-2bafd7daf542d985ee76d9079a30a602cb7be827.tar.xz |
[bugfix] add stricter checks during all stages of dereferencing remote AS objects (#2639)
* add stricter checks during all stages of dereferencing remote AS objects
* a comment
Diffstat (limited to 'internal/federation/dereferencing/account_test.go')
-rw-r--r-- | internal/federation/dereferencing/account_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/federation/dereferencing/account_test.go b/internal/federation/dereferencing/account_test.go index ef1eddb91..f99012904 100644 --- a/internal/federation/dereferencing/account_test.go +++ b/internal/federation/dereferencing/account_test.go @@ -19,6 +19,7 @@ package dereferencing_test import ( "context" + "fmt" "testing" "time" @@ -207,6 +208,28 @@ func (suite *AccountTestSuite) TestDereferenceLocalAccountWithUnknownUserURI() { suite.Nil(fetchedAccount) } +func (suite *AccountTestSuite) TestDereferenceRemoteAccountWithNonMatchingURI() { + fetchingAccount := suite.testAccounts["local_account_1"] + + const ( + remoteURI = "https://turnip.farm/users/turniplover6969" + remoteAltURI = "https://turnip.farm/users/turniphater420" + ) + + // Create a copy of this remote account at alternative URI. + remotePerson := suite.client.TestRemotePeople[remoteURI] + suite.client.TestRemotePeople[remoteAltURI] = remotePerson + + // Attempt to fetch account at alternative URI, it should fail! + fetchedAccount, _, err := suite.dereferencer.GetAccountByURI( + context.Background(), + fetchingAccount.Username, + testrig.URLMustParse(remoteAltURI), + ) + suite.Equal(err.Error(), fmt.Sprintf("enrichAccount: dereferenced account uri %s does not match %s", remoteURI, remoteAltURI)) + suite.Nil(fetchedAccount) +} + func TestAccountTestSuite(t *testing.T) { suite.Run(t, new(AccountTestSuite)) } |