diff options
author | lain <lain@soykaf.club> | 2020-05-13 08:12:09 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-13 08:12:09 +0000 |
commit | a5ccb5b0b1032b102c54d4df2e17c61423089e73 (patch) | |
tree | 48f8014dbdd9deb8b9aae1d894344c039c203918 /test/web/activity_pub | |
parent | a6283bbae13a873af969336bd4e62011777a1a70 (diff) | |
parent | 2906cbbd40ea07c2ceb4d67e1c889cc7ab8b7662 (diff) | |
download | pleroma-2.0.5.tar.gz |
Merge branch 'release/2.0.5' into 'stable'v2.0.5
Release/2.0.5
See merge request pleroma/secteam/pleroma!4
Diffstat (limited to 'test/web/activity_pub')
-rw-r--r-- | test/web/activity_pub/activity_pub_controller_test.exs | 4 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 37 | ||||
-rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 6 |
3 files changed, 43 insertions, 4 deletions
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index c418232da..153adc703 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -310,7 +310,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do end describe "/inbox" do + clear_config([:instance, :user_bio_length]) + test "it inserts an incoming activity into the database", %{conn: conn} do + Pleroma.Config.put([:instance, :user_bio_length], 1) + data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() conn = diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 433859dab..e6c4299ba 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -1351,15 +1351,44 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert Repo.aggregate(Object, :count, :id) == 0 end + clear_config([:instance, :federating]) + test "creates a block activity" do + Config.put([:instance, :federating], true) blocker = insert(:user) blocked = insert(:user) - {:ok, activity} = ActivityPub.block(blocker, blocked) + with_mock Pleroma.Web.Federator, + publish: fn _ -> nil end do + {:ok, activity} = ActivityPub.block(blocker, blocked) - assert activity.data["type"] == "Block" - assert activity.data["actor"] == blocker.ap_id - assert activity.data["object"] == blocked.ap_id + assert activity.data["type"] == "Block" + assert activity.data["actor"] == blocker.ap_id + assert activity.data["object"] == blocked.ap_id + + assert called(Pleroma.Web.Federator.publish(activity)) + end + end + + clear_config([:instance, :federating]) + clear_config([:activitypub, :outgoing_blocks]) + + test "works with outgoing blocks disabled, but doesn't federate" do + Config.put([:instance, :federating], true) + Config.put([:activitypub, :outgoing_blocks], false) + blocker = insert(:user) + blocked = insert(:user) + + with_mock Pleroma.Web.Federator, + publish: fn _ -> nil end do + {:ok, activity} = ActivityPub.block(blocker, blocked) + + assert activity.data["type"] == "Block" + assert activity.data["actor"] == blocker.ap_id + assert activity.data["object"] == blocked.ap_id + + refute called(Pleroma.Web.Federator.publish(:_)) + end end test "reverts unblock activity on error" do diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 2a3fd92b4..601e5f966 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1120,6 +1120,12 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do follower = User.get_cached_by_id(follower.id) assert User.following?(follower, followed) == true + + follower = User.get_by_id(follower.id) + assert follower.following_count == 1 + + followed = User.get_by_id(followed.id) + assert followed.follower_count == 1 end test "it fails for incoming accepts which cannot be correlated" do |