logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

exiftool_test.exs (1258B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.Filter.ExiftoolTest do
  5. use Pleroma.DataCase
  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/jpg",
  16. path: Path.absname("test/fixtures/DSCN0010.jpg"),
  17. tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
  18. }
  19. assert Filter.Exiftool.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 files are skipped" do
  27. upload = %Pleroma.Upload{
  28. name: "sample.webp",
  29. content_type: "image/webp"
  30. }
  31. assert Filter.Exiftool.filter(upload) == {:ok, :noop}
  32. end
  33. end