diff --git a/internal/api/client/media/mediacreate_test.go b/internal/api/client/media/mediacreate_test.go
index a61a36324..5c48a4381 100644
--- a/internal/api/client/media/mediacreate_test.go
+++ b/internal/api/client/media/mediacreate_test.go
@@ -156,7 +156,7 @@ func (suite *MediaCreateTestSuite) TestStatusCreatePOSTImageHandlerSuccessful()
}
// check response
- suite.EqualValues(http.StatusAccepted, recorder.Code)
+ suite.EqualValues(http.StatusOK, recorder.Code)
result := recorder.Result()
defer result.Body.Close()
diff --git a/internal/api/client/status/statuscreate_test.go b/internal/api/client/status/statuscreate_test.go
index 603432724..c175a54ec 100644
--- a/internal/api/client/status/statuscreate_test.go
+++ b/internal/api/client/status/statuscreate_test.go
@@ -93,13 +93,13 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() {
ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080/%s", status.BasePath), nil) // the endpoint we're hitting
ctx.Request.Form = url.Values{
- "status": {"this is a brand new status! #helloworld"},
- "spoiler_text": {"hello hello"},
- "sensitive": {"true"},
- "visibility_advanced": {"mutuals_only"},
- "likeable": {"false"},
- "replyable": {"false"},
- "federated": {"false"},
+ "status": {"this is a brand new status! #helloworld"},
+ "spoiler_text": {"hello hello"},
+ "sensitive": {"true"},
+ "visibility": {string(model.VisibilityMutualsOnly)},
+ "likeable": {"false"},
+ "replyable": {"false"},
+ "federated": {"false"},
}
suite.statusModule.StatusCreatePOSTHandler(ctx)
@@ -120,7 +120,7 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() {
assert.Equal(suite.T(), "hello hello", statusReply.SpoilerText)
assert.Equal(suite.T(), "
this is a brand new status! #helloworld
", statusReply.Content)
assert.True(suite.T(), statusReply.Sensitive)
- assert.Equal(suite.T(), model.VisibilityPrivate, statusReply.Visibility)
+ assert.Equal(suite.T(), model.VisibilityPrivate, statusReply.Visibility) // even though we set this status to mutuals only, it should serialize to private, because masto has no idea about mutuals_only
assert.Len(suite.T(), statusReply.Tags, 1)
assert.Equal(suite.T(), model.Tag{
Name: "helloworld",
@@ -161,13 +161,11 @@ func (suite *StatusCreateTestSuite) TestPostAnotherNewStatus() {
b, err := ioutil.ReadAll(result.Body)
assert.NoError(suite.T(), err)
- fmt.Println(string(b))
-
statusReply := &model.Status{}
err = json.Unmarshal(b, statusReply)
assert.NoError(suite.T(), err)
- assert.Equal(suite.T(), "#test alright, should be able to post #links with fragments in them now, let's see........
docs.gotosocial.org/en/latest/user_guide/posts/#links
#gotosocial
(tobi remember to pull the docker image challenge)
", statusReply.Content)
+ assert.Equal(suite.T(), "\u003cp\u003e\u003ca href=\"http://localhost:8080/tags/test\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\"\u003e#\u003cspan\u003etest\u003c/span\u003e\u003c/a\u003e alright, should be able to post \u003ca href=\"http://localhost:8080/tags/links\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\"\u003e#\u003cspan\u003elinks\u003c/span\u003e\u003c/a\u003e with fragments in them now, let\u0026#39;s see........\u003cbr/\u003e\u003cbr/\u003e\u003ca href=\"https://docs.gotosocial.org/en/latest/user_guide/posts/#links\" rel=\"noopener nofollow noreferrer\" target=\"_blank\"\u003edocs.gotosocial.org/en/latest/user_guide/posts/#links\u003c/a\u003e\u003cbr/\u003e\u003cbr/\u003e\u003ca href=\"http://localhost:8080/tags/gotosocial\" class=\"mention hashtag\" rel=\"tag nofollow noreferrer noopener\" target=\"_blank\"\u003e#\u003cspan\u003egotosocial\u003c/span\u003e\u003c/a\u003e\u003cbr/\u003e\u003cbr/\u003e(tobi remember to pull the docker image challenge)\u003c/p\u003e", statusReply.Content)
}
func (suite *StatusCreateTestSuite) TestPostNewStatusWithEmoji() {
diff --git a/internal/federation/federator_test.go b/internal/federation/federator_test.go
index d74070487..00a29465e 100644
--- a/internal/federation/federator_test.go
+++ b/internal/federation/federator_test.go
@@ -19,15 +19,9 @@
package federation_test
import (
- "bytes"
"context"
- "crypto/x509"
- "encoding/pem"
- "fmt"
- "io/ioutil"
"net/http"
"net/http/httptest"
- "strings"
"testing"
"github.com/go-fed/activity/pub"
@@ -117,43 +111,7 @@ func (suite *ProtocolTestSuite) TestAuthenticatePostInbox() {
sendingAccount := suite.accounts["remote_account_1"]
inboxAccount := suite.accounts["local_account_1"]
- encodedPublicKey, err := x509.MarshalPKIXPublicKey(sendingAccount.PublicKey)
- assert.NoError(suite.T(), err)
- publicKeyBytes := pem.EncodeToMemory(&pem.Block{
- Type: "PUBLIC KEY",
- Bytes: encodedPublicKey,
- })
- publicKeyString := strings.ReplaceAll(string(publicKeyBytes), "\n", "\\n")
-
- // for this test we need the client to return the public key of the activity creator on the 'remote' instance
- responseBodyString := fmt.Sprintf(`
- {
- "@context": [
- "https://www.w3.org/ns/activitystreams",
- "https://w3id.org/security/v1"
- ],
-
- "id": "%s",
- "type": "Person",
- "preferredUsername": "%s",
- "inbox": "%s",
-
- "publicKey": {
- "id": "%s",
- "owner": "%s",
- "publicKeyPem": "%s"
- }
- }`, sendingAccount.URI, sendingAccount.Username, sendingAccount.InboxURI, sendingAccount.PublicKeyURI, sendingAccount.URI, publicKeyString)
-
- // create a transport controller whose client will just return the response body string we specified above
- tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(func(req *http.Request) (*http.Response, error) {
- r := ioutil.NopCloser(bytes.NewReader([]byte(responseBodyString)))
- return &http.Response{
- StatusCode: 200,
- Body: r,
- }, nil
- }), suite.db)
-
+ tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
// now setup module being tested, with the mock transport controller
federator := federation.NewFederator(suite.db, testrig.NewTestFederatingDB(suite.db), tc, suite.config, suite.log, suite.typeConverter, testrig.NewTestMediaHandler(suite.db, suite.storage))
@@ -164,6 +122,8 @@ func (suite *ProtocolTestSuite) TestAuthenticatePostInbox() {
ctxWithAccount := context.WithValue(ctx, util.APAccount, inboxAccount)
ctxWithActivity := context.WithValue(ctxWithAccount, util.APActivity, activity)
+
+aaaaaaaaaaaaaaaaaaaaa
request := httptest.NewRequest(http.MethodPost, "http://localhost:8080/users/the_mighty_zork/inbox", nil) // the endpoint we're hitting
// we need these headers for the request to be validated
request.Header.Set("Signature", activity.SignatureHeader)
diff --git a/internal/typeutils/frontendtointernal.go b/internal/typeutils/frontendtointernal.go
index 6bb45d61b..75c5168aa 100644
--- a/internal/typeutils/frontendtointernal.go
+++ b/internal/typeutils/frontendtointernal.go
@@ -32,6 +32,8 @@ func (c *converter) MastoVisToVis(m model.Visibility) gtsmodel.Visibility {
return gtsmodel.VisibilityUnlocked
case model.VisibilityPrivate:
return gtsmodel.VisibilityFollowersOnly
+ case model.VisibilityMutualsOnly:
+ return gtsmodel.VisibilityMutualsOnly
case model.VisibilityDirect:
return gtsmodel.VisibilityDirect
}