logo

pleroma

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

strip_location_test.exs (1478B)


  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. File.cp!(
  10. "test/fixtures/DSCN0010.jpg",
  11. "test/fixtures/DSCN0010_tmp.jpg"
  12. )
  13. upload = %Pleroma.Upload{
  14. name: "image_with_GPS_data.jpg",
  15. content_type: "image/jpeg",
  16. path: Path.absname("test/fixtures/DSCN0010.jpg"),
  17. tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
  18. }
  19. assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
  20. {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.jpg"])
  21. {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.jpg"])
  22. refute exif_original == exif_filtered
  23. assert String.match?(exif_original, ~r/GPS/)
  24. refute String.match?(exif_filtered, ~r/GPS/)
  25. end
  26. test "verify webp, heic, svg files are skipped" do
  27. uploads =
  28. ~w{webp heic svg svg+xml}
  29. |> Enum.map(fn type ->
  30. %Pleroma.Upload{
  31. name: "sample.#{type}",
  32. content_type: "image/#{type}"
  33. }
  34. end)
  35. uploads
  36. |> Enum.each(fn upload ->
  37. assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :noop}
  38. end)
  39. end
  40. end