Wrap offline tests into cassette

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-11-17 19:13:54 +01:00
parent 9e80549f17
commit c23b7ee81f
12 changed files with 764 additions and 153 deletions

View File

@ -11,15 +11,15 @@
"uuid": "sc:identifier" "uuid": "sc:identifier"
} }
], ],
"actor": "https://event1.tcit.fr/@tcit", "actor": "https://test.mobilizon.org/@Alicia",
"cc": [ "cc": [
"https://framapiaf.org/users/admin/followers", "https://framapiaf.org/users/admin/followers",
"https://framapiaf.org/users/tcit" "https://framapiaf.org/users/tcit"
], ],
"id": "https://event1.tcit.fr/@tcit/events/109ccdfd-ee3e-46e1-a877-6c228763df0c/activity", "id": "https://test.mobilizon.org/events/39026210-0c69-4238-b3cc-986f33f98ed0/activity",
"object": { "object": {
"attachment": [], "attachment": [],
"attributedTo": "https://event1.tcit.fr/@tcit", "attributedTo": "https://test.mobilizon.org/@Alicia",
"startTime": "2018-02-12T14:08:20Z", "startTime": "2018-02-12T14:08:20Z",
"cc": [ "cc": [
"https://framapiaf.org/users/admin/followers", "https://framapiaf.org/users/admin/followers",
@ -27,7 +27,7 @@
], ],
"content": "<p><span class=\"h-card\"><a href=\"https://framapiaf.org/users/tcit\" class=\"u-url mention\">@<span>tcit</span></a></span></p>", "content": "<p><span class=\"h-card\"><a href=\"https://framapiaf.org/users/tcit\" class=\"u-url mention\">@<span>tcit</span></a></span></p>",
"category": "TODO remove me", "category": "TODO remove me",
"id": "https://event1.tcit.fr/@tcit/events/109ccdfd-ee3e-46e1-a877-6c228763df0c", "id": "https://test.mobilizon.org/events/39026210-0c69-4238-b3cc-986f33f98ed0",
"inReplyTo": null, "inReplyTo": null,
"location": { "location": {
"type": "Place", "type": "Place",
@ -55,7 +55,7 @@
"https://www.w3.org/ns/activitystreams#Public" "https://www.w3.org/ns/activitystreams#Public"
], ],
"type": "Event", "type": "Event",
"url": "https://event1.tcit.fr/@tcit/events/109ccdfd-ee3e-46e1-a877-6c228763df0c", "url": "https://test.mobilizon.org/events/39026210-0c69-4238-b3cc-986f33f98ed0",
"uuid": "109ccdfd-ee3e-46e1-a877-6c228763df0c" "uuid": "109ccdfd-ee3e-46e1-a877-6c228763df0c"
}, },
"published": "2018-02-12T14:08:20Z", "published": "2018-02-12T14:08:20Z",

View File

@ -0,0 +1,36 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://test.mobilizon.org/@Alicia"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.github.io/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"endpoints\":{\"sharedInbox\":\"https://test.mobilizon.org/inbox\"},\"followers\":\"https://test.mobilizon.org/@Alicia/followers\",\"following\":\"https://test.mobilizon.org/@Alicia/following\",\"id\":\"https://test.mobilizon.org/@Alicia\",\"inbox\":\"https://test.mobilizon.org/@Alicia/inbox\",\"manuallyApprovesFollowers\":false,\"name\":\"Alicia\",\"outbox\":\"https://test.mobilizon.org/@Alicia/outbox\",\"preferredUsername\":\"Alicia\",\"publicKey\":{\"id\":\"https://test.mobilizon.org/@Alicia#main-key\",\"owner\":\"https://test.mobilizon.org/@Alicia\",\"publicKeyPem\":\"-----BEGIN RSA PUBLIC KEY-----\\nMIIBCgKCAQEAvb+emDoC6FCVpfo9Bh608sVsOK+8fun3UIqaR+jr+DZCAjp8ihwa\\nFkXaeOQ744MVS2YdzBEyIlk3sSYD9GezF+zoMbbA8FcnJ5jZhnneRR7ZrEg/cpNx\\nKFVA2ZoQrAABwpnA1iv7ciLoYZKPTDpIZ7Ue5l/k1bYcfTy0d4F3c8YAayWftSWj\\nHy3FK2kZDLdKfpRyfn5a4UI6sao4uD/rHno47g8tPPVA74BBpaTntJfbTWqiR8Vn\\nmNGAzy3+47pVeeg6Rd+AALohzBpHPW3TlJ75mqxPDXk7aDRYXihHrswf4MmKuaXc\\nXdoCu6uxQp41Xf3jVYD+AWw60tv2Oj/d4wIDAQAB\\n-----END RSA PUBLIC KEY-----\\n\\n\"},\"summary\":\"J'aime le karaté, les mangas, coder en python.\",\"type\":\"Person\",\"url\":\"https://test.mobilizon.org/@Alicia\"}",
"headers": {
"Server": "nginx/1.14.2",
"Date": "Sun, 17 Nov 2019 18:12:35 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Content-Length": "1293",
"Connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"access-control-expose-headers": "",
"cache-control": "max-age=0, private, must-revalidate",
"x-request-id": "FdgFt2eS9ln4-7YACVtC",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains",
"X-Content-Type-Options": "nosniff"
},
"status_code": 200,
"type": "ok"
}
}
]

View File

