summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-07-13 12:06:43 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2020-07-13 12:06:43 +0000
commitf918b6f86ddf8e101a9ce22a46694788eb48b5c7 (patch)
tree94e0062e8f408e7e876a23912dc5dbcf2d616158 /test
parent11dd29ef3f9bb5b0b3109eb572c3d5ae2c830ea3 (diff)
parent93e494ec212b5bb6aae31a3b43304ed230d095e2 (diff)
downloadpleroma-f918b6f86ddf8e101a9ce22a46694788eb48b5c7.tar.gz
pleroma-f918b6f86ddf8e101a9ce22a46694788eb48b5c7.zip
Merge branch '1937-renaming' into 'develop'
ActivityPub: Don't rename a clashing nickname with the same ap id. Closes #1937 See merge request pleroma/pleroma!2748
Diffstat (limited to 'test')
-rw-r--r--test/web/activity_pub/activity_pub_test.exs42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 1520ffc4b..f3951462f 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -2056,4 +2056,46 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert [%{activity_id: ^id_create}] = Pleroma.ActivityExpiration |> Repo.all()
end
end
+
+ describe "handling of clashing nicknames" do
+ test "renames an existing user with a clashing nickname and a different ap id" do
+ orig_user =
+ insert(
+ :user,
+ local: false,
+ nickname: "admin@mastodon.example.org",
+ ap_id: "http://mastodon.example.org/users/harinezumigari"
+ )
+
+ %{
+ nickname: orig_user.nickname,
+ ap_id: orig_user.ap_id <> "part_2"
+ }
+ |> ActivityPub.maybe_handle_clashing_nickname()
+
+ user = User.get_by_id(orig_user.id)
+
+ assert user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
+ end
+
+ test "does nothing with a clashing nickname and the same ap id" do
+ orig_user =
+ insert(
+ :user,
+ local: false,
+ nickname: "admin@mastodon.example.org",
+ ap_id: "http://mastodon.example.org/users/harinezumigari"
+ )
+
+ %{
+ nickname: orig_user.nickname,
+ ap_id: orig_user.ap_id
+ }
+ |> ActivityPub.maybe_handle_clashing_nickname()
+
+ user = User.get_by_id(orig_user.id)
+
+ assert user.nickname == orig_user.nickname
+ end
+ end
end