From c5f26f3ce2ef84a424a59498cc2d5e4ca9e1b525 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 1 Nov 2018 11:27:22 +0100 Subject: [PATCH] Test that prismo url-map transforms into a string --- test/fixtures/prismo-url-map.json | 52 +++++++++++++++++++ test/web/activity_pub/transmogrifier_test.exs | 8 +++ 2 files changed, 60 insertions(+) create mode 100644 test/fixtures/prismo-url-map.json diff --git a/test/fixtures/prismo-url-map.json b/test/fixtures/prismo-url-map.json new file mode 100644 index 000000000..9088d01af --- /dev/null +++ b/test/fixtures/prismo-url-map.json @@ -0,0 +1,52 @@ +{ + "id": "https://prismo.news/posts/83", + "type": "Article", + "name": "Introducing: Federated follows!", + "published": "2018-11-01T07:10:05Z", + "content": "We are more than thrilled to announce that Prismo now supports federated follows! It means you ca...", + "url": { + "type": "Link", + "mimeType": "text/html", + "href": "https://prismo.news/posts/83" + }, + "votes": 12, + "attributedTo": [ + { + "type": "Person", + "id": "https://prismo.news/@mxb" + } + ], + "to": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "tags": [ + { + "type": "Hashtag", + "href": "https://prismo.news/tags/prismo", + "name": "#prismo" + }, + { + "type": "Hashtag", + "href": "https://prismo.news/tags/prismodev", + "name": "#prismodev" + }, + { + "type": "Hashtag", + "href": "https://prismo.news/tags/meta", + "name": "#meta" + } + ], + "@context": [ + "https://www.w3.org/ns/activitystreams", + "https://w3id.org/security/v1", + { + "Hashtag": "as:Hashtag" + }, + { + "votes": { + "@id": "as:votes", + "@type": "@id" + } + } + ] +} diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6a6f2a44c..14b02eb71 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -145,6 +145,14 @@ test "it works for incoming notices with tag not being an array (kroeg)" do assert "test" in data["object"]["tag"] end + test "it works for incoming notices with url not being a string (prismo)" do + data = File.read!("test/fixtures/prismo-url-map.json") |> Poison.decode!() + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["object"]["url"] == "https://prismo.news/posts/83" + end + test "it works for incoming follow requests" do user = insert(:user)