@ -0,0 +1,36 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://test.mobilizon.org/@Alicia"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.github.io/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"endpoints\":{\"sharedInbox\":\"https://test.mobilizon.org/inbox\"},\"followers\":\"https://test.mobilizon.org/@Alicia/followers\",\"following\":\"https://test.mobilizon.org/@Alicia/following\",\"id\":\"https://test.mobilizon.org/@Alicia\",\"inbox\":\"https://test.mobilizon.org/@Alicia/inbox\",\"manuallyApprovesFollowers\":false,\"name\":\"Alicia\",\"outbox\":\"https://test.mobilizon.org/@Alicia/outbox\",\"preferredUsername\":\"Alicia\",\"publicKey\":{\"id\":\"https://test.mobilizon.org/@Alicia#main-key\",\"owner\":\"https://test.mobilizon.org/@Alicia\",\"publicKeyPem\":\"-----BEGIN RSA PUBLIC KEY-----\\nMIIBCgKCAQEAvb+emDoC6FCVpfo9Bh608sVsOK+8fun3UIqaR+jr+DZCAjp8ihwa\\nFkXaeOQ744MVS2YdzBEyIlk3sSYD9GezF+zoMbbA8FcnJ5jZhnneRR7ZrEg/cpNx\\nKFVA2ZoQrAABwpnA1iv7ciLoYZKPTDpIZ7Ue5l/k1bYcfTy0d4F3c8YAayWftSWj\\nHy3FK2kZDLdKfpRyfn5a4UI6sao4uD/rHno47g8tPPVA74BBpaTntJfbTWqiR8Vn\\nmNGAzy3+47pVeeg6Rd+AALohzBpHPW3TlJ75mqxPDXk7aDRYXihHrswf4MmKuaXc\\nXdoCu6uxQp41Xf3jVYD+AWw60tv2Oj/d4wIDAQAB\\n-----END RSA PUBLIC KEY-----\\n\\n\"},\"summary\":\"J'aime le karaté, les mangas, coder en python.\",\"type\":\"Person\",\"url\":\"https://test.mobilizon.org/@Alicia\"}",
"headers": {
"Server": "nginx/1.14.2",
"Date": "Sun, 17 Nov 2019 18:00:51 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Content-Length": "1293",
"Connection": "keep-alive",
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"access-control-expose-headers": "",
"cache-control": "max-age=0, private, must-revalidate",
"x-request-id": "FdgFE5DoOmZXNz8ACVni",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains",
"X-Content-Type-Options": "nosniff"
},
"status_code": 200,
"type": "ok"
}
}
]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://framapiaf.org/users/Framasoft"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://w3id.org/security/v1\",{\"manuallyApprovesFollowers\":\"as:manuallyApprovesFollowers\",\"toot\":\"http://joinmastodon.org/ns#\",\"featured\":{\"@id\":\"toot:featured\",\"@type\":\"@id\"},\"alsoKnownAs\":{\"@id\":\"as:alsoKnownAs\",\"@type\":\"@id\"},\"movedTo\":{\"@id\":\"as:movedTo\",\"@type\":\"@id\"},\"schema\":\"http://schema.org#\",\"PropertyValue\":\"schema:PropertyValue\",\"value\":\"schema:value\",\"IdentityProof\":\"toot:IdentityProof\",\"discoverable\":\"toot:discoverable\",\"Hashtag\":\"as:Hashtag\",\"focalPoint\":{\"@container\":\"@list\",\"@id\":\"toot:focalPoint\"}}],\"id\":\"https://framapiaf.org/users/Framasoft\",\"type\":\"Person\",\"following\":\"https://framapiaf.org/users/Framasoft/following\",\"followers\":\"https://framapiaf.org/users/Framasoft/followers\",\"inbox\":\"https://framapiaf.org/users/Framasoft/inbox\",\"outbox\":\"https://framapiaf.org/users/Framasoft/outbox\",\"featured\":\"https://framapiaf.org/users/Framasoft/collections/featured\",\"preferredUsername\":\"Framasoft\",\"name\":\"Framasoft\",\"summary\":\"\\u003cp\\u003eLa route est longue mais la voie est libre…\\u003c/p\\u003e\\u003cp\\u003eBesoin d\\u0026apos;aide ? \\u003ca href=\\\"https://contact.framasoft.org\\\" rel=\\\"nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003econtact.framasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e /!\\\\ Pas de support sur Mastodon /!\\\\\\u003c/p\\u003e\\u003cp\\u003e\\u003ca href=\\\"https://framapiaf.org/tags/Framasoft\\\" class=\\\"mention hashtag\\\" rel=\\\"tag\\\"\\u003e#\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e \\u003ca href=\\\"https://framapiaf.org/tags/Libre\\\" class=\\\"mention hashtag\\\" rel=\\\"tag\\\"\\u003e#\\u003cspan\\u003eLibre\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/p\\u003e\",\"url\":\"https://framapiaf.org/@Framasoft\",\"manuallyApprovesFollowers\":false,\"discoverable\":true,\"publicKey\":{\"id\":\"https://framapiaf.org/users/Framasoft#main-key\",\"owner\":\"https://framapiaf.org/users/Framasoft\",\"publicKeyPem\":\"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0SgyiKbsNd0adHldDHiw\\nCotPzipq0QMrBgvmapnME8obZvrJWTF+imihNBH/DBemQqRb0ABilWvs0hluWCHl\\nouCi4SnlUljjpp2nmMTFUMPeF/GQByZS4ZPmnipgG+/uqkWL0U/206r//6agvw2s\\nmRcuVwo1xR4MZshxdtqXm/Wg9zavDSMLf/66VevieWvVy+5n0ZsqFAFuHrITgrgt\\n6wS8S3IT7de+7F28JeU/zmRFA3/3+IyWrpTx1CY4J+UM11mLbtpLWy3MCAMffchF\\nZh7TAiaJKAVMjT2Ubyr/1nNn9b4FORwOMIgWIGp5OAD1W/xVTW/rmqArAllgUMEW\\nvwIDAQAB\\n-----END PUBLIC KEY-----\\n\"},\"tag\":[{\"type\":\"Hashtag\",\"href\":\"https://framapiaf.org/explore/framasoft\",\"name\":\"#framasoft\"},{\"type\":\"Hashtag\",\"href\":\"https://framapiaf.org/explore/libre\",\"name\":\"#libre\"}],\"attachment\":[{\"type\":\"PropertyValue\",\"name\":\"Contact\",\"value\":\"\\u003ca href=\\\"https://contact.framasoft.org/\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003econtact.framasoft.org/\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Découvrir\",\"value\":\"\\u003ca href=\\\"https://framasoft.org\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003eframasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Soutenir\",\"value\":\"\\u003ca href=\\\"https://soutenir.framasoft.org\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003esoutenir.framasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"}],\"endpoints\":{\"sharedInbox\":\"https://framapiaf.org/inbox\"},\"icon\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://framapiaf.s3.framasoft.org/framapiaf/accounts/avatars/000/000/399/original/aa56a445efb72803.jpg\"},\"image\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://framapiaf.s3.framasoft.org/framapiaf/accounts/headers/000/000/399/original/94f271e4ef58fc79.jpg\"}}",
"headers": {
"Date": "Sun, 17 Nov 2019 18:09:47 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
"Server": "Mastodon",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=180, public",
"ETag": "W/\"244f2282ec9b1fac35b0381a673683da\"",
"Set-Cookie": "_mastodon_session=oLAzClz16WslSvWV2DqKE3h8nqfOVIFGE27%2BX5Ih6yqrChtwZCJVz3BghIcYTpBMOU467Or8nJZO2yPLkQPh--iCbklHRx4hwRBwGH--iLFXW%2B3UtBr28kV8Lfuk5A%3D%3D; path=/; secure; HttpOnly",
"X-Request-Id": "9ee29645-1f25-479e-8db5-bc90d7b31f4c",
"X-Runtime": "0.028450",
"X-Cached": "MISS",
"Strict-Transport-Security": "max-age=31536000"
},
"status_code": 200,
"type": "ok"
}
}
]

