diff options
author | rinpatch <rinpatch@sdf.org> | 2020-06-10 12:05:45 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-06-10 12:05:45 +0000 |
commit | 7aa6c82937090ca6f2298dee0ef894954ca2f129 (patch) | |
tree | 850f22f06eccd0babae8b805fa55109b536f324c /test/web/activity_pub/object_validators | |
parent | 1b746cfbbb55cd3411e809ead246c752a43361d0 (diff) | |
parent | 064c4f86f32b626a626fbc238f09434617f57a90 (diff) | |
download | pleroma-7aa6c82937090ca6f2298dee0ef894954ca2f129.tar.gz pleroma-7aa6c82937090ca6f2298dee0ef894954ca2f129.zip |
Merge branch 'remake-remodel-dms' into 'develop'
Chats / ChatMessages
See merge request pleroma/pleroma!2429
Diffstat (limited to 'test/web/activity_pub/object_validators')
-rw-r--r-- | test/web/activity_pub/object_validators/types/object_id_test.exs | 4 | ||||
-rw-r--r-- | test/web/activity_pub/object_validators/types/safe_text_test.exs | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validators/types/object_id_test.exs b/test/web/activity_pub/object_validators/types/object_id_test.exs index 834213182..c8911948e 100644 --- a/test/web/activity_pub/object_validators/types/object_id_test.exs +++ b/test/web/activity_pub/object_validators/types/object_id_test.exs @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.ObjectValidators.Types.ObjectIDTest do alias Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID use Pleroma.DataCase diff --git a/test/web/activity_pub/object_validators/types/safe_text_test.exs b/test/web/activity_pub/object_validators/types/safe_text_test.exs new file mode 100644 index 000000000..d4a574554 --- /dev/null +++ b/test/web/activity_pub/object_validators/types/safe_text_test.exs @@ -0,0 +1,30 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeTextTest do + use Pleroma.DataCase + + alias Pleroma.Web.ActivityPub.ObjectValidators.Types.SafeText + + test "it lets normal text go through" do + text = "hey how are you" + assert {:ok, text} == SafeText.cast(text) + end + + test "it removes html tags from text" do + text = "hey look xss <script>alert('foo')</script>" + assert {:ok, "hey look xss alert('foo')"} == SafeText.cast(text) + end + + test "it keeps basic html tags" do + text = "hey <a href='http://gensokyo.2hu'>look</a> xss <script>alert('foo')</script>" + + assert {:ok, "hey <a href=\"http://gensokyo.2hu\">look</a> xss alert('foo')"} == + SafeText.cast(text) + end + + test "errors for non-text" do + assert :error == SafeText.cast(1) + end +end |