diff options
author | 2024-07-24 13:27:42 +0200 | |
---|---|---|
committer | 2024-07-24 12:27:42 +0100 | |
commit | c9b6220fef01dce80a31436660cd06b4e1db030f (patch) | |
tree | 5fbade865a920a5ea04fdd63763eca1880d60c5d /internal/api/client/statuses/statusboost_test.go | |
parent | [chore] renames the `GTS` caches to `DB` caches (#3127) (diff) | |
download | gotosocial-c9b6220fef01dce80a31436660cd06b4e1db030f.tar.xz |
[chore] Add interaction filter to complement existing visibility filter (#3111)
* [chore] Add interaction filter to complement existing visibility filter
* pass in ptr to visibility and interaction filters to Processor{} to ensure shared
* use int constants for for match type, cache db calls in filterctx
* function name typo :innocent:
---------
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/api/client/statuses/statusboost_test.go')
-rw-r--r-- | internal/api/client/statuses/statusboost_test.go | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/internal/api/client/statuses/statusboost_test.go b/internal/api/client/statuses/statusboost_test.go index 25aa2ea0f..f6f589a5c 100644 --- a/internal/api/client/statuses/statusboost_test.go +++ b/internal/api/client/statuses/statusboost_test.go @@ -173,43 +173,42 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() { } // try to boost a status that's not boostable / visible to us -// TODO: sort this out with new interaction policies -// func (suite *StatusBoostTestSuite) TestPostUnboostable() { -// t := suite.testTokens["local_account_1"] -// oauthToken := oauth.DBTokenToToken(t) - -// targetStatus := suite.testStatuses["local_account_2_status_4"] - -// // setup -// recorder := httptest.NewRecorder() -// 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"]) -// ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"]) -// ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.ReblogPath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting -// ctx.Request.Header.Set("accept", "application/json") - -// // normally the router would populate these params from the path values, -// // but because we're calling the function directly, we need to set them manually. -// ctx.Params = gin.Params{ -// gin.Param{ -// Key: statuses.IDKey, -// Value: targetStatus.ID, -// }, -// } - -// suite.statusModule.StatusBoostPOSTHandler(ctx) - -// // check response -// suite.Equal(http.StatusNotFound, recorder.Code) // we 404 unboostable statuses - -// result := recorder.Result() -// defer result.Body.Close() -// b, err := ioutil.ReadAll(result.Body) -// suite.NoError(err) -// suite.Equal(`{"error":"Not Found"}`, string(b)) -// } +func (suite *StatusBoostTestSuite) TestPostUnboostable() { + t := suite.testTokens["local_account_1"] + oauthToken := oauth.DBTokenToToken(t) + + targetStatus := suite.testStatuses["local_account_2_status_4"] + + // setup + recorder := httptest.NewRecorder() + 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"]) + ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"]) + ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080%s", strings.Replace(statuses.ReblogPath, ":id", targetStatus.ID, 1)), nil) // the endpoint we're hitting + ctx.Request.Header.Set("accept", "application/json") + + // normally the router would populate these params from the path values, + // but because we're calling the function directly, we need to set them manually. + ctx.Params = gin.Params{ + gin.Param{ + Key: statuses.IDKey, + Value: targetStatus.ID, + }, + } + + suite.statusModule.StatusBoostPOSTHandler(ctx) + + // check response + suite.Equal(http.StatusForbidden, recorder.Code) + + result := recorder.Result() + defer result.Body.Close() + b, err := ioutil.ReadAll(result.Body) + suite.NoError(err) + suite.Equal(`{"error":"Forbidden: you do not have permission to boost this status"}`, string(b)) +} // try to boost a status that's not visible to the user func (suite *StatusBoostTestSuite) TestPostNotVisible() { |