View File

@ -0,0 +1,42 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://social.tcit.fr/users/tcit"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://w3id.org/security/v1\",{\"manuallyApprovesFollowers\":\"as:manuallyApprovesFollowers\",\"toot\":\"http://joinmastodon.org/ns#\",\"featured\":{\"@id\":\"toot:featured\",\"@type\":\"@id\"},\"alsoKnownAs\":{\"@id\":\"as:alsoKnownAs\",\"@type\":\"@id\"},\"movedTo\":{\"@id\":\"as:movedTo\",\"@type\":\"@id\"},\"schema\":\"http://schema.org#\",\"PropertyValue\":\"schema:PropertyValue\",\"value\":\"schema:value\",\"IdentityProof\":\"toot:IdentityProof\",\"discoverable\":\"toot:discoverable\",\"focalPoint\":{\"@container\":\"@list\",\"@id\":\"toot:focalPoint\"}}],\"id\":\"https://social.tcit.fr/users/tcit\",\"type\":\"Person\",\"following\":\"https://social.tcit.fr/users/tcit/following\",\"followers\":\"https://social.tcit.fr/users/tcit/followers\",\"inbox\":\"https://social.tcit.fr/users/tcit/inbox\",\"outbox\":\"https://social.tcit.fr/users/tcit/outbox\",\"featured\":\"https://social.tcit.fr/users/tcit/collections/featured\",\"preferredUsername\":\"tcit\",\"name\":\"🦄 Thomas Citharel\",\"summary\":\"\\u003cp\\u003eHoping to make people\\u0026apos;s life better with free software at \\u003cspan class=\\\"h-card\\\"\\u003e\\u003ca href=\\\"https://framapiaf.org/@Framasoft\\\" class=\\\"u-url mention\\\"\\u003e@\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/span\\u003e.\\u003c/p\\u003e\",\"url\":\"https://social.tcit.fr/@tcit\",\"manuallyApprovesFollowers\":false,\"discoverable\":true,\"publicKey\":{\"id\":\"https://social.tcit.fr/users/tcit#main-key\",\"owner\":\"https://social.tcit.fr/users/tcit\",\"publicKeyPem\":\"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApXwYMUdFg3XUd+bGsh8C\\nyiMRGpRGAWuCdM5pDWx5uM4pW2pM3xbHbcI21j9h8BmlAiPg6hbZD73KGly2N8Rt\\n5iIS0I+l6i8kA1JCCdlAaDTRd41RKMggZDoQvjVZQtsyE1VzMeU2kbqqTFN6ew7H\\nvbd6O0NhixoKoZ5f3jwuBDZoT0p1TAcaMdmG8oqHD97isizkDnRn8cOBA6wtI+xb\\n5xP2zxZMsLpTDZLiKU8XcPKZCw4OfQfmDmKkHtrFb77jCAQj/s/FxjVnvxRwmfhN\\nnWy0D+LUV/g63nHh/b5zXIeV92QZLvDYbgbezmzUzv9UeA1s70GGbaDqCIy85gw9\\n+wIDAQAB\\n-----END PUBLIC KEY-----\\n\"},\"tag\":[],\"attachment\":[{\"type\":\"PropertyValue\",\"name\":\"Works at\",\"value\":\"\\u003cspan class=\\\"h-card\\\"\\u003e\\u003ca href=\\\"https://framapiaf.org/@Framasoft\\\" class=\\\"u-url mention\\\"\\u003e@\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/span\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Pronouns\",\"value\":\"He/Him\"},{\"type\":\"PropertyValue\",\"name\":\"Work Account\",\"value\":\"\\u003ca href=\\\"https://framapiaf.org/@tcit\\\" rel=\\\"me nofollow noopener noreferrer\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003eframapiaf.org/@tcit\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Site\",\"value\":\"\\u003ca href=\\\"https://tcit.fr\\\" rel=\\\"me nofollow noopener noreferrer\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003etcit.fr\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"}],\"endpoints\":{\"sharedInbox\":\"https://social.tcit.fr/inbox\"},\"icon\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://media.social.tcit.fr/mastodontcit/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg\"},\"image\":{\"type\":\"Image\",\"mediaType\":\"image/png\",\"url\":\"https://media.social.tcit.fr/mastodontcit/accounts/headers/000/000/001/original/a3f3ec4f1b6f9f50.png\"}}",
"headers": {
"Date": "Sun, 17 Nov 2019 18:07:29 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
"Server": "Mastodon",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "same-origin",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
"X-Clacks-Overhead": "GNU Natalie Nguyen",
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=180, public",
"ETag": "W/\"ff1350ff75d62d3c2cb61a0119576ed0\"",
"Set-Cookie": "_mastodon_session=MLASVoTuayZJ50UdWnqLnyKTC4kLydS00RuPn%2BhopTFttZ8Gn3sZc0Tdwmg%2FXBVVC%2F6Pcx7giDvzLa33%2FMGb--WcnqF6HZMoKXoJt%2F--nhk%2FU6I%2FQhqd4yJI8o3oiQ%3D%3D; path=/; secure; HttpOnly",
"X-Request-Id": "dee85282-f9d0-4c85-8d06-daa455eb2bfb",
"X-Runtime": "0.022962",
"X-Cached": "MISS"
},
"status_code": 200,
"type": "ok"
}
}
]

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://framapiaf.org/users/Framasoft"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://w3id.org/security/v1\",{\"manuallyApprovesFollowers\":\"as:manuallyApprovesFollowers\",\"toot\":\"http://joinmastodon.org/ns#\",\"featured\":{\"@id\":\"toot:featured\",\"@type\":\"@id\"},\"alsoKnownAs\":{\"@id\":\"as:alsoKnownAs\",\"@type\":\"@id\"},\"movedTo\":{\"@id\":\"as:movedTo\",\"@type\":\"@id\"},\"schema\":\"http://schema.org#\",\"PropertyValue\":\"schema:PropertyValue\",\"value\":\"schema:value\",\"IdentityProof\":\"toot:IdentityProof\",\"discoverable\":\"toot:discoverable\",\"Hashtag\":\"as:Hashtag\",\"focalPoint\":{\"@container\":\"@list\",\"@id\":\"toot:focalPoint\"}}],\"id\":\"https://framapiaf.org/users/Framasoft\",\"type\":\"Person\",\"following\":\"https://framapiaf.org/users/Framasoft/following\",\"followers\":\"https://framapiaf.org/users/Framasoft/followers\",\"inbox\":\"https://framapiaf.org/users/Framasoft/inbox\",\"outbox\":\"https://framapiaf.org/users/Framasoft/outbox\",\"featured\":\"https://framapiaf.org/users/Framasoft/collections/featured\",\"preferredUsername\":\"Framasoft\",\"name\":\"Framasoft\",\"summary\":\"\\u003cp\\u003eLa route est longue mais la voie est libre…\\u003c/p\\u003e\\u003cp\\u003eBesoin d\\u0026apos;aide ? \\u003ca href=\\\"https://contact.framasoft.org\\\" rel=\\\"nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003econtact.framasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e /!\\\\ Pas de support sur Mastodon /!\\\\\\u003c/p\\u003e\\u003cp\\u003e\\u003ca href=\\\"https://framapiaf.org/tags/Framasoft\\\" class=\\\"mention hashtag\\\" rel=\\\"tag\\\"\\u003e#\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e \\u003ca href=\\\"https://framapiaf.org/tags/Libre\\\" class=\\\"mention hashtag\\\" rel=\\\"tag\\\"\\u003e#\\u003cspan\\u003eLibre\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/p\\u003e\",\"url\":\"https://framapiaf.org/@Framasoft\",\"manuallyApprovesFollowers\":false,\"discoverable\":true,\"publicKey\":{\"id\":\"https://framapiaf.org/users/Framasoft#main-key\",\"owner\":\"https://framapiaf.org/users/Framasoft\",\"publicKeyPem\":\"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0SgyiKbsNd0adHldDHiw\\nCotPzipq0QMrBgvmapnME8obZvrJWTF+imihNBH/DBemQqRb0ABilWvs0hluWCHl\\nouCi4SnlUljjpp2nmMTFUMPeF/GQByZS4ZPmnipgG+/uqkWL0U/206r//6agvw2s\\nmRcuVwo1xR4MZshxdtqXm/Wg9zavDSMLf/66VevieWvVy+5n0ZsqFAFuHrITgrgt\\n6wS8S3IT7de+7F28JeU/zmRFA3/3+IyWrpTx1CY4J+UM11mLbtpLWy3MCAMffchF\\nZh7TAiaJKAVMjT2Ubyr/1nNn9b4FORwOMIgWIGp5OAD1W/xVTW/rmqArAllgUMEW\\nvwIDAQAB\\n-----END PUBLIC KEY-----\\n\"},\"tag\":[{\"type\":\"Hashtag\",\"href\":\"https://framapiaf.org/explore/framasoft\",\"name\":\"#framasoft\"},{\"type\":\"Hashtag\",\"href\":\"https://framapiaf.org/explore/libre\",\"name\":\"#libre\"}],\"attachment\":[{\"type\":\"PropertyValue\",\"name\":\"Contact\",\"value\":\"\\u003ca href=\\\"https://contact.framasoft.org/\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003econtact.framasoft.org/\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Découvrir\",\"value\":\"\\u003ca href=\\\"https://framasoft.org\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003eframasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Soutenir\",\"value\":\"\\u003ca href=\\\"https://soutenir.framasoft.org\\\" rel=\\\"me nofollow noopener\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003esoutenir.framasoft.org\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"}],\"endpoints\":{\"sharedInbox\":\"https://framapiaf.org/inbox\"},\"icon\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://framapiaf.s3.framasoft.org/framapiaf/accounts/avatars/000/000/399/original/aa56a445efb72803.jpg\"},\"image\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://framapiaf.s3.framasoft.org/framapiaf/accounts/headers/000/000/399/original/94f271e4ef58fc79.jpg\"}}",
"headers": {
"Date": "Sun, 17 Nov 2019 18:09:19 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
"Server": "Mastodon",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=180, public",
"ETag": "W/\"244f2282ec9b1fac35b0381a673683da\"",
"Set-Cookie": "_mastodon_session=qFu4eHpJm1RgLVk6TyzbLxfQXMGZFqkybY4uqQNKUSUWboKh0edWetZQgoSPIXzAwTTFICfkkEPIhpQ4HnJU--NF09knzR8oukiQAs--2ax%2FdfLh6pkUpm6WDtngbw%3D%3D; path=/; secure; HttpOnly",
"X-Request-Id": "b121b7a6-423e-4378-97e0-e88a9a51928e",
"X-Runtime": "0.006326",
"X-Cached": "MISS",
"Strict-Transport-Security": "max-age=31536000"
},
"status_code": 200,
"type": "ok"
}
}
]

