From 6934ae378ab5743da80a5995fc74d167502187b1 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Tue, 12 Jul 2022 08:32:20 +0100 Subject: [chore] improved router logging, recovery and error handling (#705) * move panic recovery to logging middleware, improve logging + panic recovery logic Signed-off-by: kim * remove dead code Signed-off-by: kim * remove skip paths code Signed-off-by: kim * re-enable log quoting Signed-off-by: kim * use human-friendly bytesize in logging body size Signed-off-by: kim * only disable quoting in debug builds Signed-off-by: kim * use logrus level instead of debug.DEBUG() to enable/disable quoting Signed-off-by: kim * shutup linter Signed-off-by: kim * fix instance tests Signed-off-by: kim * fix gin test contexts created with missing engine HTML renderer Signed-off-by: kim * add note regarding not logging query parameters Signed-off-by: kim * better explain 'DisableQuoting' logic Signed-off-by: kim * add license text Signed-off-by: kim --- internal/api/client/status/statusboost_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/api/client/status/statusboost_test.go') diff --git a/internal/api/client/status/statusboost_test.go b/internal/api/client/status/statusboost_test.go index c8d33f0f8..5b4b1b3cd 100644 --- a/internal/api/client/status/statusboost_test.go +++ b/internal/api/client/status/statusboost_test.go @@ -31,6 +31,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/oauth" + "github.com/superseriousbusiness/gotosocial/testrig" ) type StatusBoostTestSuite struct { @@ -38,7 +39,6 @@ type StatusBoostTestSuite struct { } func (suite *StatusBoostTestSuite) TestPostBoost() { - t := suite.testTokens["local_account_1"] oauthToken := oauth.DBTokenToToken(t) @@ -46,7 +46,7 @@ func (suite *StatusBoostTestSuite) TestPostBoost() { // setup recorder := httptest.NewRecorder() - ctx, _ := gin.CreateTestContext(recorder) + ctx, _ := testrig.CreateGinTestContext(recorder, nil) ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) ctx.Set(oauth.SessionAuthorizedToken, oauthToken) ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"]) @@ -112,7 +112,7 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { testUser := suite.testUsers["local_account_1"] recorder := httptest.NewRecorder() - ctx, _ := gin.CreateTestContext(recorder) + ctx, _ := testrig.CreateGinTestContext(recorder, nil) ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) ctx.Set(oauth.SessionAuthorizedToken, oauthToken) ctx.Set(oauth.SessionAuthorizedUser, testUser) @@ -170,7 +170,6 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { // try to boost a status that's not boostable func (suite *StatusBoostTestSuite) TestPostUnboostable() { - t := suite.testTokens["local_account_1"] oauthToken := oauth.DBTokenToToken(t) @@ -178,7 +177,7 @@ func (suite *StatusBoostTestSuite) TestPostUnboostable() { // setup recorder := httptest.NewRecorder() - ctx, _ := gin.CreateTestContext(recorder) + ctx, _ := testrig.CreateGinTestContext(recorder, nil) ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) ctx.Set(oauth.SessionAuthorizedToken, oauthToken) ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"]) @@ -209,7 +208,6 @@ func (suite *StatusBoostTestSuite) TestPostUnboostable() { // try to boost a status that's not visible to the user func (suite *StatusBoostTestSuite) TestPostNotVisible() { - // stop local_account_2 following zork err := suite.db.DeleteByID(context.Background(), suite.testFollows["local_account_2_local_account_1"].ID, >smodel.Follow{}) suite.NoError(err) @@ -221,7 +219,7 @@ func (suite *StatusBoostTestSuite) TestPostNotVisible() { // setup recorder := httptest.NewRecorder() - ctx, _ := gin.CreateTestContext(recorder) + ctx, _ := testrig.CreateGinTestContext(recorder, nil) ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"]) ctx.Set(oauth.SessionAuthorizedToken, oauthToken) ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_2"]) -- cgit v1.2.3