logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

strip_location_test.exs (1545B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
  5. use Pleroma.DataCase, async: true
  6. alias Pleroma.Upload.Filter
  7. test "apply exiftool filter" do
  8. assert Pleroma.Utils.command_available?("exiftool")
  9. ~w{jpg png}
  10. |> Enum.map(fn type ->
  11. File.cp!(
  12. "test/fixtures/DSCN0010.#{type}",
  13. "test/fixtures/DSCN0010_tmp.#{type}"
  14. )
  15. upload = %Pleroma.Upload{
  16. name: "image_with_GPS_data.#{type}",
  17. content_type: "image/jpeg",
  18. path: Path.absname("test/fixtures/DSCN0010.#{type}"),
  19. tempfile: Path.absname("test/fixtures/DSCN0010_tmp.#{type}")
  20. }
  21. assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
  22. {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
  23. {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
  24. assert String.match?(exif_original, ~r/GPS/)
  25. refute String.match?(exif_filtered, ~r/GPS/)
  26. end)
  27. end
  28. test "verify webp, heic, svg files are skipped" do
  29. uploads =
  30. ~w{webp heic svg svg+xml}
  31. |> Enum.map(fn type ->
  32. %Pleroma.Upload{
  33. name: "sample.#{type}",
  34. content_type: "image/#{type}"
  35. }
  36. end)
  37. uploads
  38. |> Enum.each(fn upload ->
  39. assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :noop}
  40. end)
  41. end
  42. end