Merge remote-tracking branch 'remotes/origin/develop' into 1560-non-federating-instan...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 12 Mar 2020 09:07:07 +0000 (12:07 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 12 Mar 2020 09:07:07 +0000 (12:07 +0300)
# Conflicts:
# test/web/activity_pub/activity_pub_controller_test.exs

1  2 
test/web/activity_pub/activity_pub_controller_test.exs

index a939d0bebc84aab3ef811aded49ff9972378bb54,b2352538a3f41acde656604d509f9675cd586a17..bd8e0b5cc8ea1df1e59e64b61c17d68d7530e3a8
@@@ -411,33 -342,43 +411,71 @@@ defmodule Pleroma.Web.ActivityPub.Activ
        assert Instances.reachable?(sender_url)
      end
  
+     test "accept follow activity", %{conn: conn} do
+       Pleroma.Config.put([:instance, :federating], true)
+       relay = Relay.get_actor()
+       assert {:ok, %Activity{} = activity} = Relay.follow("https://relay.mastodon.host/actor")
+       followed_relay = Pleroma.User.get_by_ap_id("https://relay.mastodon.host/actor")
+       relay = refresh_record(relay)
+       accept =
+         File.read!("test/fixtures/relay/accept-follow.json")
+         |> String.replace("{{ap_id}}", relay.ap_id)
+         |> String.replace("{{activity_id}}", activity.data["id"])
+       assert "ok" ==
+                conn
+                |> assign(:valid_signature, true)
+                |> put_req_header("content-type", "application/activity+json")
+                |> post("/inbox", accept)
+                |> json_response(200)
+       ObanHelpers.perform(all_enqueued(worker: ReceiverWorker))
+       assert Pleroma.FollowingRelationship.following?(
+                relay,
+                followed_relay
+              )
+       Mix.shell(Mix.Shell.Process)
+       on_exit(fn ->
+         Mix.shell(Mix.Shell.IO)
+       end)
+       :ok = Mix.Tasks.Pleroma.Relay.run(["list"])
+       assert_receive {:mix_shell, :info, ["relay.mastodon.host"]}
+     end
++
 +    test "without valid signature, " <>
 +           "it only accepts Create activities and requires enabled federation",
 +         %{conn: conn} do
 +      data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
 +      non_create_data = File.read!("test/fixtures/mastodon-announce.json") |> Poison.decode!()
 +
 +      conn = put_req_header(conn, "content-type", "application/activity+json")
 +
 +      Config.put([:instance, :federating], false)
 +
 +      conn
 +      |> post("/inbox", data)
 +      |> json_response(403)
 +
 +      conn
 +      |> post("/inbox", non_create_data)
 +      |> json_response(403)
 +
 +      Config.put([:instance, :federating], true)
 +
 +      ret_conn = post(conn, "/inbox", data)
 +      assert "ok" == json_response(ret_conn, 200)
 +
 +      conn
 +      |> post("/inbox", non_create_data)
 +      |> json_response(400)
 +    end
    end
  
    describe "/users/:nickname/inbox" do