Add missing libmagic for image upload
[akkoma] / test / upload / filter / exiftool_test.exs
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
5 defmodule Pleroma.Upload.Filter.ExiftoolTest do
6 use Pleroma.DataCase
7 alias Pleroma.Upload.Filter
8
9 test "apply exiftool filter" do
10 File.cp!(
11 "test/fixtures/DSCN0010.jpg",
12 "test/fixtures/DSCN0010_tmp.jpg"
13 )
14
15 upload = %Pleroma.Upload{
16 name: "image_with_GPS_data.jpg",
17 content_type: "image/jpg",
18 path: Path.absname("test/fixtures/DSCN0010.jpg"),
19 tempfile: Path.absname("test/fixtures/DSCN0010_tmp.jpg")
20 }
21
22 assert Filter.Exiftool.filter(upload) == :ok
23
24 {exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.jpg"])
25 {exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.jpg"])
26
27 refute exif_original == exif_filtered
28 assert String.match?(exif_original, ~r/GPS/)
29 refute String.match?(exif_filtered, ~r/GPS/)
30 end
31 end