diff options
author | lain <lain@soykaf.club> | 2023-05-30 08:04:23 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2023-05-30 08:04:23 +0000 |
commit | da6b4003acad84b0f60ad8da6d08cfe13564b058 (patch) | |
tree | 9f193a68ff62feb27f3c37888ed2cf1722586301 /test | |
parent | 31ec5cd35eece97aa1213c401b40d3ab83689ea9 (diff) | |
parent | 50a20f3bbd1203679c9295eb6002225dd630baf8 (diff) | |
download | pleroma-da6b4003acad84b0f60ad8da6d08cfe13564b058.tar.gz pleroma-da6b4003acad84b0f60ad8da6d08cfe13564b058.zip |
Merge branch 'only_media_filter' into 'develop'
Add OnlyMedia Upload Filter
See merge request pleroma/pleroma!3897
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/upload/filter/only_media_test.exs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/pleroma/upload/filter/only_media_test.exs b/test/pleroma/upload/filter/only_media_test.exs new file mode 100644 index 000000000..75be070a1 --- /dev/null +++ b/test/pleroma/upload/filter/only_media_test.exs @@ -0,0 +1,32 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Upload.Filter.OnlyMediaTest do + use Pleroma.DataCase, async: true + + alias Pleroma.Upload + alias Pleroma.Upload.Filter.OnlyMedia + + test "Allows media Content-Type" do + ["audio/mpeg", "image/jpeg", "video/mp4"] + |> Enum.each(fn type -> + upload = %Upload{ + content_type: type + } + + assert {:ok, :noop} = OnlyMedia.filter(upload) + end) + end + + test "Disallows non-media Content-Type" do + ["application/javascript", "application/pdf", "text/html"] + |> Enum.each(fn type -> + upload = %Upload{ + content_type: type + } + + assert {:error, _} = OnlyMedia.filter(upload) + end) + end +end |