mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-31 19:32:25 -05:00
[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
This commit is contained in:
parent
142b7ec54f
commit
2bafd7daf5
15 changed files with 345 additions and 162 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue