aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-03-17 13:02:10 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-03-17 14:00:19 +0100
commitd3cf7e19fbe089b3a6d62d6a26f3dfc866a6669d (patch)
treefdb47e001c2b4a251be588bf97a953a06b667321
parent34fd1c2c9d685c160fd2c20602840bfa9dceb38f (diff)
downloadpleroma-d3cf7e19fbe089b3a6d62d6a26f3dfc866a6669d.tar.gz
activity_pub_controller_test.exs: test posting with AP C2S uploaded media
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs34
1 files changed, 32 insertions, 2 deletions
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index bd8e0b5cc..2bd494a37 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -1241,16 +1241,46 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
filename: "an_image.jpg"
}
- conn =
+ object =
conn
|> assign(:user, user)
|> post("/api/ap/upload_media", %{"file" => image, "description" => desc})
+ |> json_response(:created)
- assert object = json_response(conn, :created)
assert object["name"] == desc
assert object["type"] == "Document"
assert object["actor"] == user.ap_id
+ assert [%{"href" => object_href}] = object["url"]
+
+ activity_request = %{
+ "@context" => "https://www.w3.org/ns/activitystreams",
+ "type" => "Create",
+ "object" => %{
+ "type" => "Note",
+ "content" => "AP C2S test, attachment",
+ "attachment" => [object]
+ },
+ "to" => "https://www.w3.org/ns/activitystreams#Public",
+ "cc" => []
+ }
+
+ activity_response =
+ conn
+ |> assign(:user, user)
+ |> post("/users/#{user.nickname}/outbox", activity_request)
+ |> json_response(:created)
+
+ assert activity_response["id"]
+ assert activity_response["object"]
+ assert activity_response["actor"] == user.ap_id
+
+ assert %Object{data: %{"attachment" => [attachment]}} = Object.normalize(activity_response["object"])
+ assert attachment["type"] == "Document"
+ assert attachment["name"] == desc
+ assert [%{"href" => attachment_href}] = attachment["url"]
+ assert attachment_href == object_href
+ # Fails if unauthenticated
conn
|> post("/api/ap/upload_media", %{"file" => image, "description" => desc})
|> json_response(403)