2023-03-12 15:00:57 +00: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/>.
|
2022-11-29 09:24:55 +00:00
|
|
|
|
|
|
|
package search_test
|
|
|
|
|
|
|
|
import (
|
2023-06-21 17:26:40 +01:00
|
|
|
"context"
|
2023-08-02 08:31:09 +01:00
|
|
|
"crypto/rand"
|
|
|
|
"crypto/rsa"
|
2022-11-29 09:24:55 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2023-06-21 17:26:40 +01:00
|
|
|
"io"
|
2022-11-29 09:24:55 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2023-06-21 17:26:40 +01:00
|
|
|
"net/url"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
2022-11-29 09:24:55 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
2023-08-02 08:31:09 +01:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
2022-11-29 09:24:55 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api/client/search"
|
|
|
|
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
2023-06-21 17:26:40 +01:00
|
|
|
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/testrig"
|
2022-11-29 09:24:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SearchGetTestSuite struct {
|
|
|
|
SearchStandardTestSuite
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) getSearch(
|
|
|
|
requestingAccount *gtsmodel.Account,
|
|
|
|
token *gtsmodel.Token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiVersion string,
|
2023-06-21 17:26:40 +01:00
|
|
|
user *gtsmodel.User,
|
|
|
|
maxID *string,
|
|
|
|
minID *string,
|
|
|
|
limit *int,
|
|
|
|
offset *int,
|
|
|
|
query string,
|
|
|
|
queryType *string,
|
|
|
|
resolve *bool,
|
|
|
|
following *bool,
|
|
|
|
expectedHTTPStatus int,
|
|
|
|
expectedBody string,
|
|
|
|
) (*apimodel.SearchResult, error) {
|
|
|
|
var (
|
|
|
|
recorder = httptest.NewRecorder()
|
|
|
|
ctx, _ = testrig.CreateGinTestContext(recorder, nil)
|
2023-07-31 14:47:35 +01:00
|
|
|
requestURL = testrig.URLMustParse("/api" + search.BasePath)
|
2023-06-21 17:26:40 +01:00
|
|
|
queryParts []string
|
|
|
|
)
|
|
|
|
|
|
|
|
// Put the request together.
|
2023-07-31 14:47:35 +01:00
|
|
|
ctx.AddParam(apiutil.APIVersionKey, apiVersion)
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
if maxID != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.MaxIDKey+"="+url.QueryEscape(*maxID))
|
|
|
|
}
|
|
|
|
|
|
|
|
if minID != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.MinIDKey+"="+url.QueryEscape(*minID))
|
|
|
|
}
|
|
|
|
|
|
|
|
if limit != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.LimitKey+"="+strconv.Itoa(*limit))
|
|
|
|
}
|
|
|
|
|
|
|
|
if offset != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.SearchOffsetKey+"="+strconv.Itoa(*offset))
|
|
|
|
}
|
|
|
|
|
|
|
|
queryParts = append(queryParts, apiutil.SearchQueryKey+"="+url.QueryEscape(query))
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
if queryType != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.SearchTypeKey+"="+url.QueryEscape(*queryType))
|
|
|
|
}
|
|
|
|
|
|
|
|
if resolve != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.SearchResolveKey+"="+strconv.FormatBool(*resolve))
|
|
|
|
}
|
|
|
|
|
|
|
|
if following != nil {
|
|
|
|
queryParts = append(queryParts, apiutil.SearchFollowingKey+"="+strconv.FormatBool(*following))
|
|
|
|
}
|
|
|
|
|
|
|
|
requestURL.RawQuery = strings.Join(queryParts, "&")
|
|
|
|
ctx.Request = httptest.NewRequest(http.MethodGet, requestURL.String(), nil)
|
|
|
|
ctx.Set(oauth.SessionAuthorizedAccount, requestingAccount)
|
|
|
|
ctx.Set(oauth.SessionAuthorizedToken, oauth.DBTokenToToken(token))
|
|
|
|
ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
|
|
|
|
ctx.Set(oauth.SessionAuthorizedUser, user)
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
// Trigger the function being tested.
|
2022-11-29 09:24:55 +00:00
|
|
|
suite.searchModule.SearchGETHandler(ctx)
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
// Read the result.
|
2022-11-29 09:24:55 +00:00
|
|
|
result := recorder.Result()
|
|
|
|
defer result.Body.Close()
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
b, err := io.ReadAll(result.Body)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
errs := gtserror.MultiError{}
|
|
|
|
|
|
|
|
// Check expected code + body.
|
2022-11-29 09:24:55 +00:00
|
|
|
if resultCode := recorder.Code; expectedHTTPStatus != resultCode {
|
2023-06-22 20:46:36 +01:00
|
|
|
errs = append(errs, fmt.Sprintf("expected %d got %d: %v", expectedHTTPStatus, resultCode, ctx.Errors.JSON()))
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
// If we got an expected body, return early.
|
|
|
|
if expectedBody != "" && string(b) != expectedBody {
|
|
|
|
errs = append(errs, fmt.Sprintf("expected %s got %s", expectedBody, string(b)))
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := errs.Combine(); err != nil {
|
|
|
|
suite.FailNow("", "%v (body %s)", err, string(b))
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
searchResult := &apimodel.SearchResult{}
|
|
|
|
if err := json.Unmarshal(b, searchResult); err != nil {
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.FailNow(err.Error())
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return searchResult, nil
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) bodgeLocalInstance(domain string) {
|
|
|
|
// Set new host.
|
|
|
|
config.SetHost(domain)
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
// Copy instance account to not mess up other tests.
|
|
|
|
instanceAccount := >smodel.Account{}
|
|
|
|
*instanceAccount = *suite.testAccounts["instance_account"]
|
|
|
|
|
|
|
|
// Set username of instance account to given domain.
|
|
|
|
instanceAccount.Username = domain
|
|
|
|
if err := suite.db.UpdateAccount(context.Background(), instanceAccount, "username"); err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByURI() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "https://unknown-instance.com/users/brand_new_person"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
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) TestSearchRemoteAccountByNamestring() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "@brand_new_person@unknown-instance.com"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:44:02 +00:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringUppercase() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "@Some_User@example.org"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-30 16:44:02 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-11-29 09:24:55 +00:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringNoLeadingAt() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "brand_new_person@unknown-instance.com"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
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) TestSearchRemoteAccountByNamestringNoResolve() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@brand_new_person@unknown-instance.com"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
}
|
|
|
|
|
2023-05-07 18:53:21 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringSpecialChars() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@üser@ëxample.org"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2023-05-07 18:53:21 +01:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if l := len(searchResult.Accounts); l != 1 {
|
|
|
|
suite.FailNow("", "expected %d accounts, got %d", 1, l)
|
|
|
|
}
|
|
|
|
suite.Equal("üser@ëxample.org", searchResult.Accounts[0].Acct)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteAccountByNamestringSpecialCharsPunycode() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@üser@xn--xample-ova.org"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2023-05-07 18:53:21 +01:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if l := len(searchResult.Accounts); l != 1 {
|
|
|
|
suite.FailNow("", "expected %d accounts, got %d", 1, l)
|
|
|
|
}
|
|
|
|
suite.Equal("üser@ëxample.org", searchResult.Accounts[0].Acct)
|
|
|
|
}
|
|
|
|
|
2022-11-29 09:24:55 +00:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalAccountByNamestring() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@the_mighty_zork"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
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) TestSearchLocalAccountByNamestringWithDomain() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@the_mighty_zork@localhost:8080"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
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) TestSearchNonexistingLocalAccountByNamestringResolveTrue() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "@somone_made_up@localhost:8080"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalAccountByURI() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "http://localhost:8080/users/the_mighty_zork"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if !suite.Len(searchResult.Accounts, 1) {
|
|
|
|
suite.FailNow("expected 1 account in search results but got 0")
|
|
|
|
}
|
|
|
|
|
2023-05-09 16:05:35 +01:00
|
|
|
gotAccount := searchResult.Accounts[0]
|
|
|
|
suite.NotNil(gotAccount)
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalAccountByURL() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "http://localhost:8080/@the_mighty_zork"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2023-05-09 16:05:35 +01:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if !suite.Len(searchResult.Accounts, 1) {
|
|
|
|
suite.FailNow("expected 1 account in search results but got 0")
|
|
|
|
}
|
|
|
|
|
2022-11-29 09:24:55 +00:00
|
|
|
gotAccount := searchResult.Accounts[0]
|
|
|
|
suite.NotNil(gotAccount)
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchNonexistingLocalAccountByURL() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "http://localhost:8080/@the_shmighty_shmork"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchStatusByURL() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "https://turnip.farm/users/turniplover6969/statuses/70c53e54-3146-42d5-a630-83c8b6c7c042"
|
|
|
|
queryType *string = func() *string { i := "statuses"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
if !suite.Len(searchResult.Statuses, 1) {
|
|
|
|
suite.FailNow("expected 1 status in search results but got 0")
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
gotStatus := searchResult.Statuses[0]
|
|
|
|
suite.NotNil(gotStatus)
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchBlockedDomainURL() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "https://replyguys.com/@someone"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchBlockedDomainNamestring() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "@someone@replyguys.com"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchAAny() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "a"
|
|
|
|
queryType *string = nil // Return anything.
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 5)
|
|
|
|
suite.Len(searchResult.Statuses, 4)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
2022-11-29 09:24:55 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchAAnyFollowingOnly() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "a"
|
|
|
|
queryType *string = nil // Return anything.
|
|
|
|
following *bool = func() *bool { i := true; return &i }()
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2022-11-29 09:24:55 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Accounts, 2)
|
|
|
|
suite.Len(searchResult.Statuses, 4)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchAStatuses() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "a"
|
|
|
|
queryType *string = func() *string { i := "statuses"; return &i }() // Only statuses.
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 4)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
2022-11-29 09:24:55 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchAAccounts() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "a"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }() // Only accounts.
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
2023-02-14 10:55:02 +00:00
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Accounts, 5)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchAccountsLimit1() {
|
2023-06-21 17:26:40 +01:00
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = func() *int { i := 1; return &i }()
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = func() *bool { i := true; return &i }()
|
|
|
|
query = "a"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }() // Only accounts.
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 1)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalInstanceAccountByURI() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "http://localhost:8080/users/localhost:8080"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2023-02-14 10:55:02 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
// Should be able to get instance
|
|
|
|
// account by exact URI.
|
|
|
|
suite.Len(searchResult.Accounts, 1)
|
2023-02-14 10:55:02 +00:00
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalInstanceAccountFull() {
|
2023-06-21 17:26:40 +01:00
|
|
|
// Namestring excludes ':' in usernames, so we
|
|
|
|
// need to fiddle with the instance account a
|
|
|
|
// bit to get it to look like a different domain.
|
|
|
|
newDomain := "example.org"
|
|
|
|
suite.bodgeLocalInstance(newDomain)
|
|
|
|
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@" + newDomain + "@" + newDomain
|
|
|
|
queryType *string = nil
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
2023-02-14 10:55:02 +00:00
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
// Should be able to get instance
|
|
|
|
// account by full namestring.
|
|
|
|
suite.Len(searchResult.Accounts, 1)
|
2023-06-21 17:26:40 +01:00
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalInstanceAccountPartial() {
|
2023-06-21 17:26:40 +01:00
|
|
|
// Namestring excludes ':' in usernames, so we
|
|
|
|
// need to fiddle with the instance account a
|
|
|
|
// bit to get it to look like a different domain.
|
|
|
|
newDomain := "example.org"
|
|
|
|
suite.bodgeLocalInstance(newDomain)
|
|
|
|
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@" + newDomain
|
|
|
|
queryType *string = nil
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
2023-02-14 10:55:02 +00:00
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
2023-08-02 08:31:09 +01:00
|
|
|
// Query was a partial namestring from our
|
|
|
|
// instance, so will return the instance account.
|
|
|
|
suite.Len(searchResult.Accounts, 1)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchLocalInstanceAccountEvenMorePartial() {
|
|
|
|
// Namestring excludes ':' in usernames, so we
|
|
|
|
// need to fiddle with the instance account a
|
|
|
|
// bit to get it to look like a different domain.
|
|
|
|
newDomain := "example.org"
|
|
|
|
suite.bodgeLocalInstance(newDomain)
|
|
|
|
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = newDomain
|
|
|
|
queryType *string = nil
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query was just 'example.org' which doesn't
|
|
|
|
// look like a namestring, so search should
|
|
|
|
// fall back to text search and therefore give
|
|
|
|
// 0 results back.
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchRemoteInstanceAccountPartial() {
|
|
|
|
// Insert an instance account that's not
|
|
|
|
// from our instance, and try to search
|
|
|
|
// for it with a partial namestring.
|
|
|
|
theirDomain := "example.org"
|
|
|
|
|
|
|
|
key, err := rsa.GenerateKey(rand.Reader, 2048)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := suite.db.PutAccount(context.Background(), >smodel.Account{
|
|
|
|
ID: "01H6RWPG8T6DNW6VNXPBCJBH5S",
|
|
|
|
Username: theirDomain,
|
|
|
|
Domain: theirDomain,
|
|
|
|
URI: "http://" + theirDomain + "/users/" + theirDomain,
|
|
|
|
URL: "http://" + theirDomain + "/@" + theirDomain,
|
|
|
|
PublicKeyURI: "http://" + theirDomain + "/users/" + theirDomain + "#main-key",
|
|
|
|
InboxURI: "http://" + theirDomain + "/users/" + theirDomain + "/inbox",
|
|
|
|
OutboxURI: "http://" + theirDomain + "/users/" + theirDomain + "/outbox",
|
|
|
|
FollowersURI: "http://" + theirDomain + "/users/" + theirDomain + "/followers",
|
|
|
|
FollowingURI: "http://" + theirDomain + "/users/" + theirDomain + "/following",
|
|
|
|
FeaturedCollectionURI: "http://" + theirDomain + "/users/" + theirDomain + "/collections/featured",
|
|
|
|
ActorType: ap.ActorPerson,
|
|
|
|
PrivateKey: key,
|
|
|
|
PublicKey: &key.PublicKey,
|
|
|
|
}); err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "@" + theirDomain
|
|
|
|
queryType *string = nil
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ""
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for instance account from
|
|
|
|
// another domain should return 0 results.
|
2023-02-14 10:55:02 +00:00
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
2023-06-21 17:26:40 +01:00
|
|
|
func (suite *SearchGetTestSuite) TestSearchBadQueryType() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "whatever"
|
|
|
|
queryType *string = func() *string { i := "aaaaaaaaaaa"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusBadRequest
|
|
|
|
expectedBody = `{"error":"Bad Request: search query type aaaaaaaaaaa was not recognized, valid options are ['', 'accounts', 'statuses', 'hashtags']"}`
|
|
|
|
)
|
|
|
|
|
|
|
|
_, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchEmptyQuery() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = ""
|
|
|
|
queryType *string = func() *string { i := "aaaaaaaaaaa"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusBadRequest
|
|
|
|
expectedBody = `{"error":"Bad Request: required key q was not set or had empty value"}`
|
|
|
|
)
|
|
|
|
|
|
|
|
_, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
2023-07-31 14:47:35 +01:00
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchHashtagV1() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "#welcome"
|
|
|
|
queryType *string = func() *string { i := "hashtags"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = `{"accounts":[],"statuses":[],"hashtags":[{"name":"welcome","url":"http://localhost:8080/tags/welcome","history":[]}]}`
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchHashtagV2() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "#welcome"
|
|
|
|
queryType *string = func() *string { i := "hashtags"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = `{"accounts":[],"statuses":[],"hashtags":["welcome"]}`
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv1,
|
2023-06-21 17:26:40 +01:00
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
2023-07-31 14:47:35 +01:00
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchHashtagButWithAccountSearch() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "#welcome"
|
|
|
|
queryType *string = func() *string { i := "accounts"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ``
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (suite *SearchGetTestSuite) TestSearchNotHashtagButWithTypeHashtag() {
|
|
|
|
var (
|
|
|
|
requestingAccount = suite.testAccounts["local_account_1"]
|
|
|
|
token = suite.testTokens["local_account_1"]
|
|
|
|
user = suite.testUsers["local_account_1"]
|
|
|
|
maxID *string = nil
|
|
|
|
minID *string = nil
|
|
|
|
limit *int = nil
|
|
|
|
offset *int = nil
|
|
|
|
resolve *bool = nil
|
|
|
|
query = "welco"
|
|
|
|
queryType *string = func() *string { i := "hashtags"; return &i }()
|
|
|
|
following *bool = nil
|
|
|
|
expectedHTTPStatus = http.StatusOK
|
|
|
|
expectedBody = ``
|
|
|
|
)
|
|
|
|
|
|
|
|
searchResult, err := suite.getSearch(
|
|
|
|
requestingAccount,
|
|
|
|
token,
|
|
|
|
apiutil.APIv2,
|
|
|
|
user,
|
|
|
|
maxID,
|
|
|
|
minID,
|
|
|
|
limit,
|
|
|
|
offset,
|
|
|
|
query,
|
|
|
|
queryType,
|
|
|
|
resolve,
|
|
|
|
following,
|
|
|
|
expectedHTTPStatus,
|
|
|
|
expectedBody)
|
|
|
|
if err != nil {
|
|
|
|
suite.FailNow(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
suite.Len(searchResult.Accounts, 0)
|
|
|
|
suite.Len(searchResult.Statuses, 0)
|
|
|
|
suite.Len(searchResult.Hashtags, 1)
|
2023-06-21 17:26:40 +01:00
|
|
|
}
|
|
|
|
|
2022-11-29 09:24:55 +00:00
|
|
|
func TestSearchGetTestSuite(t *testing.T) {
|
|
|
|
suite.Run(t, &SearchGetTestSuite{})
|
|
|
|
}
|