From b31a934a804aed3f35442ceafe2080b0955e7317 Mon Sep 17 00:00:00 2001 From: dcc Date: Wed, 15 May 2024 00:57:23 -0700 Subject: total rebase --- .../upload/filter/analyze_metadata_test.exs | 14 ++++++++++ .../upload/filter/anonymize_filename_test.exs | 0 test/pleroma/upload/filter/dedupe_test.exs | 0 .../filter/exiftool/read_description_test.exs | 2 +- .../upload/filter/exiftool/strip_location_test.exs | 0 test/pleroma/upload/filter/mogrifun_test.exs | 0 test/pleroma/upload/filter/mogrify_test.exs | 0 test/pleroma/upload/filter/only_media_test.exs | 32 ++++++++++++++++++++++ test/pleroma/upload/filter_test.exs | 0 9 files changed, 47 insertions(+), 1 deletion(-) mode change 100755 => 100644 test/pleroma/upload/filter/analyze_metadata_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/anonymize_filename_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/dedupe_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/exiftool/read_description_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/exiftool/strip_location_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/mogrifun_test.exs mode change 100755 => 100644 test/pleroma/upload/filter/mogrify_test.exs create mode 100644 test/pleroma/upload/filter/only_media_test.exs mode change 100755 => 100644 test/pleroma/upload/filter_test.exs (limited to 'test/pleroma/upload') diff --git a/test/pleroma/upload/filter/analyze_metadata_test.exs b/test/pleroma/upload/filter/analyze_metadata_test.exs old mode 100755 new mode 100644 index b800a4a..e4ac673 --- a/test/pleroma/upload/filter/analyze_metadata_test.exs +++ b/test/pleroma/upload/filter/analyze_metadata_test.exs @@ -20,6 +20,20 @@ defmodule Pleroma.Upload.Filter.AnalyzeMetadataTest do assert meta.blurhash end + test "it blurhashes images with an alpha component" do + upload = %Pleroma.Upload{ + name: "an… image.jpg", + content_type: "image/jpeg", + path: Path.absname("test/fixtures/png_with_transparency.png"), + tempfile: Path.absname("test/fixtures/png_with_transparency.png") + } + + {:ok, :filtered, meta} = AnalyzeMetadata.filter(upload) + + assert %{width: 320, height: 320} = meta + assert meta.blurhash == "eXJi-E:SwCEm5rCmn$+YWYn+15K#5A$xxCi{SiV]s*W:Efa#s.jE-T" + end + test "adds the dimensions for videos" do upload = %Pleroma.Upload{ name: "coolvideo.mp4", diff --git a/test/pleroma/upload/filter/anonymize_filename_test.exs b/test/pleroma/upload/filter/anonymize_filename_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/upload/filter/dedupe_test.exs b/test/pleroma/upload/filter/dedupe_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/upload/filter/exiftool/read_description_test.exs b/test/pleroma/upload/filter/exiftool/read_description_test.exs old mode 100755 new mode 100644 index 7cc8396..9a1bd61 --- a/test/pleroma/upload/filter/exiftool/read_description_test.exs +++ b/test/pleroma/upload/filter/exiftool/read_description_test.exs @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Upload.Filter.Exiftool.ReadDescriptionTest do - use Pleroma.DataCase, async: true + use Pleroma.DataCase alias Pleroma.Upload.Filter @uploads %Pleroma.Upload{ diff --git a/test/pleroma/upload/filter/exiftool/strip_location_test.exs b/test/pleroma/upload/filter/exiftool/strip_location_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/upload/filter/mogrifun_test.exs b/test/pleroma/upload/filter/mogrifun_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/upload/filter/mogrify_test.exs b/test/pleroma/upload/filter/mogrify_test.exs old mode 100755 new mode 100644 diff --git a/test/pleroma/upload/filter/only_media_test.exs b/test/pleroma/upload/filter/only_media_test.exs new file mode 100644 index 0000000..75be070 --- /dev/null +++ b/test/pleroma/upload/filter/only_media_test.exs @@ -0,0 +1,32 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2023 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Upload.Filter.OnlyMediaTest do + use Pleroma.DataCase, async: true + + alias Pleroma.Upload + alias Pleroma.Upload.Filter.OnlyMedia + + test "Allows media Content-Type" do + ["audio/mpeg", "image/jpeg", "video/mp4"] + |> Enum.each(fn type -> + upload = %Upload{ + content_type: type + } + + assert {:ok, :noop} = OnlyMedia.filter(upload) + end) + end + + test "Disallows non-media Content-Type" do + ["application/javascript", "application/pdf", "text/html"] + |> Enum.each(fn type -> + upload = %Upload{ + content_type: type + } + + assert {:error, _} = OnlyMedia.filter(upload) + end) + end +end diff --git a/test/pleroma/upload/filter_test.exs b/test/pleroma/upload/filter_test.exs old mode 100755 new mode 100644 -- cgit v1.2.3