diff options
| author | Maksim Pechnikov <parallel588@gmail.com> | 2020-09-17 08:41:35 +0300 |
|---|---|---|
| committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-09-17 08:41:35 +0300 |
| commit | b867f9d7aebc4e5b8832228a54f928b9f92dad0e (patch) | |
| tree | ee00341390c7e3382092a8f4191485f15067f943 /test/web/rich_media/parser_test.exs | |
| parent | 917d325972e3aeb367583c61aaa109d62fcba837 (diff) | |
| parent | c5acbf8a1bd1a14ea82610cb3f69b8ebbb3ea28b (diff) | |
| download | pleroma-b867f9d7aebc4e5b8832228a54f928b9f92dad0e.tar.gz pleroma-b867f9d7aebc4e5b8832228a54f928b9f92dad0e.zip | |
Merge branch 'develop' into issue/2099
Diffstat (limited to 'test/web/rich_media/parser_test.exs')
| -rw-r--r-- | test/web/rich_media/parser_test.exs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs index 1e09cbf84..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 @@ -66,9 +87,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do end test "doesn't just add a title" do - assert Parser.parse("http://example.com/non-ogp") == - {:error, - "Found metadata was invalid or incomplete: %{\"url\" => \"http://example.com/non-ogp\"}"} + assert {:error, {:invalid_metadata, _}} = Parser.parse("http://example.com/non-ogp") end test "parses ogp" do @@ -146,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 |
