summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-10-21 10:23:10 +0200
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2021-06-04 20:06:33 +0200
commiteb7313b0d364ce6a0298d43fc86403d2e7dfc739 (patch)
treea57cd37da8af67f5b0cee53eea2762d72175d478 /test
parent7d350b73f58664eb822efaa5f522fcf2bd38f669 (diff)
Pipeline Ingestion: Page
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/tesla_mock/lemmy-page.json17
-rw-r--r--test/fixtures/tesla_mock/lemmy-user.json27
-rw-r--r--test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs (renamed from test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs)6
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/page_handling_test.exs36
4 files changed, 83 insertions, 3 deletions
diff --git a/test/fixtures/tesla_mock/lemmy-page.json b/test/fixtures/tesla_mock/lemmy-page.json
new file mode 100644
index 000000000..f07097a0e
--- /dev/null
+++ b/test/fixtures/tesla_mock/lemmy-page.json
@@ -0,0 +1,17 @@
+{
+ "commentsEnabled": true,
+ "sensitive": false,
+ "stickied": false,
+ "attributedTo": "https://enterprise.lemmy.ml/u/nutomic",
+ "summary": "Hello Federation!",
+ "url": "https://enterprise.lemmy.ml/pictrs/image/US52d9DPvf.jpg",
+ "image": {
+ "type": "Image",
+ "url": "https://enterprise.lemmy.ml/pictrs/image/lwFAcXHUjS.jpg"
+ },
+ "published": "2020-09-14T15:03:11.909105+00:00",
+ "to": "https://enterprise.lemmy.ml/c/main",
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "id": "https://enterprise.lemmy.ml/post/3",
+ "type": "Page"
+}
diff --git a/test/fixtures/tesla_mock/lemmy-user.json b/test/fixtures/tesla_mock/lemmy-user.json
new file mode 100644
index 000000000..d0e9066ac
--- /dev/null
+++ b/test/fixtures/tesla_mock/lemmy-user.json
@@ -0,0 +1,27 @@
+{
+ "publicKey": {
+ "id": "https://enterprise.lemmy.ml/u/nutomic#main-key",
+ "owner": "https://enterprise.lemmy.ml/u/nutomic",
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvfwAYPxp1gOk2HcCRoUd\nupoecvmnpzRc5Gu6/N3YQyOyRsrYuiYLNQq2cgM3kcU80ZeEetkwkYgXkRJOKu/b\nBWb7i1zt2tdr5k6lUdW8dfCyjht8ooFPQdov8J3QYHfgBHyUYxuCNfSujryxx2wu\nLQcdjRQa5NIWcomSO8OXmCF5/Yhg2XWCbtnlxEq6Y+AFddr1mAlTOy5pBr5d+xZz\njLw/U3CioNJ79yGi/sJhgp6IyJqtUSoN3b4BgRIEts2QVvn44W1rQy9wCbRYQrO1\nBcB9Wel4k3rJJK8uHg+LpHVMaZppkNaWGkMBhMbzr8qmIlcNWNi7cbMK/p5vyviy\nSwIDAQAB\n-----END PUBLIC KEY-----\n"
+ },
+ "inbox": "https://enterprise.lemmy.ml/u/nutomic/inbox",
+ "preferredUsername": "Nutomic",
+ "endpoints": {
+ "sharedInbox": "https://enterprise.lemmy.ml/inbox"
+ },
+ "summary": "some bio",
+ "icon": {
+ "type": "Image",
+ "url": "https://enterprise.lemmy.ml/pictrs/image/F6Z7QcWZRJ.jpg"
+ },
+ "image": {
+ "type": "Image",
+ "url": "https://enterprise.lemmy.ml:/pictrs/image/Q79N9oCDEG.png"
+ },
+ "published": "2020-09-14T14:54:53.080949+00:00",
+ "updated": "2020-10-14T10:58:28.139178+00:00",
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "id": "https://enterprise.lemmy.ml/u/nutomic",
+ "type": "Person",
+ "name": "nutomic"
+}
diff --git a/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs
index e408c85c3..720c17d8d 100644
--- a/test/pleroma/web/activity_pub/object_validators/article_note_validator_test.exs
+++ b/test/pleroma/web/activity_pub/object_validators/article_note_page_validator_test.exs
@@ -2,10 +2,10 @@
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNoteValidatorTest do
+defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest do
use Pleroma.DataCase, async: true
- alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNoteValidator
+ alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator
alias Pleroma.Web.ActivityPub.Utils
import Pleroma.Factory
@@ -29,7 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNoteValidatorTest do
end
test "a basic note validates", %{note: note} do
- %{valid?: true} = ArticleNoteValidator.cast_and_validate(note)
+ %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
end
end
end
diff --git a/test/pleroma/web/activity_pub/transmogrifier/page_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/page_handling_test.exs
new file mode 100644
index 000000000..4ac71e066
--- /dev/null
+++ b/test/pleroma/web/activity_pub/transmogrifier/page_handling_test.exs
@@ -0,0 +1,36 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.Transmogrifier.PageHandlingTest do
+ use Oban.Testing, repo: Pleroma.Repo
+ use Pleroma.DataCase
+
+ alias Pleroma.Object.Fetcher
+
+ test "Lemmy Page" do
+ Tesla.Mock.mock(fn
+ %{url: "https://enterprise.lemmy.ml/post/3"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/lemmy-page.json")
+ }
+
+ %{url: "https://enterprise.lemmy.ml/u/nutomic"} ->
+ %Tesla.Env{
+ status: 200,
+ headers: [{"content-type", "application/activity+json"}],
+ body: File.read!("test/fixtures/tesla_mock/lemmy-user.json")
+ }
+ end)
+
+ {:ok, object} = Fetcher.fetch_object_from_id("https://enterprise.lemmy.ml/post/3")
+
+ assert object.data["summary"] == "Hello Federation!"
+ assert object.data["published"] == "2020-09-14T15:03:11.909105Z"
+
+ # WAT
+ assert object.data["url"] == "https://enterprise.lemmy.ml/pictrs/image/US52d9DPvf.jpg"
+ end
+end