diff options
| author | lain <lain@soykaf.club> | 2020-07-10 14:10:44 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-07-10 14:10:44 +0200 | 
| commit | 93e494ec212b5bb6aae31a3b43304ed230d095e2 (patch) | |
| tree | affb6336cc661dc6e93a6dd7cce8986eaeaeef96 /test | |
| parent | fba1ee7d7b04730c33cadb036f59e8d7c90a93b0 (diff) | |
| download | pleroma-93e494ec212b5bb6aae31a3b43304ed230d095e2.tar.gz pleroma-93e494ec212b5bb6aae31a3b43304ed230d095e2.zip  | |
ActivityPub: Don't rename a clashing nickname with the same ap id.
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 42 | 
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 b988e4437..1658f20da 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  | 
