linting, fmt

This commit is contained in:
tsmethurst 2021-04-26 21:22:34 +02:00
commit dda2c9ab1c
4 changed files with 11 additions and 11 deletions

View file

@ -55,7 +55,7 @@ func (suite *ProtocolTestSuite) SetupSuite() {
suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB()
suite.log = testrig.NewTestLog()
suite.tc = testrig.NewTestTransportController(suite.db, testrig.NewMockHTTPClient(func(req *http.Request)(*http.Response, error) {
suite.tc = testrig.NewTestTransportController(suite.db, testrig.NewMockHTTPClient(func(req *http.Request) (*http.Response, error) {
return nil, nil
}))
suite.activities = testrig.NewTestActivities()

View file

@ -37,7 +37,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/transport"
)
/*
publicKeyer is BORROWED DIRECTLY FROM https://github.com/go-fed/apcore/blob/master/ap/util.go
Thank you @cj@mastodon.technology ! <3
@ -50,8 +49,8 @@ type publicKeyer interface {
getPublicKeyFromResponse is BORROWED DIRECTLY FROM https://github.com/go-fed/apcore/blob/master/ap/util.go
Thank you @cj@mastodon.technology ! <3
*/
func getPublicKeyFromResponse(c context.Context, b []byte, keyId *url.URL) (p crypto.PublicKey, err error) {
m := make(map[string]interface{}, 0)
func getPublicKeyFromResponse(c context.Context, b []byte, keyID *url.URL) (p crypto.PublicKey, err error) {
m := make(map[string]interface{})
err = json.Unmarshal(b, &m)
if err != nil {
return
@ -77,19 +76,19 @@ func getPublicKeyFromResponse(c context.Context, b []byte, keyId *url.URL) (p cr
continue
}
pkValue := pkpIter.Get()
var pkId *url.URL
pkId, err = pub.GetId(pkValue)
var pkID *url.URL
pkID, err = pub.GetId(pkValue)
if err != nil {
return
}
if pkId.String() != keyId.String() {
if pkID.String() != keyID.String() {
continue
}
pkpFound = pkValue
break
}
if pkpFound == nil {
err = fmt.Errorf("cannot find publicKey with id: %s", keyId)
err = fmt.Errorf("cannot find publicKey with id: %s", keyID)
return
}
pkPemProp := pkpFound.GetW3IDSecurityV1PublicKeyPem()

View file

@ -998,6 +998,7 @@ func NewTestFaves() map[string]*gtsmodel.StatusFave {
}
}
// NewTestActivities returns a bunch of pub.Activity types for use in testing the federation protocols.
func NewTestActivities() map[string]pub.Activity {
dmForZork := newNote(
URLMustParse("https://fossbros-anonymous.io/users/foss_satan/statuses/5424b153-4553-4f30-9358-7b92f7cd42f6"),

View file

@ -43,15 +43,15 @@ func NewTestTransportController(db db.DB, client pub.HttpClient) transport.Contr
// NewMockHTTPClient returns a client that conforms to the pub.HttpClient interface,
// but will always just execute the given `do` function, allowing responses to be mocked.
func NewMockHTTPClient(do func(req *http.Request) (*http.Response, error)) pub.HttpClient {
return &mockHttpClient{
return &mockHTTPClient{
do: do,
}
}
type mockHttpClient struct {
type mockHTTPClient struct {
do func(req *http.Request) (*http.Response, error)
}
func (m *mockHttpClient) Do(req *http.Request) (*http.Response, error) {
func (m *mockHTTPClient) Do(req *http.Request) (*http.Response, error) {
return m.do(req)
}