View File

@ -0,0 +1,42 @@
[
{
"request": {
"body": "",
"headers": {
"Accept": "application/activity+json"
},
"method": "get",
"options": {
"follow_redirect": "true"
},
"request_body": "",
"url": "https://social.tcit.fr/users/tcit"
},
"response": {
"binary": false,
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://w3id.org/security/v1\",{\"manuallyApprovesFollowers\":\"as:manuallyApprovesFollowers\",\"toot\":\"http://joinmastodon.org/ns#\",\"featured\":{\"@id\":\"toot:featured\",\"@type\":\"@id\"},\"alsoKnownAs\":{\"@id\":\"as:alsoKnownAs\",\"@type\":\"@id\"},\"movedTo\":{\"@id\":\"as:movedTo\",\"@type\":\"@id\"},\"schema\":\"http://schema.org#\",\"PropertyValue\":\"schema:PropertyValue\",\"value\":\"schema:value\",\"IdentityProof\":\"toot:IdentityProof\",\"discoverable\":\"toot:discoverable\",\"focalPoint\":{\"@container\":\"@list\",\"@id\":\"toot:focalPoint\"}}],\"id\":\"https://social.tcit.fr/users/tcit\",\"type\":\"Person\",\"following\":\"https://social.tcit.fr/users/tcit/following\",\"followers\":\"https://social.tcit.fr/users/tcit/followers\",\"inbox\":\"https://social.tcit.fr/users/tcit/inbox\",\"outbox\":\"https://social.tcit.fr/users/tcit/outbox\",\"featured\":\"https://social.tcit.fr/users/tcit/collections/featured\",\"preferredUsername\":\"tcit\",\"name\":\"🦄 Thomas Citharel\",\"summary\":\"\\u003cp\\u003eHoping to make people\\u0026apos;s life better with free software at \\u003cspan class=\\\"h-card\\\"\\u003e\\u003ca href=\\\"https://framapiaf.org/@Framasoft\\\" class=\\\"u-url mention\\\"\\u003e@\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/span\\u003e.\\u003c/p\\u003e\",\"url\":\"https://social.tcit.fr/@tcit\",\"manuallyApprovesFollowers\":false,\"discoverable\":true,\"publicKey\":{\"id\":\"https://social.tcit.fr/users/tcit#main-key\",\"owner\":\"https://social.tcit.fr/users/tcit\",\"publicKeyPem\":\"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApXwYMUdFg3XUd+bGsh8C\\nyiMRGpRGAWuCdM5pDWx5uM4pW2pM3xbHbcI21j9h8BmlAiPg6hbZD73KGly2N8Rt\\n5iIS0I+l6i8kA1JCCdlAaDTRd41RKMggZDoQvjVZQtsyE1VzMeU2kbqqTFN6ew7H\\nvbd6O0NhixoKoZ5f3jwuBDZoT0p1TAcaMdmG8oqHD97isizkDnRn8cOBA6wtI+xb\\n5xP2zxZMsLpTDZLiKU8XcPKZCw4OfQfmDmKkHtrFb77jCAQj/s/FxjVnvxRwmfhN\\nnWy0D+LUV/g63nHh/b5zXIeV92QZLvDYbgbezmzUzv9UeA1s70GGbaDqCIy85gw9\\n+wIDAQAB\\n-----END PUBLIC KEY-----\\n\"},\"tag\":[],\"attachment\":[{\"type\":\"PropertyValue\",\"name\":\"Works at\",\"value\":\"\\u003cspan class=\\\"h-card\\\"\\u003e\\u003ca href=\\\"https://framapiaf.org/@Framasoft\\\" class=\\\"u-url mention\\\"\\u003e@\\u003cspan\\u003eFramasoft\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/span\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Pronouns\",\"value\":\"He/Him\"},{\"type\":\"PropertyValue\",\"name\":\"Work Account\",\"value\":\"\\u003ca href=\\\"https://framapiaf.org/@tcit\\\" rel=\\\"me nofollow noopener noreferrer\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003eframapiaf.org/@tcit\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"},{\"type\":\"PropertyValue\",\"name\":\"Site\",\"value\":\"\\u003ca href=\\\"https://tcit.fr\\\" rel=\\\"me nofollow noopener noreferrer\\\" target=\\\"_blank\\\"\\u003e\\u003cspan class=\\\"invisible\\\"\\u003ehttps://\\u003c/span\\u003e\\u003cspan class=\\\"\\\"\\u003etcit.fr\\u003c/span\\u003e\\u003cspan class=\\\"invisible\\\"\\u003e\\u003c/span\\u003e\\u003c/a\\u003e\"}],\"endpoints\":{\"sharedInbox\":\"https://social.tcit.fr/inbox\"},\"icon\":{\"type\":\"Image\",\"mediaType\":\"image/jpeg\",\"url\":\"https://media.social.tcit.fr/mastodontcit/accounts/avatars/000/000/001/original/a28c50ce5f2b13fd.jpg\"},\"image\":{\"type\":\"Image\",\"mediaType\":\"image/png\",\"url\":\"https://media.social.tcit.fr/mastodontcit/accounts/headers/000/000/001/original/a3f3ec4f1b6f9f50.png\"}}",
"headers": {
"Date": "Sun, 17 Nov 2019 18:12:31 GMT",
"Content-Type": "application/activity+json; charset=utf-8",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
"Server": "Mastodon",
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Referrer-Policy": "same-origin",
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
"X-Clacks-Overhead": "GNU Natalie Nguyen",
"Vary": "Accept, Accept-Encoding, Origin",
"Cache-Control": "max-age=180, public",
"ETag": "W/\"ff1350ff75d62d3c2cb61a0119576ed0\"",
"Set-Cookie": "_mastodon_session=9eVpoF4UR66ZVzSZin58%2BNuKKLcWiF2icEY1gXXHm1nBjtugdp9H09CrYrAmpvni3ihTxnuUYTF%2BZxmdt%2FC4--ADVuJ0WvPj243aYT--rRarAcYF9GVTGqnDe7HBvg%3D%3D; path=/; secure; HttpOnly",
"X-Request-Id": "16571166-5e85-4699-9c26-367f9035ea89",
"X-Runtime": "0.020868",
"X-Cached": "MISS"
},
"status_code": 200,
"type": "ok"
}
}
]

