1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Upload.FilterTest do
8 alias Pleroma.Upload.Filter
10 setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
12 test "applies filters" do
13 clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
16 "test/fixtures/image.jpg",
17 "test/fixtures/image_tmp.jpg"
20 upload = %Pleroma.Upload{
21 name: "an… image.jpg",
22 content_type: "image/jpeg",
23 path: Path.absname("test/fixtures/image_tmp.jpg"),
24 tempfile: Path.absname("test/fixtures/image_tmp.jpg")
27 assert Filter.filter([], upload) == {:ok, upload}
29 assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
30 assert upload.name == "custom-file.png"