summaryrefslogtreecommitdiff
path: root/test/web/activity_pub
diff options
context:
space:
mode:
Diffstat (limited to 'test/web/activity_pub')
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs22
-rw-r--r--test/web/activity_pub/relay_test.exs11
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs45
-rw-r--r--test/web/activity_pub/views/object_view_test.exs1
4 files changed, 78 insertions, 1 deletions
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index e63cd6583..1c24b348c 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -5,6 +5,28 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
alias Pleroma.{Repo, User}
alias Pleroma.Activity
+ describe "/relay" do
+ test "with the relay active, it returns the relay user", %{conn: conn} do
+ res =
+ conn
+ |> get(activity_pub_path(conn, :relay))
+ |> json_response(200)
+
+ assert res["id"] =~ "/relay"
+ end
+
+ test "with the relay disabled, it returns 404", %{conn: conn} do
+ Pleroma.Config.put([:instance, :allow_relay], false)
+
+ res =
+ conn
+ |> get(activity_pub_path(conn, :relay))
+ |> json_response(404)
+
+ Pleroma.Config.put([:instance, :allow_relay], true)
+ end
+ end
+
describe "/users/:nickname" do
test "it returns a json representation of the user", %{conn: conn} do
user = insert(:user)
diff --git a/test/web/activity_pub/relay_test.exs b/test/web/activity_pub/relay_test.exs
new file mode 100644
index 000000000..41d13e055
--- /dev/null
+++ b/test/web/activity_pub/relay_test.exs
@@ -0,0 +1,11 @@
+defmodule Pleroma.Web.ActivityPub.RelayTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Web.ActivityPub.Relay
+
+ test "gets an actor for the relay" do
+ user = Relay.get_actor()
+
+ assert user.ap_id =~ "/relay"
+ end
+end
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 6a6f2a44c..0278ef5d1 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -145,6 +145,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert "test" in data["object"]["tag"]
end
+ test "it works for incoming notices with url not being a string (prismo)" do
+ data = File.read!("test/fixtures/prismo-url-map.json") |> Poison.decode!()
+
+ {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+
+ assert data["object"]["url"] == "https://prismo.news/posts/83"
+ end
+
test "it works for incoming follow requests" do
user = insert(:user)
@@ -695,7 +703,9 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
- assert modified["@context"] == "https://www.w3.org/ns/activitystreams"
+ assert modified["@context"] ==
+ Pleroma.Web.ActivityPub.Utils.make_json_ld_header()["@context"]
+
assert modified["object"]["conversation"] == modified["context"]
end
@@ -733,6 +743,39 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert modified["object"]["inReplyTo"] == "http://gs.example.org:4040/index.php/notice/29"
end
+
+ test "it strips internal hashtag data" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu"})
+
+ expected_tag = %{
+ "href" => Pleroma.Web.Endpoint.url() <> "/tags/2hu",
+ "type" => "Hashtag",
+ "name" => "#2hu"
+ }
+
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert modified["object"]["tag"] == [expected_tag]
+ end
+
+ test "it strips internal fields" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "#2hu :moominmamma:"})
+
+ {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+ assert length(modified["object"]["tag"]) == 2
+
+ assert is_nil(modified["object"]["emoji"])
+ assert is_nil(modified["object"]["likes"])
+ assert is_nil(modified["object"]["like_count"])
+ assert is_nil(modified["object"]["announcements"])
+ assert is_nil(modified["object"]["announcement_count"])
+ assert is_nil(modified["object"]["context_id"])
+ end
end
describe "user upgrade" do
diff --git a/test/web/activity_pub/views/object_view_test.exs b/test/web/activity_pub/views/object_view_test.exs
index 6a1311be7..7e08dff5d 100644
--- a/test/web/activity_pub/views/object_view_test.exs
+++ b/test/web/activity_pub/views/object_view_test.exs
@@ -13,5 +13,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
assert result["to"] == note.data["to"]
assert result["content"] == note.data["content"]
assert result["type"] == "Note"
+ assert result["@context"]
end
end