2023-03-12 16:00:57 +01:00
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2023-01-25 11:12:17 +01:00
package admin_test
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"strconv"
"testing"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/admin"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
2024-06-18 18:18:00 +02:00
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
2023-01-25 11:12:17 +01:00
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
2023-08-07 19:38:11 +02:00
"github.com/superseriousbusiness/gotosocial/internal/util"
2023-01-25 11:12:17 +01:00
"github.com/superseriousbusiness/gotosocial/testrig"
)
type ReportsGetTestSuite struct {
AdminStandardTestSuite
}
func ( suite * ReportsGetTestSuite ) getReports (
account * gtsmodel . Account ,
token * gtsmodel . Token ,
user * gtsmodel . User ,
expectedHTTPStatus int ,
expectedBody string ,
resolved * bool ,
accountID string ,
targetAccountID string ,
maxID string ,
sinceID string ,
minID string ,
limit int ,
) ( [ ] * apimodel . AdminReport , string , error ) {
// instantiate recorder + test context
recorder := httptest . NewRecorder ( )
ctx , _ := testrig . CreateGinTestContext ( recorder , nil )
ctx . Set ( oauth . SessionAuthorizedAccount , account )
ctx . Set ( oauth . SessionAuthorizedToken , oauth . DBTokenToToken ( token ) )
ctx . Set ( oauth . SessionAuthorizedApplication , suite . testApplications [ "application_1" ] )
ctx . Set ( oauth . SessionAuthorizedUser , user )
// create the request URI
2024-06-18 18:18:00 +02:00
requestPath := admin . ReportsPath + "?" + apiutil . LimitKey + "=" + strconv . Itoa ( limit )
2023-01-25 11:12:17 +01:00
if resolved != nil {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . ResolvedKey + "=" + strconv . FormatBool ( * resolved )
2023-01-25 11:12:17 +01:00
}
if accountID != "" {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . AccountIDKey + "=" + accountID
2023-01-25 11:12:17 +01:00
}
if targetAccountID != "" {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . TargetAccountIDKey + "=" + targetAccountID
2023-01-25 11:12:17 +01:00
}
if maxID != "" {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . MaxIDKey + "=" + maxID
2023-01-25 11:12:17 +01:00
}
if sinceID != "" {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . SinceIDKey + "=" + sinceID
2023-01-25 11:12:17 +01:00
}
if minID != "" {
2024-06-18 18:18:00 +02:00
requestPath = requestPath + "&" + apiutil . MinIDKey + "=" + minID
2023-01-25 11:12:17 +01:00
}
baseURI := config . GetProtocol ( ) + "://" + config . GetHost ( )
requestURI := baseURI + "/api/" + requestPath
// create the request
ctx . Request = httptest . NewRequest ( http . MethodGet , requestURI , nil )
ctx . Request . Header . Set ( "accept" , "application/json" )
// trigger the handler
suite . adminModule . ReportsGETHandler ( ctx )
// read the response
result := recorder . Result ( )
defer result . Body . Close ( )
b , err := ioutil . ReadAll ( result . Body )
if err != nil {
return nil , "" , err
}
2023-08-02 17:21:46 +02:00
errs := gtserror . NewMultiError ( 2 )
2023-01-25 11:12:17 +01:00
if resultCode := recorder . Code ; expectedHTTPStatus != resultCode {
2023-08-02 17:21:46 +02:00
errs . Appendf ( "expected %d got %d" , expectedHTTPStatus , resultCode )
2023-01-25 11:12:17 +01:00
}
// if we got an expected body, return early
if expectedBody != "" {
if string ( b ) != expectedBody {
2023-08-02 17:21:46 +02:00
errs . Appendf ( "expected %s got %s" , expectedBody , string ( b ) )
2023-01-25 11:12:17 +01:00
}
return nil , "" , errs . Combine ( )
}
resp := [ ] * apimodel . AdminReport { }
if err := json . Unmarshal ( b , & resp ) ; err != nil {
return nil , "" , err
}
return resp , result . Header . Get ( "Link" ) , nil
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetAll ( ) {
2023-01-25 11:12:17 +01:00
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , nil , "" , "" , "" , "" , "" , 20 )
suite . NoError ( err )
suite . NotEmpty ( reports )
b , err := json . MarshalIndent ( & reports , "" , " " )
suite . NoError ( err )
suite . Equal ( ` [
{
"id" : "01GP3DFY9XQ1TJMZT5BGAZPXX7" ,
"action_taken" : true ,
"action_taken_at" : "2022-05-15T15:01:56.000Z" ,
"category" : "other" ,
"comment" : "this is a turtle, not a person, therefore should not be a poster" ,
"forwarded" : true ,
"created_at" : "2022-05-15T14:20:12.000Z" ,
"updated_at" : "2022-05-15T14:20:12.000Z" ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"domain" : "fossbros-anonymous.io" ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"email" : "" ,
"ip" : null ,
"ips" : [ ] ,
"locale" : "" ,
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : false ,
"approved" : false ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
}
} ,
"target_account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"domain" : null ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"email" : "tortle.dude@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"acct" : "1happyturtle" ,
"display_name" : "happy little turtle :3" ,
"locked" : true ,
2023-02-16 14:20:23 +01:00
"discoverable" : false ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"note" : "\u003cp\u003ei post about things that concern me\u003c/p\u003e" ,
"url" : "http://localhost:8080/@1happyturtle" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 9 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
2023-05-09 12:16:10 +02:00
"fields" : [
{
"name" : "should you follow me?" ,
"value" : "maybe!" ,
"verified_at" : null
} ,
{
"name" : "age" ,
"value" : "120" ,
"verified_at" : null
}
] ,
2024-07-31 18:26:09 +02:00
"hide_collections" : true
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGY43H3N2C8EWPR2FPYEXG"
} ,
"assigned_account" : {
"id" : "01F8MH17FWEB39HZJ76B6VXSKF" ,
"username" : "admin" ,
"domain" : null ,
"created_at" : "2022-05-17T13:10:59.000Z" ,
"email" : "admin@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "admin" ,
"name" : "admin" ,
"color" : "" ,
"permissions" : "546033" ,
"highlighted" : true
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH17FWEB39HZJ76B6VXSKF" ,
"username" : "admin" ,
"acct" : "admin" ,
"display_name" : "" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-05-17T13:10:59.000Z" ,
"note" : "" ,
"url" : "http://localhost:8080/@admin" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
"statuses_count" : 4 ,
2024-10-12 10:02:26 +02:00
"last_status_at" : "2021-10-20" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ] ,
"enable_rss" : true ,
2024-07-31 18:26:09 +02:00
"roles" : [
{
"id" : "admin" ,
"name" : "admin" ,
"color" : ""
}
]
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGXQRHYF5QPMTMXP78QC2F"
} ,
"action_taken_by_account" : {
"id" : "01F8MH17FWEB39HZJ76B6VXSKF" ,
"username" : "admin" ,
"domain" : null ,
"created_at" : "2022-05-17T13:10:59.000Z" ,
"email" : "admin@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "admin" ,
"name" : "admin" ,
"color" : "" ,
"permissions" : "546033" ,
"highlighted" : true
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH17FWEB39HZJ76B6VXSKF" ,
"username" : "admin" ,
"acct" : "admin" ,
"display_name" : "" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-05-17T13:10:59.000Z" ,
"note" : "" ,
"url" : "http://localhost:8080/@admin" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
"statuses_count" : 4 ,
2024-10-12 10:02:26 +02:00
"last_status_at" : "2021-10-20" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ] ,
"enable_rss" : true ,
2024-07-31 18:26:09 +02:00
"roles" : [
{
"id" : "admin" ,
"name" : "admin" ,
"color" : ""
}
]
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGXQRHYF5QPMTMXP78QC2F"
} ,
"statuses" : [ ] ,
2023-08-19 14:33:15 +02:00
"rules" : [ ] ,
2023-01-25 11:12:17 +01:00
"action_taken_comment" : "user was warned not to be a turtle anymore"
} ,
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB5R" ,
"action_taken" : false ,
"action_taken_at" : null ,
"category" : "other" ,
"comment" : "dark souls sucks, please yeet this nerd" ,
"forwarded" : true ,
"created_at" : "2022-05-14T10:20:03.000Z" ,
"updated_at" : "2022-05-14T10:20:03.000Z" ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"domain" : null ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"email" : "tortle.dude@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"acct" : "1happyturtle" ,
"display_name" : "happy little turtle :3" ,
"locked" : true ,
2023-02-16 14:20:23 +01:00
"discoverable" : false ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"note" : "\u003cp\u003ei post about things that concern me\u003c/p\u003e" ,
"url" : "http://localhost:8080/@1happyturtle" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 9 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
2023-05-09 12:16:10 +02:00
"fields" : [
{
"name" : "should you follow me?" ,
"value" : "maybe!" ,
"verified_at" : null
} ,
{
"name" : "age" ,
"value" : "120" ,
"verified_at" : null
}
] ,
2024-07-31 18:26:09 +02:00
"hide_collections" : true
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGY43H3N2C8EWPR2FPYEXG"
} ,
"target_account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"domain" : "fossbros-anonymous.io" ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"email" : "" ,
"ip" : null ,
"ips" : [ ] ,
"locale" : "" ,
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : false ,
"approved" : false ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
}
} ,
"assigned_account" : null ,
"action_taken_by_account" : null ,
"statuses" : [
{
"id" : "01FVW7JHQFSFK166WWKR8CBA6M" ,
"created_at" : "2021-09-20T10:40:37.000Z" ,
2024-12-05 14:35:07 +01:00
"edited_at" : null ,
2023-01-25 11:12:17 +01:00
"in_reply_to_id" : null ,
"in_reply_to_account_id" : null ,
"sensitive" : false ,
"spoiler_text" : "" ,
"visibility" : "unlisted" ,
"language" : "en" ,
"uri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"url" : "http://fossbros-anonymous.io/@foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"replies_count" : 0 ,
"reblogs_count" : 0 ,
"favourites_count" : 0 ,
"favourited" : false ,
"reblogged" : false ,
"muted" : false ,
"bookmarked" : false ,
"pinned" : false ,
"content" : "dark souls status bot: \"thoughts of dog\"" ,
"reblog" : null ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
} ,
"media_attachments" : [
{
"id" : "01FVW7RXPQ8YJHTEXYPE7Q8ZY0" ,
"type" : "image" ,
"url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
"text_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/small/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.webp" ,
2023-01-25 11:12:17 +01:00
"remote_url" : "http://fossbros-anonymous.io/attachments/original/13bbc3f8-2b5e-46ea-9531-40b4974d9912.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_remote_url" : null ,
2023-01-25 11:12:17 +01:00
"meta" : {
"original" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"small" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"focus" : {
"x" : 0 ,
"y" : 0
}
} ,
"description" : "tweet from thoughts of dog: i drank. all the water. in my bowl. earlier. but just now. i returned. to the same bowl. and it was. full again.. the bowl. is haunted" ,
2024-07-19 17:28:43 +02:00
"blurhash" : "L3Q9_@4n9E?axW4mD$Mx~q00Di%L"
2023-01-25 11:12:17 +01:00
}
] ,
"mentions" : [ ] ,
"tags" : [ ] ,
"emojis" : [ ] ,
"card" : null ,
2024-07-17 16:46:52 +02:00
"poll" : null ,
"interaction_policy" : {
"can_favourite" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reply" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reblog" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
}
}
2023-01-25 11:12:17 +01:00
}
] ,
2023-08-19 14:33:15 +02:00
"rules" : [
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB51" ,
"text" : "Be gay"
} ,
{
"id" : "01GP3DFY9XQ1TJMZT5BGAZPXX3" ,
"text" : "Do crime"
}
] ,
2023-01-25 11:12:17 +01:00
"action_taken_comment" : null
}
] ` , string ( b ) )
suite . Equal ( ` <http://localhost:8080/api/v1/admin/reports?limit=20&max_id=01GP3AWY4CRDVRNZKW0TEAMB5R>; rel="next", <http://localhost:8080/api/v1/admin/reports?limit=20&min_id=01GP3DFY9XQ1TJMZT5BGAZPXX7>; rel="prev" ` , link )
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetCreatedByAccount ( ) {
2023-01-25 11:12:17 +01:00
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
account := suite . testAccounts [ "local_account_2" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , nil , account . ID , "" , "" , "" , "" , 20 )
suite . NoError ( err )
suite . NotEmpty ( reports )
b , err := json . MarshalIndent ( & reports , "" , " " )
suite . NoError ( err )
suite . Equal ( ` [
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB5R" ,
"action_taken" : false ,
"action_taken_at" : null ,
"category" : "other" ,
"comment" : "dark souls sucks, please yeet this nerd" ,
"forwarded" : true ,
"created_at" : "2022-05-14T10:20:03.000Z" ,
"updated_at" : "2022-05-14T10:20:03.000Z" ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"domain" : null ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"email" : "tortle.dude@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"acct" : "1happyturtle" ,
"display_name" : "happy little turtle :3" ,
"locked" : true ,
2023-02-16 14:20:23 +01:00
"discoverable" : false ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"note" : "\u003cp\u003ei post about things that concern me\u003c/p\u003e" ,
"url" : "http://localhost:8080/@1happyturtle" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 9 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
2023-05-09 12:16:10 +02:00
"fields" : [
{
"name" : "should you follow me?" ,
"value" : "maybe!" ,
"verified_at" : null
} ,
{
"name" : "age" ,
"value" : "120" ,
"verified_at" : null
}
] ,
2024-07-31 18:26:09 +02:00
"hide_collections" : true
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGY43H3N2C8EWPR2FPYEXG"
} ,
"target_account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"domain" : "fossbros-anonymous.io" ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"email" : "" ,
"ip" : null ,
"ips" : [ ] ,
"locale" : "" ,
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : false ,
"approved" : false ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
}
} ,
"assigned_account" : null ,
"action_taken_by_account" : null ,
"statuses" : [
{
"id" : "01FVW7JHQFSFK166WWKR8CBA6M" ,
"created_at" : "2021-09-20T10:40:37.000Z" ,
2024-12-05 14:35:07 +01:00
"edited_at" : null ,
2023-01-25 11:12:17 +01:00
"in_reply_to_id" : null ,
"in_reply_to_account_id" : null ,
"sensitive" : false ,
"spoiler_text" : "" ,
"visibility" : "unlisted" ,
"language" : "en" ,
"uri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"url" : "http://fossbros-anonymous.io/@foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"replies_count" : 0 ,
"reblogs_count" : 0 ,
"favourites_count" : 0 ,
"favourited" : false ,
"reblogged" : false ,
"muted" : false ,
"bookmarked" : false ,
"pinned" : false ,
"content" : "dark souls status bot: \"thoughts of dog\"" ,
"reblog" : null ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
} ,
"media_attachments" : [
{
"id" : "01FVW7RXPQ8YJHTEXYPE7Q8ZY0" ,
"type" : "image" ,
"url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
"text_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/small/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.webp" ,
2023-01-25 11:12:17 +01:00
"remote_url" : "http://fossbros-anonymous.io/attachments/original/13bbc3f8-2b5e-46ea-9531-40b4974d9912.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_remote_url" : null ,
2023-01-25 11:12:17 +01:00
"meta" : {
"original" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"small" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"focus" : {
"x" : 0 ,
"y" : 0
}
} ,
"description" : "tweet from thoughts of dog: i drank. all the water. in my bowl. earlier. but just now. i returned. to the same bowl. and it was. full again.. the bowl. is haunted" ,
2024-07-19 17:28:43 +02:00
"blurhash" : "L3Q9_@4n9E?axW4mD$Mx~q00Di%L"
2023-01-25 11:12:17 +01:00
}
] ,
"mentions" : [ ] ,
"tags" : [ ] ,
"emojis" : [ ] ,
"card" : null ,
2024-07-17 16:46:52 +02:00
"poll" : null ,
"interaction_policy" : {
"can_favourite" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reply" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reblog" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
}
}
2023-01-25 11:12:17 +01:00
}
] ,
2023-08-19 14:33:15 +02:00
"rules" : [
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB51" ,
"text" : "Be gay"
} ,
{
"id" : "01GP3DFY9XQ1TJMZT5BGAZPXX3" ,
"text" : "Do crime"
}
] ,
2023-01-25 11:12:17 +01:00
"action_taken_comment" : null
}
] ` , string ( b ) )
2024-06-18 18:18:00 +02:00
suite . Equal ( ` <http://localhost:8080/api/v1/admin/reports?account_id=01F8MH5NBDF2MV7CTC4Q5128HF&limit=20&max_id=01GP3AWY4CRDVRNZKW0TEAMB5R>; rel="next", <http://localhost:8080/api/v1/admin/reports?account_id=01F8MH5NBDF2MV7CTC4Q5128HF&limit=20&min_id=01GP3AWY4CRDVRNZKW0TEAMB5R>; rel="prev" ` , link )
2023-01-25 11:12:17 +01:00
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetTargetAccount ( ) {
2023-01-25 11:12:17 +01:00
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
targetAccount := suite . testAccounts [ "remote_account_1" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , nil , "" , targetAccount . ID , "" , "" , "" , 20 )
suite . NoError ( err )
suite . NotEmpty ( reports )
b , err := json . MarshalIndent ( & reports , "" , " " )
suite . NoError ( err )
suite . Equal ( ` [
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB5R" ,
"action_taken" : false ,
"action_taken_at" : null ,
"category" : "other" ,
"comment" : "dark souls sucks, please yeet this nerd" ,
"forwarded" : true ,
"created_at" : "2022-05-14T10:20:03.000Z" ,
"updated_at" : "2022-05-14T10:20:03.000Z" ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"domain" : null ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"email" : "tortle.dude@example.org" ,
2024-04-11 11:45:53 +02:00
"ip" : null ,
2023-01-25 11:12:17 +01:00
"ips" : [ ] ,
"locale" : "en" ,
2023-03-31 15:01:29 +02:00
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : true ,
"approved" : true ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5NBDF2MV7CTC4Q5128HF" ,
"username" : "1happyturtle" ,
"acct" : "1happyturtle" ,
"display_name" : "happy little turtle :3" ,
"locked" : true ,
2023-02-16 14:20:23 +01:00
"discoverable" : false ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2022-06-04T13:12:00.000Z" ,
"note" : "\u003cp\u003ei post about things that concern me\u003c/p\u003e" ,
"url" : "http://localhost:8080/@1happyturtle" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 1 ,
"following_count" : 1 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 9 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
2023-05-09 12:16:10 +02:00
"fields" : [
{
"name" : "should you follow me?" ,
"value" : "maybe!" ,
"verified_at" : null
} ,
{
"name" : "age" ,
"value" : "120" ,
"verified_at" : null
}
] ,
2024-07-31 18:26:09 +02:00
"hide_collections" : true
2023-01-25 11:12:17 +01:00
} ,
"created_by_application_id" : "01F8MGY43H3N2C8EWPR2FPYEXG"
} ,
"target_account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"domain" : "fossbros-anonymous.io" ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"email" : "" ,
"ip" : null ,
"ips" : [ ] ,
"locale" : "" ,
"invite_request" : null ,
2023-02-20 17:00:44 +01:00
"role" : {
2024-07-31 18:26:09 +02:00
"id" : "user" ,
"name" : "user" ,
"color" : "" ,
"permissions" : "0" ,
"highlighted" : false
2023-02-20 17:00:44 +01:00
} ,
2023-01-25 11:12:17 +01:00
"confirmed" : false ,
"approved" : false ,
"disabled" : false ,
"silenced" : false ,
"suspended" : false ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
}
} ,
"assigned_account" : null ,
"action_taken_by_account" : null ,
"statuses" : [
{
"id" : "01FVW7JHQFSFK166WWKR8CBA6M" ,
"created_at" : "2021-09-20T10:40:37.000Z" ,
2024-12-05 14:35:07 +01:00
"edited_at" : null ,
2023-01-25 11:12:17 +01:00
"in_reply_to_id" : null ,
"in_reply_to_account_id" : null ,
"sensitive" : false ,
"spoiler_text" : "" ,
"visibility" : "unlisted" ,
"language" : "en" ,
"uri" : "http://fossbros-anonymous.io/users/foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"url" : "http://fossbros-anonymous.io/@foss_satan/statuses/01FVW7JHQFSFK166WWKR8CBA6M" ,
"replies_count" : 0 ,
"reblogs_count" : 0 ,
"favourites_count" : 0 ,
"favourited" : false ,
"reblogged" : false ,
"muted" : false ,
"bookmarked" : false ,
"pinned" : false ,
"content" : "dark souls status bot: \"thoughts of dog\"" ,
"reblog" : null ,
"account" : {
"id" : "01F8MH5ZK5VRH73AKHQM6Y9VNX" ,
"username" : "foss_satan" ,
"acct" : "foss_satan@fossbros-anonymous.io" ,
"display_name" : "big gerald" ,
"locked" : false ,
2023-02-16 14:20:23 +01:00
"discoverable" : true ,
2023-01-25 11:12:17 +01:00
"bot" : false ,
"created_at" : "2021-09-26T10:52:36.000Z" ,
"note" : "i post about like, i dunno, stuff, or whatever!!!!" ,
"url" : "http://fossbros-anonymous.io/@foss_satan" ,
"avatar" : "" ,
"avatar_static" : "" ,
2024-07-20 15:02:22 +02:00
"header" : "http://localhost:8080/assets/default_header.webp" ,
"header_static" : "http://localhost:8080/assets/default_header.webp" ,
2024-10-21 14:04:50 +02:00
"header_description" : "Flat gray background (default header)." ,
2023-01-25 11:12:17 +01:00
"followers_count" : 0 ,
"following_count" : 0 ,
2024-12-05 14:35:07 +01:00
"statuses_count" : 4 ,
"last_status_at" : "2024-11-01" ,
2023-01-25 11:12:17 +01:00
"emojis" : [ ] ,
"fields" : [ ]
} ,
"media_attachments" : [
{
"id" : "01FVW7RXPQ8YJHTEXYPE7Q8ZY0" ,
"type" : "image" ,
"url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
"text_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/original/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_url" : "http://localhost:8080/fileserver/01F8MH5ZK5VRH73AKHQM6Y9VNX/attachment/small/01FVW7RXPQ8YJHTEXYPE7Q8ZY0.webp" ,
2023-01-25 11:12:17 +01:00
"remote_url" : "http://fossbros-anonymous.io/attachments/original/13bbc3f8-2b5e-46ea-9531-40b4974d9912.jpg" ,
2024-07-19 17:28:43 +02:00
"preview_remote_url" : null ,
2023-01-25 11:12:17 +01:00
"meta" : {
"original" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"small" : {
"width" : 472 ,
"height" : 291 ,
"size" : "472x291" ,
"aspect" : 1.6219932
} ,
"focus" : {
"x" : 0 ,
"y" : 0
}
} ,
"description" : "tweet from thoughts of dog: i drank. all the water. in my bowl. earlier. but just now. i returned. to the same bowl. and it was. full again.. the bowl. is haunted" ,
2024-07-19 17:28:43 +02:00
"blurhash" : "L3Q9_@4n9E?axW4mD$Mx~q00Di%L"
2023-01-25 11:12:17 +01:00
}
] ,
"mentions" : [ ] ,
"tags" : [ ] ,
"emojis" : [ ] ,
"card" : null ,
2024-07-17 16:46:52 +02:00
"poll" : null ,
"interaction_policy" : {
"can_favourite" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reply" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
} ,
"can_reblog" : {
"always" : [
2024-07-24 13:27:42 +02:00
"public" ,
"me"
2024-07-17 16:46:52 +02:00
] ,
"with_approval" : [ ]
}
}
2023-01-25 11:12:17 +01:00
}
] ,
2023-08-19 14:33:15 +02:00
"rules" : [
{
"id" : "01GP3AWY4CRDVRNZKW0TEAMB51" ,
"text" : "Be gay"
} ,
{
"id" : "01GP3DFY9XQ1TJMZT5BGAZPXX3" ,
"text" : "Do crime"
}
] ,
2023-01-25 11:12:17 +01:00
"action_taken_comment" : null
}
] ` , string ( b ) )
suite . Equal ( ` <http://localhost:8080/api/v1/admin/reports?limit=20&max_id=01GP3AWY4CRDVRNZKW0TEAMB5R&target_account_id=01F8MH5ZK5VRH73AKHQM6Y9VNX>; rel="next", <http://localhost:8080/api/v1/admin/reports?limit=20&min_id=01GP3AWY4CRDVRNZKW0TEAMB5R&target_account_id=01F8MH5ZK5VRH73AKHQM6Y9VNX>; rel="prev" ` , link )
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetResolvedTargetAccount ( ) {
2023-01-25 11:12:17 +01:00
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
2023-08-07 19:38:11 +02:00
resolved := util . Ptr ( false )
2023-01-25 11:12:17 +01:00
targetAccount := suite . testAccounts [ "local_account_2" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , resolved , "" , targetAccount . ID , "" , "" , "" , 20 )
suite . NoError ( err )
suite . Empty ( reports )
b , err := json . MarshalIndent ( & reports , "" , " " )
suite . NoError ( err )
suite . Equal ( ` [] ` , string ( b ) )
suite . Empty ( link )
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetNotAdmin ( ) {
2023-01-25 11:12:17 +01:00
testAccount := suite . testAccounts [ "local_account_1" ]
testToken := suite . testTokens [ "local_account_1" ]
testUser := suite . testUsers [ "local_account_1" ]
reports , _ , err := suite . getReports ( testAccount , testToken , testUser , http . StatusForbidden , ` { "error":"Forbidden: user 01F8MGVGPHQ2D3P3X0454H54Z5 not an admin"} ` , nil , "" , "" , "" , "" , "" , 20 )
suite . NoError ( err )
suite . Empty ( reports )
}
2023-03-03 14:01:11 +01:00
func ( suite * ReportsGetTestSuite ) TestReportsGetZeroLimit ( ) {
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , nil , "" , "" , "" , "" , "" , 0 )
suite . NoError ( err )
suite . Len ( reports , 2 )
2024-06-18 18:18:00 +02:00
// Limit in Link header should be set to default (20)
suite . Equal ( ` <http://localhost:8080/api/v1/admin/reports?limit=20&max_id=01GP3AWY4CRDVRNZKW0TEAMB5R>; rel="next", <http://localhost:8080/api/v1/admin/reports?limit=20&min_id=01GP3DFY9XQ1TJMZT5BGAZPXX7>; rel="prev" ` , link )
2023-03-03 14:01:11 +01:00
}
func ( suite * ReportsGetTestSuite ) TestReportsGetHighLimit ( ) {
testAccount := suite . testAccounts [ "admin_account" ]
testToken := suite . testTokens [ "admin_account" ]
testUser := suite . testUsers [ "admin_account" ]
reports , link , err := suite . getReports ( testAccount , testToken , testUser , http . StatusOK , "" , nil , "" , "" , "" , "" , "" , 2000 )
suite . NoError ( err )
suite . Len ( reports , 2 )
2023-03-12 16:00:57 +01:00
// Limit in Link header should be set to 100
2023-03-03 14:01:11 +01:00
suite . Equal ( ` <http://localhost:8080/api/v1/admin/reports?limit=100&max_id=01GP3AWY4CRDVRNZKW0TEAMB5R>; rel="next", <http://localhost:8080/api/v1/admin/reports?limit=100&min_id=01GP3DFY9XQ1TJMZT5BGAZPXX7>; rel="prev" ` , link )
}
2023-01-25 11:12:17 +01:00
func TestReportsGetTestSuite ( t * testing . T ) {
suite . Run ( t , & ReportsGetTestSuite { } )
}