summaryrefslogtreecommitdiff
path: root/test/web/rich_media/parser_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2020-09-17 14:54:00 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2020-09-17 14:54:00 +0300
commit44e8b6037ae71881327451dcf7d9351f1ba82674 (patch)
treed78e161239f819c3310248f3d1685bc481f0504c /test/web/rich_media/parser_test.exs
parentc5830ac037c0c344bd22b674c41f4dc244a088aa (diff)
parentc5acbf8a1bd1a14ea82610cb3f69b8ebbb3ea28b (diff)
downloadpleroma-44e8b6037ae71881327451dcf7d9351f1ba82674.tar.gz
pleroma-44e8b6037ae71881327451dcf7d9351f1ba82674.zip
Merge branch 'develop' into feature/expire-mutes
Diffstat (limited to 'test/web/rich_media/parser_test.exs')
-rw-r--r--test/web/rich_media/parser_test.exs29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs
index 21ae35f8b..6d00c2af5 100644
--- a/test/web/rich_media/parser_test.exs
+++ b/test/web/rich_media/parser_test.exs
@@ -56,6 +56,27 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
%{method: :get, url: "http://example.com/error"} ->
{:error, :overload}
+
+ %{
+ method: :head,
+ url: "http://example.com/huge-page"
+ } ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-length", "2000001"}, {"content-type", "text/html"}]
+ }
+
+ %{
+ method: :head,
+ url: "http://example.com/pdf-file"
+ } ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-length", "1000000"}, {"content-type", "application/pdf"}]
+ }
+
+ %{method: :head} ->
+ %Tesla.Env{status: 404, body: "", headers: []}
end)
:ok
@@ -144,4 +165,12 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
test "returns error if getting page was not successful" do
assert {:error, :overload} = Parser.parse("http://example.com/error")
end
+
+ test "does a HEAD request to check if the body is too large" do
+ assert {:error, :body_too_large} = Parser.parse("http://example.com/huge-page")
+ end
+
+ test "does a HEAD request to check if the body is html" do
+ assert {:error, {:content_type, _}} = Parser.parse("http://example.com/pdf-file")
+ end
end