X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Factivity_pub_test.exs;h=e95e4490aa57da984517bcf744a1f8d2ef3d5e1e;hb=bd040fe96afaf39c1433cd3695bed0ee2c0f55ed;hp=fc452ef1a69776d6738861fab8c38114b0afbd2c;hpb=4a94c9a31ef11f63ea71ad9c1f085c18cf8ef083;p=akkoma diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index fc452ef1a..e95e4490a 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -723,17 +723,26 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do test "it should return public activities that reference a given hashtag" do hashtag = insert(:hashtag, name: "tenshi") user = insert(:user) + other_user = insert(:user) + + {:ok, normally_visible} = + CommonAPI.post(other_user, %{status: "hello :)", visibility: "public"}) {:ok, public} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "public"}) {:ok, _unrelated} = CommonAPI.post(user, %{status: "dai #tensh", visibility: "public"}) {:ok, unlisted} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "unlisted"}) {:ok, _private} = CommonAPI.post(user, %{status: "maji #tenshi", visibility: "private"}) - activities = ActivityPub.fetch_activities([], %{followed_hashtags: [hashtag.id]}) - assert length(activities) == 2 + activities = + ActivityPub.fetch_activities([other_user.follower_address], %{ + followed_hashtags: [hashtag.id] + }) + + assert length(activities) == 3 + normal_id = normally_visible.id public_id = public.id unlisted_id = unlisted.id - assert [%{id: ^public_id}, %{id: ^unlisted_id}] = activities + assert [%{id: ^normal_id}, %{id: ^public_id}, %{id: ^unlisted_id}] = activities end end @@ -1294,6 +1303,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do %{test_file: test_file} end + test "strips / from filename", %{test_file: file} do + file = %Plug.Upload{file | filename: "../../../../../nested/bad.jpg"} + {:ok, %Object{} = object} = ActivityPub.upload(file) + [%{"href" => href}] = object.data["url"] + assert Regex.match?(~r"/bad.jpg$", href) + refute Regex.match?(~r"/nested/", href) + end + test "sets a description if given", %{test_file: file} do {:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file") assert object.data["name"] == "a cool file"