summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2024-07-17 17:50:17 +0000
committerfeld <feld@feld.me>2024-07-17 17:50:17 +0000
commit45445057618ff1d9b3c4980e6befc69d56a6142f (patch)
treee2bfc102b34eba70c338c15fddd2f44f9ccfc18a /test
parentb4c5cc39f65e3cd3e5e86be4631a3dcfb4bda593 (diff)
parentf753bd33805159a08cc8b447daa1c9ace137deab (diff)
downloadpleroma-45445057618ff1d9b3c4980e6befc69d56a6142f.tar.gz
pleroma-45445057618ff1d9b3c4980e6befc69d56a6142f.zip
Merge branch 'oban/rich-media-invalid' into 'develop'
Rework some Rich Media functionality for better error handling See merge request pleroma/pleroma!4182
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/rich_media/parser_test.exs12
-rw-r--r--test/support/http_request_mock.ex2
2 files changed, 7 insertions, 7 deletions
diff --git a/test/pleroma/web/rich_media/parser_test.exs b/test/pleroma/web/rich_media/parser_test.exs
index a5f2563a2..8fd75b57a 100644
--- a/test/pleroma/web/rich_media/parser_test.exs
+++ b/test/pleroma/web/rich_media/parser_test.exs
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
end
test "doesn't just add a title" do
- assert {:error, {:invalid_metadata, _}} = Parser.parse("https://example.com/non-ogp")
+ assert {:error, :invalid_metadata} = Parser.parse("https://example.com/non-ogp")
end
test "parses ogp" do
@@ -96,7 +96,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
end
test "returns error if getting page was not successful" do
- assert {:error, :overload} = Parser.parse("https://example.com/error")
+ assert {:error, :get} = Parser.parse("https://example.com/error")
end
test "does a HEAD request to check if the body is too large" do
@@ -104,17 +104,17 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
end
test "does a HEAD request to check if the body is html" do
- assert {:error, {:content_type, _}} = Parser.parse("https://example.com/pdf-file")
+ assert {:error, :content_type} = Parser.parse("https://example.com/pdf-file")
end
test "refuses to crawl incomplete URLs" do
url = "example.com/ogp"
- assert :error == Parser.parse(url)
+ assert {:error, :validate} == Parser.parse(url)
end
test "refuses to crawl malformed URLs" do
url = "example.com[]/ogp"
- assert :error == Parser.parse(url)
+ assert {:error, :validate} == Parser.parse(url)
end
test "refuses to crawl URLs of private network from posts" do
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.RichMedia.ParserTest do
"https://pleroma.local/notice/9kCP7V"
]
|> Enum.each(fn url ->
- assert :error == Parser.parse(url)
+ assert {:error, :validate} == Parser.parse(url)
end)
end
diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex
index 20e410424..ed044cf98 100644
--- a/test/support/http_request_mock.ex
+++ b/test/support/http_request_mock.ex
@@ -1724,7 +1724,7 @@ defmodule HttpRequestMock do
]
def head(url, _query, _body, _headers) when url in @rich_media_mocks do
- {:ok, %Tesla.Env{status: 404, body: ""}}
+ {:ok, %Tesla.Env{status: 200, body: ""}}
end
def head("https://example.com/pdf-file", _, _, _) do