diff options
| author | lain <lain@soykaf.club> | 2020-07-08 17:07:24 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-07-08 17:07:24 +0200 | 
| commit | 00e54f8fe7af098ba829f7f7cd5511569dcd1c0a (patch) | |
| tree | 263998479216cab106f83f0ef7654f82b98d7e6f /test/web | |
| parent | 9dda8b542723afae8dd5493b4082b8524873a14d (diff) | |
| download | pleroma-00e54f8fe7af098ba829f7f7cd5511569dcd1c0a.tar.gz pleroma-00e54f8fe7af098ba829f7f7cd5511569dcd1c0a.zip | |
ActivityPub: Remove `follow` and fix issues.
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 32 | ||||
| -rw-r--r-- | test/web/activity_pub/relay_test.exs | 6 | ||||
| -rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 11 | ||||
| -rw-r--r-- | test/web/activity_pub/utils_test.exs | 9 | ||||
| -rw-r--r-- | test/web/common_api/common_api_test.exs | 21 | ||||
| -rw-r--r-- | test/web/mastodon_api/controllers/follow_request_controller_test.exs | 8 | 
6 files changed, 36 insertions, 51 deletions
| diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 17e12a1a7..38c98f658 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -669,7 +669,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do      refute activity in activities      followed_user = insert(:user) -    ActivityPub.follow(user, followed_user) +    CommonAPI.follow(user, followed_user)      {:ok, repeat_activity} = CommonAPI.repeat(activity.id, followed_user)      activities = ActivityPub.fetch_activities([], %{blocking_user: user, skip_preload: true}) @@ -1013,24 +1013,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do      end    end -  describe "following / unfollowing" do -    test "it reverts follow activity" do -      follower = insert(:user) -      followed = insert(:user) - -      with_mock(Utils, [:passthrough], maybe_federate: fn _ -> {:error, :reverted} end) do -        assert {:error, :reverted} = ActivityPub.follow(follower, followed) -      end - -      assert Repo.aggregate(Activity, :count, :id) == 0 -      assert Repo.aggregate(Object, :count, :id) == 0 -    end - +  describe "unfollowing" do      test "it reverts unfollow activity" do        follower = insert(:user)        followed = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        with_mock(Utils, [:passthrough], maybe_federate: fn _ -> {:error, :reverted} end) do          assert {:error, :reverted} = ActivityPub.unfollow(follower, followed) @@ -1043,21 +1031,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do        assert activity.data["object"] == followed.ap_id      end -    test "creates a follow activity" do -      follower = insert(:user) -      followed = insert(:user) - -      {:ok, activity} = ActivityPub.follow(follower, followed) -      assert activity.data["type"] == "Follow" -      assert activity.data["actor"] == follower.ap_id -      assert activity.data["object"] == followed.ap_id -    end -      test "creates an undo activity for the last follow" do        follower = insert(:user)        followed = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        {:ok, activity} = ActivityPub.unfollow(follower, followed)        assert activity.data["type"] == "Undo" @@ -1074,7 +1052,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do        follower = insert(:user)        followed = insert(:user, %{locked: true}) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        {:ok, activity} = ActivityPub.unfollow(follower, followed)        assert activity.data["type"] == "Undo" diff --git a/test/web/activity_pub/relay_test.exs b/test/web/activity_pub/relay_test.exs index b3b573c9b..9d657ac4f 100644 --- a/test/web/activity_pub/relay_test.exs +++ b/test/web/activity_pub/relay_test.exs @@ -7,8 +7,8 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do    alias Pleroma.Activity    alias Pleroma.User -  alias Pleroma.Web.ActivityPub.ActivityPub    alias Pleroma.Web.ActivityPub.Relay +  alias Pleroma.Web.CommonAPI    import ExUnit.CaptureLog    import Pleroma.Factory @@ -53,8 +53,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do      test "returns activity" do        user = insert(:user)        service_actor = Relay.get_actor() -      ActivityPub.follow(service_actor, user) -      Pleroma.User.follow(service_actor, user) +      CommonAPI.follow(service_actor, user)        assert "#{user.ap_id}/followers" in User.following(service_actor)        assert {:ok, %Activity{} = activity} = Relay.unfollow(user.ap_id)        assert activity.actor == "#{Pleroma.Web.Endpoint.url()}/relay" @@ -74,6 +73,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do        assert Relay.publish(activity) == {:error, "Not implemented"}      end +    @tag capture_log: true      test "returns error when activity not public" do        activity = insert(:direct_note_activity)        assert Relay.publish(activity) == {:error, false} diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 01179206c..f7b7d1a9f 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -11,7 +11,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do    alias Pleroma.Object.Fetcher    alias Pleroma.Tests.ObanHelpers    alias Pleroma.User -  alias Pleroma.Web.ActivityPub.ActivityPub    alias Pleroma.Web.ActivityPub.Transmogrifier    alias Pleroma.Web.AdminAPI.AccountView    alias Pleroma.Web.CommonAPI @@ -452,7 +451,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        {:ok, follower} = User.follow(follower, followed)        assert User.following?(follower, followed) == true -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        accept_data =          File.read!("test/fixtures/mastodon-accept-activity.json") @@ -482,7 +481,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        follower = insert(:user)        followed = insert(:user, locked: true) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        accept_data =          File.read!("test/fixtures/mastodon-accept-activity.json") @@ -504,7 +503,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        follower = insert(:user)        followed = insert(:user, locked: true) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        accept_data =          File.read!("test/fixtures/mastodon-accept-activity.json") @@ -569,7 +568,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        followed = insert(:user, locked: true)        {:ok, follower} = User.follow(follower, followed) -      {:ok, _follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, _follow_activity} = CommonAPI.follow(follower, followed)        assert User.following?(follower, followed) == true @@ -595,7 +594,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        followed = insert(:user, locked: true)        {:ok, follower} = User.follow(follower, followed) -      {:ok, follow_activity} = ActivityPub.follow(follower, followed) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)        assert User.following?(follower, followed) == true diff --git a/test/web/activity_pub/utils_test.exs b/test/web/activity_pub/utils_test.exs index 2f9ecb5a3..361dc5a41 100644 --- a/test/web/activity_pub/utils_test.exs +++ b/test/web/activity_pub/utils_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do    alias Pleroma.Object    alias Pleroma.Repo    alias Pleroma.User -  alias Pleroma.Web.ActivityPub.ActivityPub    alias Pleroma.Web.ActivityPub.Utils    alias Pleroma.Web.AdminAPI.AccountView    alias Pleroma.Web.CommonAPI @@ -197,8 +196,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do        user = insert(:user, locked: true)        follower = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_two} = ActivityPub.follow(follower, user) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)        data =          follow_activity_two.data @@ -221,8 +220,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do        user = insert(:user, locked: true)        follower = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_two} = ActivityPub.follow(follower, user) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user)        data =          follow_activity_two.data diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 908ee5484..7e11fede3 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -934,6 +934,15 @@ defmodule Pleroma.Web.CommonAPITest do      end    end +  describe "follow/2" do +    test "directly follows a non-locked local user" do +      [follower, followed] = insert_pair(:user) +      {:ok, follower, followed, _} = CommonAPI.follow(follower, followed) + +      assert User.following?(follower, followed) +    end +  end +    describe "unfollow/2" do      test "also unsubscribes a user" do        [follower, followed] = insert_pair(:user) @@ -998,9 +1007,9 @@ defmodule Pleroma.Web.CommonAPITest do        follower = insert(:user)        follower_two = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_two} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user)        assert follow_activity.data["state"] == "pending"        assert follow_activity_two.data["state"] == "pending" @@ -1018,9 +1027,9 @@ defmodule Pleroma.Web.CommonAPITest do        follower = insert(:user)        follower_two = insert(:user) -      {:ok, follow_activity} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_two} = ActivityPub.follow(follower, user) -      {:ok, follow_activity_three} = ActivityPub.follow(follower_two, user) +      {:ok, _, _, follow_activity} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_two} = CommonAPI.follow(follower, user) +      {:ok, _, _, follow_activity_three} = CommonAPI.follow(follower_two, user)        assert follow_activity.data["state"] == "pending"        assert follow_activity_two.data["state"] == "pending" diff --git a/test/web/mastodon_api/controllers/follow_request_controller_test.exs b/test/web/mastodon_api/controllers/follow_request_controller_test.exs index 44e12d15a..6749e0e83 100644 --- a/test/web/mastodon_api/controllers/follow_request_controller_test.exs +++ b/test/web/mastodon_api/controllers/follow_request_controller_test.exs @@ -6,7 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do    use Pleroma.Web.ConnCase    alias Pleroma.User -  alias Pleroma.Web.ActivityPub.ActivityPub +  alias Pleroma.Web.CommonAPI    import Pleroma.Factory @@ -20,7 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        {:ok, other_user} = User.follow(other_user, user, :follow_pending)        assert User.following?(other_user, user) == false @@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests/:id/authorize works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        {:ok, other_user} = User.follow(other_user, user, :follow_pending)        user = User.get_cached_by_id(user.id) @@ -56,7 +56,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do      test "/api/v1/follow_requests/:id/reject works", %{user: user, conn: conn} do        other_user = insert(:user) -      {:ok, _activity} = ActivityPub.follow(other_user, user) +      {:ok, _, _, _activity} = CommonAPI.follow(other_user, user)        user = User.get_cached_by_id(user.id) | 
