X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fostatus%2Fostatus_test.exs;h=ee2b79ffa6d8566783689fbf49255a7007fe4f81;hb=540dfb4617aaab400d0aeafa47d41544c00a2b83;hp=2d11b4664a1b78abea5e7f417a5634a63d97be3d;hpb=429992fcc921a15f853d08b975682499d83dea99;p=akkoma diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 2d11b4664..ee2b79ffa 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -15,6 +15,8 @@ defmodule Pleroma.Web.OStatusTest do incoming = File.read!("test/fixtures/incoming_note_activity.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) + user = User.get_by_ap_id(activity.data["actor"]) + assert user.info["note_count"] == 1 assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note" @@ -35,6 +37,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["content"] == "Will it blend?" user = User.get_cached_by_ap_id(activity.data["actor"]) assert User.ap_followers(user) in activity.data["to"] + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming notes with attachments - GS, subscription" do @@ -46,6 +49,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" assert activity.data["object"]["attachment"] |> length == 2 assert activity.data["object"]["external_url"] == "https://social.heldscal.la/notice/2020923" + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming notes with tags" do @@ -53,6 +57,7 @@ defmodule Pleroma.Web.OStatusTest do {:ok, [activity]} = OStatus.handle_incoming(incoming) assert activity.data["object"]["tag"] == ["nsfw"] + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming notes - Mastodon, salmon, reply" do @@ -69,6 +74,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["type"] == "Note" assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda" assert activity.data["context"] == "2hu" + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming notes - Mastodon, with CW" do @@ -79,6 +85,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["type"] == "Note" assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda" assert String.contains?(activity.data["object"]["content"], "technologic") + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming retweets - Mastodon, with CW" do @@ -97,6 +104,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" assert activity.data["object"]["content"] == "@shpbot why not indeed." assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note" + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming retweets - GS, subscription" do @@ -174,6 +182,13 @@ defmodule Pleroma.Web.OStatusTest do refute favorited_activity.local end + test "handle conversation references" do + incoming = File.read!("test/fixtures/mastodon_conversation.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["context"] == "tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation" + end + test "handle incoming favorites with locally available object - GS, websub" do note_activity = insert(:note_activity) @@ -199,6 +214,7 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc" assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"] assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note" + assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"] end test "handle incoming follows" do @@ -317,11 +333,18 @@ defmodule Pleroma.Web.OStatusTest do describe "fetching a status by it's HTML url" do test "it builds a missing status from an html url" do url = "https://shitposter.club/notice/2827873" - {:ok, [activity] } = OStatus.fetch_activity_from_html_url(url) + {:ok, [activity] } = OStatus.fetch_activity_from_url(url) assert activity.data["actor"] == "https://shitposter.club/user/1" assert activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment" end + + test "it works for atom notes, too" do + url = "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056" + {:ok, [activity] } = OStatus.fetch_activity_from_url(url) + assert activity.data["actor"] == "https://social.sakamoto.gq/users/eal" + assert activity.data["object"]["id"] == url + end end test "insert or update a user from given data" do @@ -330,4 +353,11 @@ defmodule Pleroma.Web.OStatusTest do assert {:ok, %User{}} = OStatus.insert_or_update_user(data) end + + test "it doesn't add nil in the do field" do + incoming = File.read!("test/fixtures/nil_mention_entry.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["to"] == ["http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers", "https://www.w3.org/ns/activitystreams#Public"] + end end