From 634e3d4155df4c327d608a112fd4a3caf44cf9b8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 23 Jun 2024 20:56:58 -0400 Subject: Add test validating the activity_id is correctly present in the Oban job This was preventing the activity from being streamed over websockets. --- test/pleroma/web/rich_media/card_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/pleroma/web/rich_media/card_test.exs b/test/pleroma/web/rich_media/card_test.exs index c76df99e2..33d07127f 100644 --- a/test/pleroma/web/rich_media/card_test.exs +++ b/test/pleroma/web/rich_media/card_test.exs @@ -3,12 +3,14 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.RichMedia.CardTest do + use Oban.Testing, repo: Pleroma.Repo use Pleroma.DataCase, async: true alias Pleroma.Tests.ObanHelpers alias Pleroma.UnstubbedConfigMock, as: ConfigMock alias Pleroma.Web.CommonAPI alias Pleroma.Web.RichMedia.Card + alias Pleroma.Workers.RichMediaWorker import Mox import Pleroma.Factory @@ -37,6 +39,11 @@ defmodule Pleroma.Web.RichMedia.CardTest do content_type: "text/markdown" }) + assert_enqueued( + worker: RichMediaWorker, + args: %{"url" => url, "activity_id" => activity.id} + ) + ObanHelpers.perform_all() assert %Card{url_hash: ^url_hash, fields: _} = Card.get_by_activity(activity) -- cgit v1.2.3 From b135fa35a1e6258dbe1a07438213ce2593d86bc2 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 24 Jun 2024 09:46:55 -0400 Subject: RichMedia: test that activity is streamed out --- test/pleroma/web/rich_media/card_test.exs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/pleroma/web/rich_media/card_test.exs b/test/pleroma/web/rich_media/card_test.exs index 33d07127f..9541627c1 100644 --- a/test/pleroma/web/rich_media/card_test.exs +++ b/test/pleroma/web/rich_media/card_test.exs @@ -39,6 +39,9 @@ defmodule Pleroma.Web.RichMedia.CardTest do content_type: "text/markdown" }) + Pleroma.Web.ActivityPub.ActivityPubMock + |> expect(:stream_out, fn ^activity -> nil end) + assert_enqueued( worker: RichMediaWorker, args: %{"url" => url, "activity_id" => activity.id} -- cgit v1.2.3 From ba88c5078a9828bbd743ed5a1d20bab7a69aa48e Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Fri, 28 Jun 2024 20:31:03 +0400 Subject: StripLocationTest: Add failing test for PNGs --- test/fixtures/DSCN0010.png | Bin 0 -> 762272 bytes .../upload/filter/exiftool/strip_location_test.exs | 44 +++++++++++---------- 2 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 test/fixtures/DSCN0010.png (limited to 'test') diff --git a/test/fixtures/DSCN0010.png b/test/fixtures/DSCN0010.png new file mode 100644 index 000000000..66f2f05f7 Binary files /dev/null and b/test/fixtures/DSCN0010.png differ diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs index bcb5f3f60..4dcd4dce3 100644 --- a/test/pleroma/upload/filter/exiftool/strip_location_test.exs +++ b/test/pleroma/upload/filter/exiftool/strip_location_test.exs @@ -9,29 +9,31 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do test "apply exiftool filter" do assert Pleroma.Utils.command_available?("exiftool") - File.cp!( - "test/fixtures/DSCN0010.jpg", - "test/fixtures/DSCN0010_tmp.jpg" - ) - - upload = %Pleroma.Upload{ - name: "image_with_GPS_data.jpg", - content_type: "image/jpeg", - path: Path.absname("test/fixtures/DSCN0010.jpg"), - tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg") - } - - assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered} - - {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.jpg"]) - {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.jpg"]) - - refute exif_original == exif_filtered - assert String.match?(exif_original, ~r/GPS/) - refute String.match?(exif_filtered, ~r/GPS/) + ~w{jpg png} + |> Enum.map(fn type -> + File.cp!( + "test/fixtures/DSCN0010.#{type}", + "test/fixtures/DSCN0010_tmp.#{type}" + ) + + upload = %Pleroma.Upload{ + name: "image_with_GPS_data.#{type}", + content_type: "image/jpeg", + path: Path.absname("test/fixtures/DSCN0010.#{type}"), + tempfile: Path.absname("test/fixtures/DSCN0010_tmp.#{type}") + } + + assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered} + + {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"]) + {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"]) + + assert String.match?(exif_original, ~r/GPS/) + refute String.match?(exif_filtered, ~r/GPS/) + end) end - test "verify webp, heic, svg files are skipped" do + test "verify webp, heic, svg files are skipped" do uploads = ~w{webp heic svg svg+xml} |> Enum.map(fn type -> -- cgit v1.2.3