diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-09-14 21:51:25 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-09-14 21:51:25 +0300 |
commit | 5687ff6c4a1186e08737156e784162376719bd39 (patch) | |
tree | eb4d871eb7a3acb2ce3ccd5272695aa0faa971bf /test/web/rich_media | |
parent | d52eece03ab744fa7c18bbdf70e20b5bd9589f13 (diff) | |
parent | 39d769f25057dbaf89dc23d39941780bc65c2b06 (diff) | |
download | pleroma-media-preview-proxy.tar.gz |
Merge remote-tracking branch 'remotes/origin/develop' into media-preview-proxymedia-preview-proxy
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 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 |