aboutsummaryrefslogtreecommitdiff
path: root/test/web/activity_pub
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-29 12:36:17 +0200
committerlain <lain@soykaf.club>2020-05-29 12:36:17 +0200
commitaf6d01ec93a07cd896bc4f0a2c2cf437c6fd51fc (patch)
tree54e02858d0fa9ca905ffe5a057c9f0accbeae115 /test/web/activity_pub
parentdbd07d29a358a446d87078d60b993a59b757ad1d (diff)
parent396bc69aeef951f163c0c20474ce4653df1dd667 (diff)
downloadpleroma-af6d01ec93a07cd896bc4f0a2c2cf437c6fd51fc.tar.gz
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
Diffstat (limited to 'test/web/activity_pub')
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs30
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs33
2 files changed, 49 insertions, 14 deletions
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index dd2a48a61..24edab41a 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -451,6 +451,36 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
assert Activity.get_by_ap_id(data["id"])
end
+ @tag capture_log: true
+ test "it inserts an incoming activity into the database" <>
+ "even if we can't fetch the user but have it in our db",
+ %{conn: conn} do
+ user =
+ insert(:user,
+ ap_id: "https://mastodon.example.org/users/raymoo",
+ ap_enabled: true,
+ local: false,
+ last_refreshed_at: nil
+ )
+
+ data =
+ File.read!("test/fixtures/mastodon-post-activity.json")
+ |> Poison.decode!()
+ |> Map.put("actor", user.ap_id)
+ |> put_in(["object", "attridbutedTo"], user.ap_id)
+
+ conn =
+ conn
+ |> assign(:valid_signature, true)
+ |> put_req_header("content-type", "application/activity+json")
+ |> post("/inbox", data)
+
+ assert "ok" == json_response(conn, 200)
+
+ ObanHelpers.perform(all_enqueued(worker: ReceiverWorker))
+ assert Activity.get_by_ap_id(data["id"])
+ end
+
test "it clears `unreachable` federation status of the sender", %{conn: conn} do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 356004d48..94d8552e8 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -1094,23 +1094,28 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
{:ok, activity} =
CommonAPI.post(user, %{status: "hey, @#{other_user.nickname}, how are ya? #2hu"})
- {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
- object = modified["object"]
+ with_mock Pleroma.Notification,
+ get_notified_from_activity: fn _, _ -> [] end do
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
- expected_mention = %{
- "href" => other_user.ap_id,
- "name" => "@#{other_user.nickname}",
- "type" => "Mention"
- }
+ object = modified["object"]
- expected_tag = %{
- "href" => Pleroma.Web.Endpoint.url() <> "/tags/2hu",
- "type" => "Hashtag",
- "name" => "#2hu"
- }
+ expected_mention = %{
+ "href" => other_user.ap_id,
+ "name" => "@#{other_user.nickname}",
+ "type" => "Mention"
+ }
- assert Enum.member?(object["tag"], expected_tag)
- assert Enum.member?(object["tag"], expected_mention)
+ expected_tag = %{
+ "href" => Pleroma.Web.Endpoint.url() <> "/tags/2hu",
+ "type" => "Hashtag",
+ "name" => "#2hu"
+ }
+
+ refute called(Pleroma.Notification.get_notified_from_activity(:_, :_))
+ assert Enum.member?(object["tag"], expected_tag)
+ assert Enum.member?(object["tag"], expected_mention)
+ end
end
test "it adds the sensitive property" do