diff options
author | 2025-01-23 17:18:23 +0000 | |
---|---|---|
committer | 2025-01-23 18:18:23 +0100 | |
commit | 9333bbc4d0d5ae46c72fca1f5b1aacb3c0a7653e (patch) | |
tree | e7ccd1dc3abff5386e0b86e6baf659c9aa3b55a5 /internal/typeutils/wrap_test.go | |
parent | [feature] Add warning about `trusted-proxies` to make config easier (#3675) (diff) | |
download | gotosocial-9333bbc4d0d5ae46c72fca1f5b1aacb3c0a7653e.tar.xz |
[feature] Serve bot accounts over AP as Service instead of Person (#3672)
* pepis
* oopsie doopsie
* bollocks
Diffstat (limited to 'internal/typeutils/wrap_test.go')
-rw-r--r-- | internal/typeutils/wrap_test.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/internal/typeutils/wrap_test.go b/internal/typeutils/wrap_test.go index 1085c8c66..8c8af7506 100644 --- a/internal/typeutils/wrap_test.go +++ b/internal/typeutils/wrap_test.go @@ -139,6 +139,86 @@ func (suite *WrapTestSuite) TestWrapNoteInCreate() { }`, string(bytes)) } +func (suite *WrapTestSuite) TestWrapAccountableInUpdate() { + testAccount := suite.testAccounts["local_account_1"] + + accountable, err := suite.typeconverter.AccountToAS(context.Background(), testAccount) + if err != nil { + suite.FailNow(err.Error()) + } + + create, err := suite.typeconverter.WrapAccountableInUpdate(accountable) + if err != nil { + suite.FailNow(err.Error()) + } + + createI, err := ap.Serialize(create) + if err != nil { + suite.FailNow(err.Error()) + } + + // Get the ID as it's not determinate. + createID := ap.GetJSONLDId(create) + + bytes, err := json.MarshalIndent(createI, "", " ") + if err != nil { + suite.FailNow(err.Error()) + } + + suite.Equal(`{ + "@context": [ + "https://w3id.org/security/v1", + "https://www.w3.org/ns/activitystreams", + { + "discoverable": "toot:discoverable", + "featured": { + "@id": "toot:featured", + "@type": "@id" + }, + "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", + "toot": "http://joinmastodon.org/ns#" + } + ], + "actor": "http://localhost:8080/users/the_mighty_zork", + "bcc": "http://localhost:8080/users/the_mighty_zork/followers", + "id": "`+createID.String()+`", + "object": { + "discoverable": true, + "featured": "http://localhost:8080/users/the_mighty_zork/collections/featured", + "followers": "http://localhost:8080/users/the_mighty_zork/followers", + "following": "http://localhost:8080/users/the_mighty_zork/following", + "icon": { + "mediaType": "image/jpeg", + "type": "Image", + "url": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg" + }, + "id": "http://localhost:8080/users/the_mighty_zork", + "image": { + "mediaType": "image/jpeg", + "type": "Image", + "url": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg" + }, + "inbox": "http://localhost:8080/users/the_mighty_zork/inbox", + "manuallyApprovesFollowers": false, + "name": "original zork (he/they)", + "outbox": "http://localhost:8080/users/the_mighty_zork/outbox", + "preferredUsername": "the_mighty_zork", + "publicKey": { + "id": "http://localhost:8080/users/the_mighty_zork/main-key", + "owner": "http://localhost:8080/users/the_mighty_zork", + "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwXTcOAvM1Jiw5Ffpk0qn\nr0cwbNvFe/5zQ+Tp7tumK/ZnT37o7X0FUEXrxNi+dkhmeJ0gsaiN+JQGNUewvpSk\nPIAXKvi908aSfCGjs7bGlJCJCuDuL5d6m7hZnP9rt9fJc70GElPpG0jc9fXwlz7T\nlsPb2ecatmG05Y4jPwdC+oN4MNCv9yQzEvCVMzl76EJaM602kIHC1CISn0rDFmYd\n9rSN7XPlNJw1F6PbpJ/BWQ+pXHKw3OEwNTETAUNYiVGnZU+B7a7bZC9f6/aPbJuV\nt8Qmg+UnDvW1Y8gmfHnxaWG2f5TDBvCHmcYtucIZPLQD4trAozC4ryqlmCWQNKbt\n0wIDAQAB\n-----END PUBLIC KEY-----\n" + }, + "published": "2022-05-20T11:09:18Z", + "summary": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e", + "tag": [], + "type": "Person", + "url": "http://localhost:8080/@the_mighty_zork" + }, + "to": "https://www.w3.org/ns/activitystreams#Public", + "type": "Update" +}`, string(bytes)) +} + func TestWrapTestSuite(t *testing.T) { suite.Run(t, new(WrapTestSuite)) } |