summaryrefslogtreecommitdiff
path: root/test/web
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-09-14 12:38:00 +0000
committerrinpatch <rinpatch@sdf.org>2020-09-14 12:38:00 +0000
commit4d543fcb759dccc3627be66851789712c189a540 (patch)
treed8e4287a106a95eb5ba2f3f00191d9799020eb31 /test/web
parent2937e3095ab9208b2aea1f42792ab99b1b4252d7 (diff)
parent738685a6298d7bd883fe81477b2e25ec94822e02 (diff)
downloadpleroma-4d543fcb759dccc3627be66851789712c189a540.tar.gz
pleroma-4d543fcb759dccc3627be66851789712c189a540.zip
Merge branch 'feat/rich-media-head' into 'develop'
RichMedia: Do a HEAD request to check content type/length See merge request pleroma/pleroma!2995
Diffstat (limited to 'test/web')
-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