summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-10-25 19:14:18 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-10-25 19:14:18 +0700
commitb777083f3f396a7d8c357ec968f72679befc691c (patch)
tree4038d850ce00c5372541107537069537261ac823 /test
parent96cd66ac1bdadc0eefca6d63eb01e814690dba52 (diff)
downloadpleroma-b777083f3f396a7d8c357ec968f72679befc691c.tar.gz
pleroma-b777083f3f396a7d8c357ec968f72679befc691c.zip
Add `also_known_as` field to Pleroma.User
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/tesla_mock/admin@mastdon.example.org.json9
-rw-r--r--test/web/activity_pub/transmogrifier_test.exs31
2 files changed, 38 insertions, 2 deletions
diff --git a/test/fixtures/tesla_mock/admin@mastdon.example.org.json b/test/fixtures/tesla_mock/admin@mastdon.example.org.json
index 8159dc20a..9fdd6557c 100644
--- a/test/fixtures/tesla_mock/admin@mastdon.example.org.json
+++ b/test/fixtures/tesla_mock/admin@mastdon.example.org.json
@@ -9,7 +9,11 @@
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
"conversation": "ostatus:conversation",
"toot": "http://joinmastodon.org/ns#",
- "Emoji": "toot:Emoji"
+ "Emoji": "toot:Emoji",
+ "alsoKnownAs": {
+ "@id": "as:alsoKnownAs",
+ "@type": "@id"
+ }
}],
"id": "http://mastodon.example.org/users/admin",
"type": "Person",
@@ -50,5 +54,6 @@
"type": "Image",
"mediaType": "image/png",
"url": "https://cdn.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"
- }
+ },
+ "alsoKnownAs": ["http://example.org/users/foo"]
}
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs
index 6f7e1da1f..8fd2f5053 100644
--- a/test/web/activity_pub/transmogrifier_test.exs
+++ b/test/web/activity_pub/transmogrifier_test.exs
@@ -592,6 +592,37 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert user.bio == "<p>Some bio</p>"
end
+ test "it works with alsoKnownAs" do
+ {:ok, %Activity{data: %{"actor" => actor}}} =
+ "test/fixtures/mastodon-post-activity.json"
+ |> File.read!()
+ |> Poison.decode!()
+ |> Transmogrifier.handle_incoming()
+
+ assert User.get_cached_by_ap_id(actor).also_known_as == ["http://example.org/users/foo"]
+
+ {:ok, _activity} =
+ "test/fixtures/mastodon-update.json"
+ |> File.read!()
+ |> Poison.decode!()
+ |> Map.put("actor", actor)
+ |> Map.update!("object", fn object ->
+ object
+ |> Map.put("actor", actor)
+ |> Map.put("id", actor)
+ |> Map.put("alsoKnownAs", [
+ "http://mastodon.example.org/users/foo",
+ "http://example.org/users/bar"
+ ])
+ end)
+ |> Transmogrifier.handle_incoming()
+
+ assert User.get_cached_by_ap_id(actor).also_known_as == [
+ "http://mastodon.example.org/users/foo",
+ "http://example.org/users/bar"
+ ]
+ end
+
test "it works with custom profile fields" do
{:ok, activity} =
"test/fixtures/mastodon-post-activity.json"