summaryrefslogtreecommitdiff
path: root/internal/api/client/status
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client/status')
-rw-r--r--internal/api/client/status/status_test.go97
-rw-r--r--internal/api/client/status/statuscreate_test.go4
2 files changed, 3 insertions, 98 deletions
diff --git a/internal/api/client/status/status_test.go b/internal/api/client/status/status_test.go
index e2e2819b5..049a5069c 100644
--- a/internal/api/client/status/status_test.go
+++ b/internal/api/client/status/status_test.go
@@ -19,18 +19,8 @@
package status_test
import (
- "bytes"
- "context"
- "encoding/json"
- "fmt"
- "io"
- "io/ioutil"
- "net/http"
-
"codeberg.org/gruf/go-store/kv"
"github.com/stretchr/testify/suite"
- "github.com/superseriousbusiness/activity/pub"
- "github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
"github.com/superseriousbusiness/gotosocial/internal/concurrency"
"github.com/superseriousbusiness/gotosocial/internal/db"
@@ -94,7 +84,7 @@ func (suite *StatusStandardTestSuite) SetupTest() {
clientWorker := concurrency.NewWorkerPool[messages.FromClientAPI](-1, -1)
suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage)
- suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(suite.testHttpClient(), suite.db, fedWorker), suite.storage, suite.mediaManager, fedWorker)
+ suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil, "../../../../testrig/media"), suite.db, fedWorker), suite.storage, suite.mediaManager, fedWorker)
suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator, suite.emailSender, suite.mediaManager, clientWorker, fedWorker)
suite.statusModule = status.New(suite.processor).(*status.Module)
@@ -104,88 +94,3 @@ func (suite *StatusStandardTestSuite) TearDownTest() {
testrig.StandardDBTeardown(suite.db)
testrig.StandardStorageTeardown(suite.storage)
}
-
-func (suite *StatusStandardTestSuite) testHttpClient() pub.HttpClient {
- remoteAccount := suite.testAccounts["remote_account_1"]
- remoteAccountNamestring := fmt.Sprintf("acct:%s@%s", remoteAccount.Username, remoteAccount.Domain)
- remoteAccountWebfingerURI := fmt.Sprintf("https://%s/.well-known/webfinger?resource=%s", remoteAccount.Domain, remoteAccountNamestring)
-
- fmt.Println(remoteAccountWebfingerURI)
-
- httpClient := testrig.NewMockHTTPClient(func(req *http.Request) (*http.Response, error) {
- // respond correctly to a webfinger lookup
- if req.URL.String() == remoteAccountWebfingerURI {
- responseJson := fmt.Sprintf(`
- {
- "subject": "%s",
- "aliases": [
- "%s",
- "%s"
- ],
- "links": [
- {
- "rel": "http://webfinger.net/rel/profile-page",
- "type": "text/html",
- "href": "%s"
- },
- {
- "rel": "self",
- "type": "application/activity+json",
- "href": "%s"
- }
- ]
- }`, remoteAccountNamestring, remoteAccount.URI, remoteAccount.URL, remoteAccount.URL, remoteAccount.URI)
- responseType := "application/json"
-
- reader := bytes.NewReader([]byte(responseJson))
- readCloser := io.NopCloser(reader)
- response := &http.Response{
- StatusCode: 200,
- Body: readCloser,
- ContentLength: int64(len(responseJson)),
- Header: http.Header{
- "content-type": {responseType},
- },
- }
- return response, nil
- }
-
- // respond correctly to an account dereference
- if req.URL.String() == remoteAccount.URI {
- satanAS, err := suite.tc.AccountToAS(context.Background(), remoteAccount)
- if err != nil {
- panic(err)
- }
-
- satanI, err := streams.Serialize(satanAS)
- if err != nil {
- panic(err)
- }
- satanJson, err := json.Marshal(satanI)
- if err != nil {
- panic(err)
- }
- responseType := "application/activity+json"
-
- reader := bytes.NewReader(satanJson)
- readCloser := io.NopCloser(reader)
- response := &http.Response{
- StatusCode: 200,
- Body: readCloser,
- ContentLength: int64(len(satanJson)),
- Header: http.Header{
- "content-type": {responseType},
- },
- }
- return response, nil
- }
-
- r := ioutil.NopCloser(bytes.NewReader([]byte{}))
- return &http.Response{
- StatusCode: 200,
- Body: r,
- }, nil
- })
-
- return httpClient
-}
diff --git a/internal/api/client/status/statuscreate_test.go b/internal/api/client/status/statuscreate_test.go
index 61d0a5ee4..206dc5cfc 100644
--- a/internal/api/client/status/statuscreate_test.go
+++ b/internal/api/client/status/statuscreate_test.go
@@ -128,7 +128,7 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() {
ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080/%s", status.BasePath), nil) // the endpoint we're hitting
ctx.Request.Header.Set("accept", "application/json")
ctx.Request.Form = url.Values{
- "status": {"hello @foss_satan@fossbros-anonymous.io"},
+ "status": {"hello @brand_new_person@unknown-instance.com"},
"visibility": {string(model.VisibilityPublic)},
}
suite.statusModule.StatusCreatePOSTHandler(ctx)
@@ -145,7 +145,7 @@ func (suite *StatusCreateTestSuite) TestMentionUnknownAccount() {
suite.NoError(err)
// if the status is properly formatted, that means the account has been put in the db
- suite.Equal("<p>hello <span class=\"h-card\"><a href=\"http://fossbros-anonymous.io/@foss_satan\" class=\"u-url mention\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">@<span>foss_satan</span></a></span></p>", statusReply.Content)
+ suite.Equal(`<p>hello <span class="h-card"><a href="https://unknown-instance.com/@brand_new_person" class="u-url mention" rel="nofollow noreferrer noopener" target="_blank">@<span>brand_new_person</span></a></span></p>`, statusReply.Content)
suite.Equal(model.VisibilityPublic, statusReply.Visibility)
}