mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 21:26:40 +00:00
[bugfix] Don't call strings.ToLower()
on usernames when selecting account by domain+username (#1190)
* don't lowercase account username when doing a select * test getting remote user with uppercase username
This commit is contained in:
parent
8d581deb28
commit
3a11861ac6
|
@ -70,7 +70,7 @@ func (suite *GetTestSuite) TestGet() {
|
||||||
b, err := ioutil.ReadAll(result.Body)
|
b, err := ioutil.ReadAll(result.Body)
|
||||||
assert.NoError(suite.T(), err)
|
assert.NoError(suite.T(), err)
|
||||||
|
|
||||||
suite.Equal(`[{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]}]`, string(b))
|
suite.Equal(`[{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"Some_User","acct":"Some_User@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@Some_User","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]}]`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTestSuite(t *testing.T) {
|
func TestGetTestSuite(t *testing.T) {
|
||||||
|
|
|
@ -97,6 +97,23 @@ func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestring() {
|
||||||
suite.NotNil(gotAccount)
|
suite.NotNil(gotAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringUppercase() {
|
||||||
|
query := "@Some_User@example.org"
|
||||||
|
resolve := true
|
||||||
|
|
||||||
|
searchResult, err := suite.testSearch(query, resolve, http.StatusOK)
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if !suite.Len(searchResult.Accounts, 1) {
|
||||||
|
suite.FailNow("expected 1 account in search results but got 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
gotAccount := searchResult.Accounts[0]
|
||||||
|
suite.NotNil(gotAccount)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringNoLeadingAt() {
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringNoLeadingAt() {
|
||||||
query := "brand_new_person@unknown-instance.com"
|
query := "brand_new_person@unknown-instance.com"
|
||||||
resolve := true
|
resolve := true
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"codeberg.org/gruf/go-cache/v3/result"
|
"codeberg.org/gruf/go-cache/v3/result"
|
||||||
|
@ -102,7 +101,6 @@ func(account *gtsmodel.Account) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *accountDB) GetAccountByUsernameDomain(ctx context.Context, username string, domain string) (*gtsmodel.Account, db.Error) {
|
func (a *accountDB) GetAccountByUsernameDomain(ctx context.Context, username string, domain string) (*gtsmodel.Account, db.Error) {
|
||||||
username = strings.ToLower(username)
|
|
||||||
return a.getAccount(
|
return a.getAccount(
|
||||||
ctx,
|
ctx,
|
||||||
"Username.Domain",
|
"Username.Domain",
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (suite *CreateTestSuite) TestCreateNoteForward() {
|
||||||
suite.Nil(msg.GTSModel)
|
suite.Nil(msg.GTSModel)
|
||||||
|
|
||||||
// but we should have a uri set
|
// but we should have a uri set
|
||||||
suite.Equal("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1", msg.APIri.String())
|
suite.Equal("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1", msg.APIri.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateTestSuite(t *testing.T) {
|
func TestCreateTestSuite(t *testing.T) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (suite *FollowRequestTestSuite) TestFollowRequestAccept() {
|
||||||
suite.NoError(errWithCode)
|
suite.NoError(errWithCode)
|
||||||
suite.EqualValues(&apimodel.Relationship{ID: "01FHMQX3GAABWSM0S2VZEC2SWC", Following: false, ShowingReblogs: false, Notifying: false, FollowedBy: true, Blocking: false, BlockedBy: false, Muting: false, MutingNotifications: false, Requested: false, DomainBlocking: false, Endorsed: false, Note: ""}, relationship)
|
suite.EqualValues(&apimodel.Relationship{ID: "01FHMQX3GAABWSM0S2VZEC2SWC", Following: false, ShowingReblogs: false, Notifying: false, FollowedBy: true, Blocking: false, BlockedBy: false, Muting: false, MutingNotifications: false, Requested: false, DomainBlocking: false, Endorsed: false, Note: ""}, relationship)
|
||||||
|
|
||||||
// accept should be sent to some_user
|
// accept should be sent to Some_User
|
||||||
var sent [][]byte
|
var sent [][]byte
|
||||||
if !testrig.WaitFor(func() bool {
|
if !testrig.WaitFor(func() bool {
|
||||||
sentI, ok := suite.httpClient.SentMessages.Load(requestingAccount.InboxURI)
|
sentI, ok := suite.httpClient.SentMessages.Load(requestingAccount.InboxURI)
|
||||||
|
@ -119,7 +119,7 @@ func (suite *FollowRequestTestSuite) TestFollowRequestReject() {
|
||||||
suite.NoError(errWithCode)
|
suite.NoError(errWithCode)
|
||||||
suite.EqualValues(&apimodel.Relationship{ID: "01FHMQX3GAABWSM0S2VZEC2SWC", Following: false, ShowingReblogs: false, Notifying: false, FollowedBy: false, Blocking: false, BlockedBy: false, Muting: false, MutingNotifications: false, Requested: false, DomainBlocking: false, Endorsed: false, Note: ""}, relationship)
|
suite.EqualValues(&apimodel.Relationship{ID: "01FHMQX3GAABWSM0S2VZEC2SWC", Following: false, ShowingReblogs: false, Notifying: false, FollowedBy: false, Blocking: false, BlockedBy: false, Muting: false, MutingNotifications: false, Requested: false, DomainBlocking: false, Endorsed: false, Note: ""}, relationship)
|
||||||
|
|
||||||
// reject should be sent to some_user
|
// reject should be sent to Some_User
|
||||||
var sent [][]byte
|
var sent [][]byte
|
||||||
if !testrig.WaitFor(func() bool {
|
if !testrig.WaitFor(func() bool {
|
||||||
sentI, ok := suite.httpClient.SentMessages.Load(requestingAccount.InboxURI)
|
sentI, ok := suite.httpClient.SentMessages.Load(requestingAccount.InboxURI)
|
||||||
|
|
|
@ -556,12 +556,12 @@ func (suite *FromFederatorTestSuite) TestCreateStatusFromIRI() {
|
||||||
APActivityType: ap.ActivityCreate,
|
APActivityType: ap.ActivityCreate,
|
||||||
GTSModel: nil, // gtsmodel is nil because this is a forwarded status -- we want to dereference it using the iri
|
GTSModel: nil, // gtsmodel is nil because this is a forwarded status -- we want to dereference it using the iri
|
||||||
ReceivingAccount: receivingAccount,
|
ReceivingAccount: receivingAccount,
|
||||||
APIri: testrig.URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
APIri: testrig.URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
||||||
})
|
})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// status should now be in the database, attributed to remote_account_2
|
// status should now be in the database, attributed to remote_account_2
|
||||||
s, err := suite.db.GetStatusByURI(context.Background(), "http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1")
|
s, err := suite.db.GetStatusByURI(context.Background(), "http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1")
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(statusCreator.URI, s.AccountURI)
|
suite.Equal(statusCreator.URI, s.AccountURI)
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceToFrontendWithAdminAccount
|
||||||
b, err := json.Marshal(apiInstance)
|
b, err := json.Marshal(apiInstance)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
suite.Equal(`{"uri":"https://example.org","title":"example instance","description":"a much longer description","short_description":"a little description","email":"someone@example.org","version":"software-from-hell 0.666","registrations":false,"approval_required":false,"invites_enabled":false,"thumbnail":"","contact_account":{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"some_user","acct":"some_user@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@some_user","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]},"max_toot_chars":0}`, string(b))
|
suite.Equal(`{"uri":"https://example.org","title":"example instance","description":"a much longer description","short_description":"a little description","email":"someone@example.org","version":"software-from-hell 0.666","registrations":false,"approval_required":false,"invites_enabled":false,"thumbnail":"","contact_account":{"id":"01FHMQX3GAABWSM0S2VZEC2SWC","username":"Some_User","acct":"Some_User@example.org","display_name":"some user","locked":true,"bot":false,"created_at":"2020-08-10T12:13:28.000Z","note":"i'm a real son of a gun","url":"http://example.org/@Some_User","avatar":"","avatar_static":"","header":"http://localhost:8080/assets/default_header.png","header_static":"http://localhost:8080/assets/default_header.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]},"max_toot_chars":0}`, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
|
func (suite *InternalToFrontendTestSuite) TestEmojiToFrontend() {
|
||||||
|
|
|
@ -539,7 +539,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
|
||||||
},
|
},
|
||||||
"remote_account_2": {
|
"remote_account_2": {
|
||||||
ID: "01FHMQX3GAABWSM0S2VZEC2SWC",
|
ID: "01FHMQX3GAABWSM0S2VZEC2SWC",
|
||||||
Username: "some_user",
|
Username: "Some_User",
|
||||||
Domain: "example.org",
|
Domain: "example.org",
|
||||||
DisplayName: "some user",
|
DisplayName: "some user",
|
||||||
Fields: []gtsmodel.Field{},
|
Fields: []gtsmodel.Field{},
|
||||||
|
@ -553,20 +553,20 @@ func NewTestAccounts() map[string]*gtsmodel.Account {
|
||||||
Discoverable: TrueBool(),
|
Discoverable: TrueBool(),
|
||||||
Sensitive: FalseBool(),
|
Sensitive: FalseBool(),
|
||||||
Language: "en",
|
Language: "en",
|
||||||
URI: "http://example.org/users/some_user",
|
URI: "http://example.org/users/Some_User",
|
||||||
URL: "http://example.org/@some_user",
|
URL: "http://example.org/@Some_User",
|
||||||
LastWebfingeredAt: time.Time{},
|
LastWebfingeredAt: time.Time{},
|
||||||
InboxURI: "http://example.org/users/some_user/inbox",
|
InboxURI: "http://example.org/users/Some_User/inbox",
|
||||||
SharedInboxURI: StringPtr(""),
|
SharedInboxURI: StringPtr(""),
|
||||||
OutboxURI: "http://example.org/users/some_user/outbox",
|
OutboxURI: "http://example.org/users/Some_User/outbox",
|
||||||
FollowersURI: "http://example.org/users/some_user/followers",
|
FollowersURI: "http://example.org/users/Some_User/followers",
|
||||||
FollowingURI: "http://example.org/users/some_user/following",
|
FollowingURI: "http://example.org/users/Some_User/following",
|
||||||
FeaturedCollectionURI: "http://example.org/users/some_user/collections/featured",
|
FeaturedCollectionURI: "http://example.org/users/Some_User/collections/featured",
|
||||||
ActorType: ap.ActorPerson,
|
ActorType: ap.ActorPerson,
|
||||||
AlsoKnownAs: "",
|
AlsoKnownAs: "",
|
||||||
PrivateKey: &rsa.PrivateKey{},
|
PrivateKey: &rsa.PrivateKey{},
|
||||||
PublicKey: &rsa.PublicKey{},
|
PublicKey: &rsa.PublicKey{},
|
||||||
PublicKeyURI: "http://example.org/users/some_user#main-key",
|
PublicKeyURI: "http://example.org/users/Some_User#main-key",
|
||||||
SensitizedAt: time.Time{},
|
SensitizedAt: time.Time{},
|
||||||
SilencedAt: time.Time{},
|
SilencedAt: time.Time{},
|
||||||
SuspendedAt: time.Time{},
|
SuspendedAt: time.Time{},
|
||||||
|
@ -1853,27 +1853,27 @@ func NewTestActivities(accounts map[string]*gtsmodel.Account) map[string]Activit
|
||||||
createReplyToTurtleForTurtleSig, createReplyToTurtleForTurtleDigest, createReplyToTurtleForTurtleDate := GetSignatureForActivity(createReplyToTurtle, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_2"].InboxURI))
|
createReplyToTurtleForTurtleSig, createReplyToTurtleForTurtleDigest, createReplyToTurtleForTurtleDate := GetSignatureForActivity(createReplyToTurtle, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_2"].InboxURI))
|
||||||
|
|
||||||
forwardedMessage := NewAPNote(
|
forwardedMessage := NewAPNote(
|
||||||
URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
||||||
URLMustParse("http://example.org/@some_user/afaba698-5740-4e32-a702-af61aa543bc1"),
|
URLMustParse("http://example.org/@Some_User/afaba698-5740-4e32-a702-af61aa543bc1"),
|
||||||
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
||||||
"this is a public status, please forward it!",
|
"this is a public status, please forward it!",
|
||||||
"",
|
"",
|
||||||
URLMustParse("http://example.org/users/some_user"),
|
URLMustParse("http://example.org/users/Some_User"),
|
||||||
[]*url.URL{URLMustParse(pub.PublicActivityPubIRI)},
|
[]*url.URL{URLMustParse(pub.PublicActivityPubIRI)},
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
[]vocab.ActivityStreamsMention{},
|
[]vocab.ActivityStreamsMention{},
|
||||||
[]vocab.ActivityStreamsImage{
|
[]vocab.ActivityStreamsImage{
|
||||||
newAPImage(
|
newAPImage(
|
||||||
URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1/attachment1.jpeg"),
|
URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1/attachment1.jpeg"),
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"trent reznor looking handsome as balls",
|
"trent reznor looking handsome as balls",
|
||||||
"LEDara58O=t5EMSOENEN9]}?aK%0"),
|
"LEDara58O=t5EMSOENEN9]}?aK%0"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
createForwardedMessage := WrapAPNoteInCreate(
|
createForwardedMessage := WrapAPNoteInCreate(
|
||||||
URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1/activity"),
|
URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1/activity"),
|
||||||
URLMustParse("http://example.org/users/some_user"),
|
URLMustParse("http://example.org/users/Some_User"),
|
||||||
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
||||||
forwardedMessage)
|
forwardedMessage)
|
||||||
createForwardedMessageSig, createForwardedMessageDigest, createForwardedMessageDate := GetSignatureForActivity(createForwardedMessage, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI))
|
createForwardedMessageSig, createForwardedMessageDigest, createForwardedMessageDate := GetSignatureForActivity(createForwardedMessage, accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].InboxURI))
|
||||||
|
@ -2172,20 +2172,20 @@ func NewTestFediAttachments(relativePath string) map[string]RemoteAttachmentFile
|
||||||
|
|
||||||
func NewTestFediStatuses() map[string]vocab.ActivityStreamsNote {
|
func NewTestFediStatuses() map[string]vocab.ActivityStreamsNote {
|
||||||
return map[string]vocab.ActivityStreamsNote{
|
return map[string]vocab.ActivityStreamsNote{
|
||||||
"http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1": NewAPNote(
|
"http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1": NewAPNote(
|
||||||
URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1"),
|
||||||
URLMustParse("http://example.org/@some_user/afaba698-5740-4e32-a702-af61aa543bc1"),
|
URLMustParse("http://example.org/@Some_User/afaba698-5740-4e32-a702-af61aa543bc1"),
|
||||||
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
TimeMustParse("2022-07-13T12:13:12+02:00"),
|
||||||
"this is a public status, please forward it!",
|
"this is a public status, please forward it!",
|
||||||
"",
|
"",
|
||||||
URLMustParse("http://example.org/users/some_user"),
|
URLMustParse("http://example.org/users/Some_User"),
|
||||||
[]*url.URL{URLMustParse(pub.PublicActivityPubIRI)},
|
[]*url.URL{URLMustParse(pub.PublicActivityPubIRI)},
|
||||||
nil,
|
nil,
|
||||||
false,
|
false,
|
||||||
[]vocab.ActivityStreamsMention{},
|
[]vocab.ActivityStreamsMention{},
|
||||||
[]vocab.ActivityStreamsImage{
|
[]vocab.ActivityStreamsImage{
|
||||||
newAPImage(
|
newAPImage(
|
||||||
URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1/attachment1.jpeg"),
|
URLMustParse("http://example.org/users/Some_User/statuses/afaba698-5740-4e32-a702-af61aa543bc1/attachment1.jpeg"),
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"trent reznor looking handsome as balls",
|
"trent reznor looking handsome as balls",
|
||||||
"LEDara58O=t5EMSOENEN9]}?aK%0"),
|
"LEDara58O=t5EMSOENEN9]}?aK%0"),
|
||||||
|
|
|
@ -282,14 +282,14 @@ func WebfingerResponse(req *http.Request) (responseCode int, responseBytes []byt
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
case "https://example.org/.well-known/webfinger?resource=acct:some_user@example.org":
|
case "https://example.org/.well-known/webfinger?resource=acct:Some_User@example.org":
|
||||||
wfr = &apimodel.WellKnownResponse{
|
wfr = &apimodel.WellKnownResponse{
|
||||||
Subject: "acct:some_user@example.org",
|
Subject: "acct:Some_User@example.org",
|
||||||
Links: []apimodel.Link{
|
Links: []apimodel.Link{
|
||||||
{
|
{
|
||||||
Rel: "self",
|
Rel: "self",
|
||||||
Type: applicationActivityJSON,
|
Type: applicationActivityJSON,
|
||||||
Href: "https://example.org/users/some_user",
|
Href: "https://example.org/users/Some_User",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue