mastodon API: do not sanitize html in non-html fields
[akkoma] / test / web / activity_pub / publisher_test.exs
index df03b40087aa708036eb6568f2a58522b899e150..015af19abe5b3691d9f908f481f01a73d4daa7d6 100644 (file)
@@ -23,11 +23,32 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
     :ok
   end
 
+  describe "gather_webfinger_links/1" do
+    test "it returns links" do
+      user = insert(:user)
+
+      expected_links = [
+        %{"href" => user.ap_id, "rel" => "self", "type" => "application/activity+json"},
+        %{
+          "href" => user.ap_id,
+          "rel" => "self",
+          "type" => "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
+        },
+        %{
+          "rel" => "http://ostatus.org/schema/1.0/subscribe",
+          "template" => "#{Pleroma.Web.base_url()}/ostatus_subscribe?acct={uri}"
+        }
+      ]
+
+      assert expected_links == Publisher.gather_webfinger_links(user)
+    end
+  end
+
   describe "determine_inbox/2" do
     test "it returns sharedInbox for messages involving as:Public in to" do
       user =
         insert(:user, %{
-          info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
+          source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
         })
 
       activity = %Activity{
@@ -40,7 +61,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
     test "it returns sharedInbox for messages involving as:Public in cc" do
       user =
         insert(:user, %{
-          info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
+          source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
         })
 
       activity = %Activity{
@@ -53,7 +74,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
     test "it returns sharedInbox for messages involving multiple recipients in to" do
       user =
         insert(:user, %{
-          info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
+          source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
         })
 
       user_two = insert(:user)
@@ -69,7 +90,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
     test "it returns sharedInbox for messages involving multiple recipients in cc" do
       user =
         insert(:user, %{
-          info: %{source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}}
+          source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
         })
 
       user_two = insert(:user)
@@ -84,14 +105,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
 
     test "it returns sharedInbox for messages involving multiple recipients in total" do
       user =
-        insert(:user, %{
-          info: %{
-            source_data: %{
-              "inbox" => "http://example.com/personal-inbox",
-              "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
-            }
+        insert(:user,
+          source_data: %{
+            "inbox" => "http://example.com/personal-inbox",
+            "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
           }
-        })
+        )
 
       user_two = insert(:user)
 
@@ -104,14 +123,12 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
 
     test "it returns inbox for messages involving single recipients in total" do
       user =
-        insert(:user, %{
-          info: %{
-            source_data: %{
-              "inbox" => "http://example.com/personal-inbox",
-              "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
-            }
+        insert(:user,
+          source_data: %{
+            "inbox" => "http://example.com/personal-inbox",
+            "endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
           }
-        })
+        )
 
       activity = %Activity{
         data: %{"to" => [user.ap_id], "cc" => []}
@@ -241,10 +258,8 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
       follower =
         insert(:user,
           local: false,
-          info: %{
-            ap_enabled: true,
-            source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"}
-          }
+          source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"},
+          ap_enabled: true
         )
 
       actor = insert(:user, follower_address: follower.ap_id)
@@ -278,19 +293,15 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
       fetcher =
         insert(:user,
           local: false,
-          info: %{
-            ap_enabled: true,
-            source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"}
-          }
+          source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"},
+          ap_enabled: true
         )
 
       another_fetcher =
         insert(:user,
           local: false,
-          info: %{
-            ap_enabled: true,
-            source_data: %{"inbox" => "https://domain2.com/users/nick1/inbox"}
-          }
+          source_data: %{"inbox" => "https://domain2.com/users/nick1/inbox"},
+          ap_enabled: true
         )
 
       actor = insert(:user)