X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fostatus%2Fostatus_test.exs;h=41e1c3448709ac45ec0fd4a5d2b9fdc8b0db8b13;hb=a41aa4e4898660fffb9a54070d16e2c3a5373d71;hp=e85d7677c3d9b1cb789a9775c86118746aad0adf;hpb=c48c381e909240dcece9f961e4728fa712d089cc;p=akkoma diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index e85d7677c..41e1c3448 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -2,7 +2,8 @@ defmodule Pleroma.Web.OStatusTest do use Pleroma.DataCase alias Pleroma.Web.OStatus alias Pleroma.Web.XML - alias Pleroma.{Object, Repo} + alias Pleroma.{Object, Repo, User} + import Pleroma.Factory test "don't insert create notes twice" do incoming = File.read!("test/fixtures/incoming_note_activity.xml") @@ -31,6 +32,8 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["type"] == "Note" assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211" 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"] end test "handle incoming notes with attachments - GS, subscription" do @@ -96,6 +99,36 @@ defmodule Pleroma.Web.OStatusTest do refute retweeted_activity.local end + test "handle incoming favorites - GS, websub" do + incoming = File.read!("test/fixtures/favorite.xml") + {:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Like" + assert activity.data["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"] == favorited_activity.data["object"]["id"] + refute activity.local + assert favorited_activity.data["type"] == "Create" + assert favorited_activity.data["actor"] == "https://shitposter.club/user/1" + assert favorited_activity.data["object"]["id"] == "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment" + refute favorited_activity.local + end + + test "handle incoming favorites with locally available object - GS, websub" do + note_activity = insert(:note_activity) + + incoming = File.read!("test/fixtures/favorite_with_local_note.xml") + |> String.replace("localid", note_activity.data["object"]["id"]) + + {:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Like" + assert activity.data["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"] == favorited_activity.data["object"]["id"] + refute activity.local + assert note_activity.id == favorited_activity.id + assert favorited_activity.local + end + test "handle incoming replies" do incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) @@ -107,8 +140,14 @@ defmodule Pleroma.Web.OStatusTest do end describe "new remote user creation" do + test "returns local users" do + local_user = insert(:user) + {:ok, user} = OStatus.find_or_make_user(local_user.ap_id) + + assert user == local_user + end + test "tries to use the information in poco fields" do - # TODO make test local uri = "https://social.heldscal.la/user/23211" {:ok, user} = OStatus.find_or_make_user(uri) @@ -127,7 +166,6 @@ defmodule Pleroma.Web.OStatusTest do end test "find_make_or_update_user takes an author element and returns an updated user" do - # TODO make test local uri = "https://social.heldscal.la/user/23211" {:ok, user} = OStatus.find_or_make_user(uri) @@ -191,4 +229,14 @@ defmodule Pleroma.Web.OStatusTest do assert data == expected end end + + 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) + + 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 + end end