test missing first field
authorkPherox <admin@mail.kr-kp.com>
Sat, 30 Nov 2019 06:24:08 +0000 (15:24 +0900)
committerkPherox <admin@mail.kr-kp.com>
Sat, 30 Nov 2019 06:43:12 +0000 (15:43 +0900)
test/fixtures/users_mock/friendica_followers.json [new file with mode: 0644]
test/fixtures/users_mock/friendica_following.json [new file with mode: 0644]
test/support/http_request_mock.ex
test/web/activity_pub/activity_pub_test.exs

diff --git a/test/fixtures/users_mock/friendica_followers.json b/test/fixtures/users_mock/friendica_followers.json
new file mode 100644 (file)
index 0000000..7b86b5f
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "@context": [
+    "https://www.w3.org/ns/activitystreams",
+    "https://w3id.org/security/v1",
+    {
+      "vcard": "http://www.w3.org/2006/vcard/ns#",
+      "dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
+      "diaspora": "https://diasporafoundation.org/ns/",
+      "litepub": "http://litepub.social/ns#",
+      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+      "sensitive": "as:sensitive",
+      "Hashtag": "as:Hashtag",
+      "directMessage": "litepub:directMessage"
+    }
+  ],
+  "id": "http://localhost:8080/followers/fuser3",
+  "type": "OrderedCollection",
+  "totalItems": 296
+}
diff --git a/test/fixtures/users_mock/friendica_following.json b/test/fixtures/users_mock/friendica_following.json
new file mode 100644 (file)
index 0000000..7c526be
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "@context": [
+    "https://www.w3.org/ns/activitystreams",
+    "https://w3id.org/security/v1",
+    {
+      "vcard": "http://www.w3.org/2006/vcard/ns#",
+      "dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
+      "diaspora": "https://diasporafoundation.org/ns/",
+      "litepub": "http://litepub.social/ns#",
+      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
+      "sensitive": "as:sensitive",
+      "Hashtag": "as:Hashtag",
+      "directMessage": "litepub:directMessage"
+    }
+  ],
+  "id": "http://localhost:8080/following/fuser3",
+  "type": "OrderedCollection",
+  "totalItems": 32
+}
index 965335e966bed52e72b7a0d90d69e59fc6ebcb37..e3a621f49ac0fcabc08fc51cda0109d116fc1114 100644 (file)
@@ -1035,6 +1035,22 @@ defmodule HttpRequestMock do
      }}
   end
 
+  def get("http://localhost:8080/followers/fuser3", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/users_mock/friendica_followers.json")
+     }}
+  end
+
+  def get("http://localhost:8080/following/fuser3", _, _, _) do
+    {:ok,
+     %Tesla.Env{
+       status: 200,
+       body: File.read!("test/fixtures/users_mock/friendica_following.json")
+     }}
+  end
+
   def get("http://localhost:4001/users/fuser2/followers", _, _, _) do
     {:ok,
      %Tesla.Env{
index d437ad456c78a8d1c85e739748fbd321605d6021..30f5dde0cb344830cd355b60edbd6d37d0165e50 100644 (file)
@@ -1554,5 +1554,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
       assert follow_info.hide_followers == false
       assert follow_info.hide_follows == true
     end
+
+    test "detects hidden follows/followers for friendica" do
+      user =
+        insert(:user,
+          local: false,
+          follower_address: "http://localhost:8080/followers/fuser3",
+          following_address: "http://localhost:8080/following/fuser3"
+        )
+
+      {:ok, follow_info} = ActivityPub.fetch_follow_information_for_user(user)
+      assert follow_info.hide_followers == true
+      assert follow_info.follower_count == 296
+      assert follow_info.following_count == 32
+      assert follow_info.hide_follows == true
+    end
   end
 end