File diff suppressed because one or more lines are too long

View File

@ -26,45 +26,47 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
describe "handle incoming events" do describe "handle incoming events" do
test "it works for incoming events" do test "it works for incoming events" do
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!() use_cassette "activity_pub/fetch_mobilizon_post_activity" do
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, %Event{} = event} = {:ok, %Activity{data: data, local: false}, %Event{} = event} =
Transmogrifier.handle_incoming(data) Transmogrifier.handle_incoming(data)
assert data["id"] == assert data["id"] ==
"https://event1.tcit.fr/@tcit/events/109ccdfd-ee3e-46e1-a877-6c228763df0c/activity" "https://test.mobilizon.org/events/39026210-0c69-4238-b3cc-986f33f98ed0/activity"
assert data["to"] == ["https://www.w3.org/ns/activitystreams#Public"] assert data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
# #
# assert data["cc"] == [ # assert data["cc"] == [
# "https://framapiaf.org/users/admin/followers", # "https://framapiaf.org/users/admin/followers",
# "http://localtesting.pleroma.lol/users/lain" # "http://localtesting.pleroma.lol/users/lain"
# ] # ]
assert data["actor"] == "https://event1.tcit.fr/@tcit" assert data["actor"] == "https://test.mobilizon.org/@Alicia"
object = data["object"] object = data["object"]
assert object["id"] == assert object["id"] ==
"https://event1.tcit.fr/@tcit/events/109ccdfd-ee3e-46e1-a877-6c228763df0c" "https://test.mobilizon.org/events/39026210-0c69-4238-b3cc-986f33f98ed0"
assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"] assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
# assert object["cc"] == [ # assert object["cc"] == [
# "https://framapiaf.org/users/admin/followers", # "https://framapiaf.org/users/admin/followers",
# "http://localtesting.pleroma.lol/users/lain" # "http://localtesting.pleroma.lol/users/lain"
# ] # ]
assert object["actor"] == "https://event1.tcit.fr/@tcit" assert object["actor"] == "https://test.mobilizon.org/@Alicia"
assert object["location"]["name"] == "Locaux de Framasoft" assert object["location"]["name"] == "Locaux de Framasoft"
assert object["attributedTo"] == "https://event1.tcit.fr/@tcit" assert object["attributedTo"] == "https://test.mobilizon.org/@Alicia"
assert event.physical_address.street == "10 Rue Jangot" assert event.physical_address.street == "10 Rue Jangot"
assert event.physical_address.url == assert event.physical_address.url ==
"https://event1.tcit.fr/address/eeecc11d-0030-43e8-a897-6422876372jd" "https://event1.tcit.fr/address/eeecc11d-0030-43e8-a897-6422876372jd"
{:ok, %Actor{}} = Actors.get_actor_by_url(object["actor"]) {:ok, %Actor{}} = Actors.get_actor_by_url(object["actor"])
end
end end
end end
@ -116,43 +118,48 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
# end # end
test "it works for incoming notices" do test "it works for incoming notices" do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!() use_cassette "activity_pub/mastodon_post_activity" do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["id"] == "https://framapiaf.org/users/admin/statuses/99512778738411822/activity" assert data["id"] ==
"https://framapiaf.org/users/admin/statuses/99512778738411822/activity"
assert data["to"] == ["https://www.w3.org/ns/activitystreams#Public"] assert data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
# assert data["cc"] == [ # assert data["cc"] == [
# "https://framapiaf.org/users/admin/followers", # "https://framapiaf.org/users/admin/followers",
# "http://mobilizon.com/@tcit" # "http://mobilizon.com/@tcit"
# ] # ]
assert data["actor"] == "https://framapiaf.org/users/admin" assert data["actor"] == "https://framapiaf.org/users/admin"
object = data["object"] object = data["object"]
assert object["id"] == "https://framapiaf.org/users/admin/statuses/99512778738411822" assert object["id"] == "https://framapiaf.org/users/admin/statuses/99512778738411822"
assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"] assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
# assert object["cc"] == [ # assert object["cc"] == [
# "https://framapiaf.org/users/admin/followers", # "https://framapiaf.org/users/admin/followers",
# "http://localtesting.pleroma.lol/users/lain" # "http://localtesting.pleroma.lol/users/lain"
# ] # ]
assert object["actor"] == "https://framapiaf.org/users/admin" assert object["actor"] == "https://framapiaf.org/users/admin"
assert object["attributedTo"] == "https://framapiaf.org/users/admin" assert object["attributedTo"] == "https://framapiaf.org/users/admin"
{:ok, %Actor{}} = Actors.get_actor_by_url(object["actor"]) {:ok, %Actor{}} = Actors.get_actor_by_url(object["actor"])
end
end end
test "it works for incoming notices with hashtags" do test "it works for incoming notices with hashtags" do
data = File.read!("test/fixtures/mastodon-post-activity-hashtag.json") |> Jason.decode!() use_cassette "activity_pub/mastodon_activity_hashtag" do
data = File.read!("test/fixtures/mastodon-post-activity-hashtag.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert Enum.at(data["object"]["tag"], 0)["name"] == "@tcit@framapiaf.org" assert Enum.at(data["object"]["tag"], 0)["name"] == "@tcit@framapiaf.org"
assert Enum.at(data["object"]["tag"], 1)["name"] == "#moo" assert Enum.at(data["object"]["tag"], 1)["name"] == "#moo"
end
end end
# test "it works for incoming notices with contentMap" do # test "it works for incoming notices with contentMap" do
@ -209,21 +216,23 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
end end
test "it works for incoming follow requests" do test "it works for incoming follow requests" do
actor = insert(:actor) use_cassette "activity_pub/mastodon_follow_activity" do
actor = insert(:actor)
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", actor.url) |> Map.put("object", actor.url)
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["actor"] == "https://social.tcit.fr/users/tcit" assert data["actor"] == "https://social.tcit.fr/users/tcit"
assert data["type"] == "Follow" assert data["type"] == "Follow"
assert data["id"] == "https://social.tcit.fr/users/tcit#follows/2" assert data["id"] == "https://social.tcit.fr/users/tcit#follows/2"
actor = Actors.get_actor_with_preload(actor.id) actor = Actors.get_actor_with_preload(actor.id)
assert Actors.is_following(Actors.get_actor_by_url!(data["actor"], true), actor) assert Actors.is_following(Actors.get_actor_by_url!(data["actor"], true), actor)
end
end end
# test "it works for incoming follow requests from hubzilla" do # test "it works for incoming follow requests from hubzilla" do
@ -295,89 +304,99 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
# end # end
test "it works for incoming announces" do test "it works for incoming announces" do
data = File.read!("test/fixtures/mastodon-announce.json") |> Jason.decode!() use_cassette "activity_pub/mastodon_announce_activity" do
data = File.read!("test/fixtures/mastodon-announce.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["actor"] == "https://framapiaf.org/users/Framasoft" assert data["actor"] == "https://framapiaf.org/users/Framasoft"
assert data["type"] == "Announce" assert data["type"] == "Announce"
assert data["id"] == assert data["id"] ==
"https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity" "https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity"
assert data["object"] == assert data["object"] ==
"https://framapiaf.org/users/Framasoft/statuses/102501959686438400" "https://framapiaf.org/users/Framasoft/statuses/102501959686438400"
assert %Comment{} = Events.get_comment_from_url(data["object"]) assert %Comment{} = Events.get_comment_from_url(data["object"])
end
end end
test "it works for incoming announces with an existing activity" do test "it works for incoming announces with an existing activity" do
comment = insert(:comment) use_cassette "activity_pub/mastodon_announce_existing_activity" do
comment = insert(:comment)
data = data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", comment.url) |> Map.put("object", comment.url)
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["actor"] == "https://framapiaf.org/users/Framasoft" assert data["actor"] == "https://framapiaf.org/users/Framasoft"
assert data["type"] == "Announce" assert data["type"] == "Announce"
assert data["id"] == assert data["id"] ==
"https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity" "https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity"
assert data["object"] == comment.url assert data["object"] == comment.url
end
end end
test "it works for incoming update activities on actors" do test "it works for incoming update activities on actors" do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!() use_cassette "activity_pub/update_actor_activity" do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!() update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object = object =
update_data["object"] update_data["object"]
|> Map.put("actor", data["actor"]) |> Map.put("actor", data["actor"])
|> Map.put("id", data["actor"]) |> Map.put("id", data["actor"])
update_data = update_data =
update_data update_data
|> Map.put("actor", data["actor"]) |> Map.put("actor", data["actor"])
|> Map.put("object", object) |> Map.put("object", object)
{:ok, %Activity{data: _data, local: false}, _} = Transmogrifier.handle_incoming(update_data) {:ok, %Activity{data: _data, local: false}, _} =
Transmogrifier.handle_incoming(update_data)
{:ok, %Actor{} = actor} = Actors.get_actor_by_url(update_data["actor"]) {:ok, %Actor{} = actor} = Actors.get_actor_by_url(update_data["actor"])
assert actor.name == "nextsoft" assert actor.name == "nextsoft"
assert actor.summary == "<p>Some bio</p>" assert actor.summary == "<p>Some bio</p>"
end
end end
test "it works for incoming update activities on events" do test "it works for incoming update activities on events" do
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!() use_cassette "activity_pub/event_update_activities" do
data = File.read!("test/fixtures/mobilizon-post-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!() update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object = object =
data["object"] data["object"]
|> Map.put("actor", data["actor"]) |> Map.put("actor", data["actor"])
|> Map.put("name", "My updated event") |> Map.put("name", "My updated event")
|> Map.put("id", data["object"]["id"]) |> Map.put("id", data["object"]["id"])
|> Map.put("type", "Event") |> Map.put("type", "Event")
update_data = update_data =
update_data update_data
|> Map.put("actor", data["actor"]) |> Map.put("actor", data["actor"])
|> Map.put("object", object) |> Map.put("object", object)
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(update_data) {:ok, %Activity{data: data, local: false}, _} =
Transmogrifier.handle_incoming(update_data)
%Event{} = event = Events.get_event_by_url(data["object"]["id"]) %Event{} = event = Events.get_event_by_url(data["object"]["id"])
assert event.title == "My updated event" assert event.title == "My updated event"
assert event.description == data["object"]["content"] assert event.description == data["object"]["content"]
end
end end
# test "it works for incoming update activities which lock the account" do # test "it works for incoming update activities which lock the account" do
@ -449,56 +468,60 @@ defmodule Mobilizon.Service.ActivityPub.TransmogrifierTest do
# end # end
test "it works for incoming unannounces with an existing notice" do test "it works for incoming unannounces with an existing notice" do
comment = insert(:comment) use_cassette "activity_pub/mastodon_unannounce_activity" do
comment = insert(:comment)
announce_data = announce_data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", comment.url) |> Map.put("object", comment.url)
{:ok, %Activity{data: announce_data, local: false}, _} = {:ok, %Activity{data: announce_data, local: false}, _} =
Transmogrifier.handle_incoming(announce_data) Transmogrifier.handle_incoming(announce_data)
data = data =
File.read!("test/fixtures/mastodon-undo-announce.json") File.read!("test/fixtures/mastodon-undo-announce.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", announce_data) |> Map.put("object", announce_data)
|> Map.put("actor", announce_data["actor"]) |> Map.put("actor", announce_data["actor"])
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["type"] == "Undo" assert data["type"] == "Undo"
assert data["object"]["type"] == "Announce" assert data["object"]["type"] == "Announce"
assert data["object"]["object"] == comment.url assert data["object"]["object"] == comment.url
assert data["object"]["id"] == assert data["object"]["id"] ==
"https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity" "https://framapiaf.org/users/Framasoft/statuses/102501959686438400/activity"
end
end end
test "it works for incomming unfollows with an existing follow" do test "it works for incomming unfollows with an existing follow" do
actor = insert(:actor) use_cassette "activity_pub/unfollow_existing_follow_activity" do
actor = insert(:actor)
follow_data = follow_data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", actor.url) |> Map.put("object", actor.url)
{:ok, %Activity{data: _, local: false}, _} = Transmogrifier.handle_incoming(follow_data) {:ok, %Activity{data: _, local: false}, _} = Transmogrifier.handle_incoming(follow_data)
data = data =
File.read!("test/fixtures/mastodon-unfollow-activity.json") File.read!("test/fixtures/mastodon-unfollow-activity.json")
|> Jason.decode!() |> Jason.decode!()
|> Map.put("object", follow_data) |> Map.put("object", follow_data)
{:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}, _} = Transmogrifier.handle_incoming(data)
assert data["type"] == "Undo" assert data["type"] == "Undo"
assert data["object"]["type"] == "Follow" assert data["object"]["type"] == "Follow"
assert data["object"]["object"] == actor.url assert data["object"]["object"] == actor.url
assert data["actor"] == "https://social.tcit.fr/users/tcit" assert data["actor"] == "https://social.tcit.fr/users/tcit"
{:ok, followed} = Actors.get_actor_by_url(data["actor"]) {:ok, followed} = Actors.get_actor_by_url(data["actor"])
refute Actors.is_following(followed, actor) refute Actors.is_following(followed, actor)
end
end end
# test "it works for incoming blocks" do # test "it works for incoming blocks" do