diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/rich_media/ogp-missing-title.html | 12 | ||||
-rw-r--r-- | test/html_test.exs | 16 | ||||
-rw-r--r-- | test/plugs/rate_limiter_test.exs | 4 | ||||
-rw-r--r-- | test/tasks/config_test.exs | 2 | ||||
-rw-r--r-- | test/tasks/ecto/migrate_test.exs | 20 | ||||
-rw-r--r-- | test/tasks/ecto/rollback_test.exs | 16 | ||||
-rw-r--r-- | test/web/admin_api/admin_api_controller_test.exs | 2 | ||||
-rw-r--r-- | test/web/mastodon_api/account_view_test.exs | 6 | ||||
-rw-r--r-- | test/web/rich_media/parser_test.exs | 22 |
9 files changed, 62 insertions, 38 deletions
diff --git a/test/fixtures/rich_media/ogp-missing-title.html b/test/fixtures/rich_media/ogp-missing-title.html deleted file mode 100644 index fcdbedfc6..000000000 --- a/test/fixtures/rich_media/ogp-missing-title.html +++ /dev/null @@ -1,12 +0,0 @@ -<html prefix="og: http://ogp.me/ns#"> - -<head> - <title>The Rock (1996)</title> - <meta property="og:type" content="video.movie" /> - <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" /> - <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" /> - <meta property="og:description" - content="Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer."> -</head> - -</html> diff --git a/test/html_test.exs b/test/html_test.exs index 64513980b..b8906c46a 100644 --- a/test/html_test.exs +++ b/test/html_test.exs @@ -212,5 +212,21 @@ defmodule Pleroma.HTMLTest do assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140" end + + test "skips microformats hashtags" do + user = insert(:user) + + {:ok, activity} = + CommonAPI.post(user, %{ + "status" => + "<a href=\"https://pleroma.gov/tags/cofe\" rel=\"tag\">#cofe</a> https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140", + "content_type" => "text/html" + }) + + object = Object.normalize(activity) + {:ok, url} = HTML.extract_first_external_url(object, object.data["content"]) + + assert url == "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=72255140" + end end end diff --git a/test/plugs/rate_limiter_test.exs b/test/plugs/rate_limiter_test.exs index b3798bf03..b8d6aff89 100644 --- a/test/plugs/rate_limiter_test.exs +++ b/test/plugs/rate_limiter_test.exs @@ -20,7 +20,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do end test "it restricts by opts" do - scale = 100 + scale = 1000 limit = 5 Pleroma.Config.put([:rate_limit, @limiter_name], {scale, limit}) @@ -64,7 +64,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do test "optional limits for authenticated users" do Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo) - scale = 100 + scale = 1000 limit = 5 Pleroma.Config.put([:rate_limit, @limiter_name], [{1, 10}, {scale, limit}]) diff --git a/test/tasks/config_test.exs b/test/tasks/config_test.exs index 7d3b1860c..d448b0444 100644 --- a/test/tasks/config_test.exs +++ b/test/tasks/config_test.exs @@ -5,7 +5,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do setup_all do Mix.shell(Mix.Shell.Process) - temp_file = "config/temp.migrated.secret.exs" + temp_file = "config/temp.exported_from_db.secret.exs" dynamic = Pleroma.Config.get([:instance, :dynamic_configuration]) diff --git a/test/tasks/ecto/migrate_test.exs b/test/tasks/ecto/migrate_test.exs new file mode 100644 index 000000000..0538a7b40 --- /dev/null +++ b/test/tasks/ecto/migrate_test.exs @@ -0,0 +1,20 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-onl + +defmodule Mix.Tasks.Pleroma.Ecto.MigrateTest do + use Pleroma.DataCase, async: true + import ExUnit.CaptureLog + require Logger + + test "ecto.migrate info message" do + level = Logger.level() + Logger.configure(level: :warn) + + assert capture_log(fn -> + Mix.Tasks.Pleroma.Ecto.Migrate.run() + end) =~ "[info] Already up" + + Logger.configure(level: level) + end +end diff --git a/test/tasks/ecto/rollback_test.exs b/test/tasks/ecto/rollback_test.exs new file mode 100644 index 000000000..33d093fca --- /dev/null +++ b/test/tasks/ecto/rollback_test.exs @@ -0,0 +1,16 @@ +defmodule Mix.Tasks.Pleroma.Ecto.RollbackTest do + use Pleroma.DataCase + import ExUnit.CaptureLog + require Logger + + test "ecto.rollback info message" do + level = Logger.level() + Logger.configure(level: :warn) + + assert capture_log(fn -> + Mix.Tasks.Pleroma.Ecto.Rollback.run() + end) =~ "[info] Rollback succesfully" + + Logger.configure(level: level) + end +end diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 18f64f2b7..2a5912645 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -1334,7 +1334,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do setup %{conn: conn} do admin = insert(:user, info: %{is_admin: true}) - temp_file = "config/test.migrated.secret.exs" + temp_file = "config/test.exported_from_db.secret.exs" on_exit(fn -> Application.delete_env(:pleroma, :key1) diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs index 2ba7c0505..de6aeec72 100644 --- a/test/web/mastodon_api/account_view_test.exs +++ b/test/web/mastodon_api/account_view_test.exs @@ -269,4 +269,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do result = AccountView.render("account.json", %{user: user, for: user}) assert result.pleroma[:settings_store] == nil end + + test "sanitizes display names" do + user = insert(:user, name: "<marquee> username </marquee>") + result = AccountView.render("account.json", %{user: user}) + refute result.display_name == "<marquee> username </marquee>" + end end diff --git a/test/web/rich_media/parser_test.exs b/test/web/rich_media/parser_test.exs index a49ba9549..3a9cc1854 100644 --- a/test/web/rich_media/parser_test.exs +++ b/test/web/rich_media/parser_test.exs @@ -11,15 +11,6 @@ defmodule Pleroma.Web.RichMedia.ParserTest do %{ method: :get, - url: "http://example.com/ogp-missing-title" - } -> - %Tesla.Env{ - status: 200, - body: File.read!("test/fixtures/rich_media/ogp-missing-title.html") - } - - %{ - method: :get, url: "http://example.com/twitter-card" } -> %Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/twitter_card.html")} @@ -60,19 +51,6 @@ defmodule Pleroma.Web.RichMedia.ParserTest do }} end - test "falls back to <title> when ogp:title is missing" do - assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/ogp-missing-title") == - {:ok, - %{ - image: "http://ia.media-imdb.com/images/rock.jpg", - title: "The Rock (1996)", - description: - "Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John Spencer.", - type: "video.movie", - url: "http://www.imdb.com/title/tt0117500/" - }} - end - test "parses twitter card" do assert Pleroma.Web.RichMedia.Parser.parse("http://example.com/twitter-card") == {:ok, |