diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2024-01-02 15:12:33 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2024-01-02 15:37:41 +0100 |
commit | 6af49270a9b1ddbdf8836139597b66695d8e1606 (patch) | |
tree | c6a33ed249fd58fb37b796a60c62bcc08976fbe3 /test | |
parent | 47e00524f7c443d5313c1b05f05d61f50c3a1f7c (diff) |
MRF: Log sensible error for subdomains_regex
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/activity_pub/mrf_test.exs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/test/pleroma/web/activity_pub/mrf_test.exs b/test/pleroma/web/activity_pub/mrf_test.exs index 4ad45c818..3ead73792 100644 --- a/test/pleroma/web/activity_pub/mrf_test.exs +++ b/test/pleroma/web/activity_pub/mrf_test.exs @@ -1,10 +1,13 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ActivityPub.MRFTest do use ExUnit.Case use Pleroma.Tests.Helpers + + import ExUnit.CaptureLog + alias Pleroma.Web.ActivityPub.MRF test "subdomains_regex/1" do @@ -61,6 +64,14 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do refute MRF.subdomain_match?(regexes, "EXAMPLE.COM") refute MRF.subdomain_match?(regexes, "example.com") end + + @tag capture_log: true + test "logs sensible error on accidental wildcard" do + assert_raise Regex.CompileError, fn -> + assert capture_log(MRF.subdomains_regex(["*unsafe.tld"])) =~ + "MRF: Invalid subdomain Regex: *unsafe.tld" + end + end end describe "instance_list_from_tuples/1" do |