diff --git a/lib/adapter/adapter.ex b/lib/adapter/adapter.ex index 914b3ab..c7ee89b 100644 --- a/lib/adapter/adapter.ex +++ b/lib/adapter/adapter.ex @@ -34,8 +34,13 @@ defmodule Bonfire.Federate.ActivityPub.Adapter do # "activity_id" => activity.id # # "activity" => activity # }) + + # case Incoming.receive_activity(activity) - |> debug("receive done") + # |> debug("receive done") do + # nil -> activity + # received -> received + # end end defp character_id_from_actor(actor), diff --git a/test/activity_pub_integration/actor_integration_test.exs b/test/activity_pub_integration/actor_integration_test.exs index 2bc1573..0327cbf 100644 --- a/test/activity_pub_integration/actor_integration_test.exs +++ b/test/activity_pub_integration/actor_integration_test.exs @@ -11,6 +11,8 @@ defmodule Bonfire.Federate.ActivityPub.ActorIntegrationTest do @remote_actor_url @remote_instance <> "/@karen" @webfinger @remote_instance <> "/.well-known/webfinger?resource=acct:" <> @actor_name + @webfinger @remote_instance <> + "/.well-known/webfinger?resource=acct%3Akaren%40mocked.local" # TODO: move this into fixtures setup_all do @@ -24,6 +26,9 @@ defmodule Bonfire.Federate.ActivityPub.ActorIntegrationTest do %{method: :get, url: @webfinger} -> json(Simulate.webfingered()) + %{method: :get, url: @webfinger2} -> + json(Simulate.webfingered()) + %{ method: :get, url: "http://mocked.local/.well-known/webfinger?resource=acct:karen@mocked.local" diff --git a/test/activity_pub_integration/follow_integration_test.exs b/test/activity_pub_integration/follow_integration_test.exs index c94fc3b..d2529eb 100644 --- a/test/activity_pub_integration/follow_integration_test.exs +++ b/test/activity_pub_integration/follow_integration_test.exs @@ -84,7 +84,7 @@ defmodule Bonfire.Federate.ActivityPub.FollowIntegrationTest do test "incoming follow request works" do followed = fake_user!(%{}, %{}, request_before_follow: true) - # info(ulid(followed), "followed ID") + # info(ulid(followed), "followed ID") {:ok, ap_followed} = ActivityPub.Federator.Adapter.get_actor_by_id(followed.id) {:ok, ap_follower} = ActivityPub.Actor.get_cached_or_fetch(ap_id: @remote_actor) @@ -96,7 +96,8 @@ defmodule Bonfire.Federate.ActivityPub.FollowIntegrationTest do # |> debug assert {:ok, _} = Bonfire.Federate.ActivityPub.Incoming.receive_activity(follow_activity) - assert Bonfire.Social.Graph.Follows.following?(follower, followed) + assert Bonfire.Social.Graph.Follows.requested?(follower, followed) + refute Bonfire.Social.Graph.Follows.following?(follower, followed) end test "incoming follow + accept works" do diff --git a/test/activity_pub_integration/post_web_test.exs b/test/activity_pub_integration/post_web_test.exs index 858cede..a36efb9 100644 --- a/test/activity_pub_integration/post_web_test.exs +++ b/test/activity_pub_integration/post_web_test.exs @@ -1,5 +1,5 @@ defmodule Bonfire.Federate.ActivityPub.PostWebTest do - use Bonfire.Federate.ActivityPub.ConnCase + use Bonfire.Federate.ActivityPub.ConnCase, async: false import Tesla.Mock import Untangle alias Bonfire.Posts @@ -8,8 +8,8 @@ defmodule Bonfire.Federate.ActivityPub.PostWebTest do @remote_instance "https://mocked.local" @remote_actor @remote_instance <> "/users/karen" - setup do - mock(fn + setup_all do + mock_global(fn %{method: :get, url: @remote_actor} -> json(Simulate.actor_json(@remote_actor)) @@ -19,7 +19,7 @@ defmodule Bonfire.Federate.ActivityPub.PostWebTest do _ -> raise Tesla.Mock.Error, "Request not mocked" end) - |> IO.inspect(label: "setup done") + |> debug("setup done") :ok end @@ -28,7 +28,8 @@ defmodule Bonfire.Federate.ActivityPub.PostWebTest do test "fetch local post from AP API with Pointer ID, and take into account unindexable setting" do user = fake_user!() - |> IO.inspect(label: "a user") + + # |> debug("a user") user = current_user( diff --git a/test/support/data_helpers.ex b/test/support/data_helpers.ex index da11428..d8464ff 100755 --- a/test/support/data_helpers.ex +++ b/test/support/data_helpers.ex @@ -65,7 +65,9 @@ defmodule Bonfire.Federate.ActivityPub.DataHelpers do } end - def remote_activity_json_with_mentions(actor, tos, extra \\ %{}) do + def remote_activity_json_with_mentions(actor, tos, extra \\ %{}) + + def remote_activity_json_with_mentions(actor, tos, extra) do context = "blabla" object = @@ -96,7 +98,11 @@ defmodule Bonfire.Federate.ActivityPub.DataHelpers do actor: actor, context: context, object: object, - to: tos, + to: + Enum.map(List.wrap(tos), fn + %{ap_id: ap_id} -> ap_id + ap_id -> ap_id + end), local: false, additional: %{ "id" => @remote_instance <> "/pub/" <> Needle.ULID.autogenerate(),