summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2019-10-05 20:41:33 +0000
committerAriadne Conill <ariadne@dereferenced.org>2019-10-19 23:21:37 +0000
commitef659331b03925c41cd3e557bd39cb2d73dd6aa1 (patch)
treeb1f0e5fea52a6e1ccf817c0d85b1b6839cdeed74 /test
parent95871cb4628933900f2004a8bece1b929d5525bf (diff)
downloadpleroma-ef659331b03925c41cd3e557bd39cb2d73dd6aa1.tar.gz
pleroma-ef659331b03925c41cd3e557bd39cb2d73dd6aa1.zip
implement invisible support for remote users
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/tesla_mock/relay@mastdon.example.org.json54
-rw-r--r--test/support/http_request_mock.ex8
-rw-r--r--test/web/activity_pub/activity_pub_test.exs6
3 files changed, 68 insertions, 0 deletions
diff --git a/test/fixtures/tesla_mock/relay@mastdon.example.org.json b/test/fixtures/tesla_mock/relay@mastdon.example.org.json
new file mode 100644
index 000000000..b70be2bf4
--- /dev/null
+++ b/test/fixtures/tesla_mock/relay@mastdon.example.org.json
@@ -0,0 +1,54 @@
+{
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", {
+ "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+ "sensitive": "as:sensitive",
+ "movedTo": "as:movedTo",
+ "Hashtag": "as:Hashtag",
+ "ostatus": "http://ostatus.org#",
+ "atomUri": "ostatus:atomUri",
+ "inReplyToAtomUri": "ostatus:inReplyToAtomUri",
+ "conversation": "ostatus:conversation",
+ "toot": "http://joinmastodon.org/ns#",
+ "Emoji": "toot:Emoji"
+ }],
+ "id": "http://mastodon.example.org/users/admin",
+ "type": ["Application", "Invisible"],
+ "following": "http://mastodon.example.org/users/admin/following",
+ "followers": "http://mastodon.example.org/users/admin/followers",
+ "inbox": "http://mastodon.example.org/users/admin/inbox",
+ "outbox": "http://mastodon.example.org/users/admin/outbox",
+ "preferredUsername": "admin",
+ "name": null,
+ "summary": "\u003cp\u003e\u003c/p\u003e",
+ "url": "http://mastodon.example.org/@admin",
+ "manuallyApprovesFollowers": false,
+ "publicKey": {
+ "id": "http://mastodon.example.org/users/admin#main-key",
+ "owner": "http://mastodon.example.org/users/admin",
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtc4Tir+3ADhSNF6VKrtW\nOU32T01w7V0yshmQei38YyiVwVvFu8XOP6ACchkdxbJ+C9mZud8qWaRJKVbFTMUG\nNX4+6Q+FobyuKrwN7CEwhDALZtaN2IPbaPd6uG1B7QhWorrY+yFa8f2TBM3BxnUy\nI4T+bMIZIEYG7KtljCBoQXuTQmGtuffO0UwJksidg2ffCF5Q+K//JfQagJ3UzrR+\nZXbKMJdAw4bCVJYs4Z5EhHYBwQWiXCyMGTd7BGlmMkY6Av7ZqHKC/owp3/0EWDNz\nNqF09Wcpr3y3e8nA10X40MJqp/wR+1xtxp+YGbq/Cj5hZGBG7etFOmIpVBrDOhry\nBwIDAQAB\n-----END PUBLIC KEY-----\n"
+ },
+ "attachment": [{
+ "type": "PropertyValue",
+ "name": "foo",
+ "value": "bar"
+ },
+ {
+ "type": "PropertyValue",
+ "name": "foo1",
+ "value": "bar1"
+ }
+ ],
+ "endpoints": {
+ "sharedInbox": "http://mastodon.example.org/inbox"
+ },
+ "icon": {
+ "type": "Image",
+ "mediaType": "image/jpeg",
+ "url": "https://cdn.niu.moe/accounts/avatars/000/033/323/original/fd7f8ae0b3ffedc9.jpeg"
+ },
+ "image": {
+ "type": "Image",
+ "mediaType": "image/png",
+ "url": "https://cdn.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"
+ }
+}
diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex
index 7d65209fb..eba22c40b 100644
--- a/test/support/http_request_mock.ex
+++ b/test/support/http_request_mock.ex
@@ -348,6 +348,14 @@ defmodule HttpRequestMock do
}}
end
+ def get("http://mastodon.example.org/users/relay", _, _, Accept: "application/activity+json") do
+ {:ok,
+ %Tesla.Env{
+ status: 200,
+ body: File.read!("test/fixtures/tesla_mock/relay@mastdon.example.org.json")
+ }}
+ end
+
def get("http://mastodon.example.org/users/gargron", _, _, Accept: "application/activity+json") do
{:error, :nxdomain}
end
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 28a9b773c..b87050a4a 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -179,6 +179,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert user.follower_address == "http://mastodon.example.org/users/admin/followers"
end
+ test "it returns a user that is invisible" do
+ user_id = "http://mastodon.example.org/users/relay"
+ {:ok, user} = ActivityPub.make_user_from_ap_id(user_id)
+ assert user.info.invisible
+ end
+
test "it fetches the appropriate tag-restricted posts" do
user = insert(:user)