summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLain Soykaf <lain@lain.com>2024-06-28 20:31:03 +0400
committerLain Soykaf <lain@lain.com>2024-06-28 20:31:03 +0400
commitba88c5078a9828bbd743ed5a1d20bab7a69aa48e (patch)
treecb6945a9dacea486ab684f174cb1ea671602ffb4
parent394cb1e0f51de5ded6837dd882f0633f9791c11b (diff)
downloadpleroma-ba88c5078a9828bbd743ed5a1d20bab7a69aa48e.tar.gz
pleroma-ba88c5078a9828bbd743ed5a1d20bab7a69aa48e.zip
StripLocationTest: Add failing test for PNGs
-rw-r--r--.gitignore2
-rw-r--r--test/fixtures/DSCN0010.pngbin0 -> 762272 bytes
-rw-r--r--test/pleroma/upload/filter/exiftool/strip_location_test.exs44
3 files changed, 24 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index b0bb9b2e5..c0d017951 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@
/test/instance
/test/uploads
/.elixir_ls
-/test/fixtures/DSCN0010_tmp.jpg
+/test/fixtures/DSCN0010_tmp*
/test/fixtures/test_tmp.txt
/test/fixtures/image_tmp.jpg
/test/tmp/
diff --git a/test/fixtures/DSCN0010.png b/test/fixtures/DSCN0010.png
new file mode 100644
index 000000000..66f2f05f7
--- /dev/null
+++ b/test/fixtures/DSCN0010.png
Binary files 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 ->