diff options
author | rinpatch <rinpatch@sdf.org> | 2020-09-17 19:09:10 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-09-17 19:09:10 +0000 |
commit | a0f5e8b27edbe2224d9c2c3997ad5b8ea484244b (patch) | |
tree | 4a7a0f02e5880b7dff3ac20eaf59d71c7b584e5e /test/web/rich_media | |
parent | 425324aae3d4534bc045466a1cc15653ddfa27d2 (diff) | |
parent | 34afc2b0745b39861d9381e69cdb4b9c158f86ee (diff) | |
download | pleroma-2.1.2.tar.gz |
Merge branch 'release/2.1.2' into 'stable'v2.1.2
Release/2.1.2
See merge request pleroma/secteam/pleroma!17
Diffstat (limited to 'test/web/rich_media')
-rw-r--r-- | test/web/rich_media/parser_test.exs | 29 |
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 1e09cbf84..b8ef2cccf 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 @@ -146,4 +167,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 |