Merge branch 'feature/create-tombstone-instead-of-delete' into 'develop'
[akkoma] / test / web / ostatus / ostatus_test.exs
index b2f25d215a56ca654083550059ddb86182828b07..403cc7095ddb077839fc74bca266cbfab04bdce3 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.OStatusTest do
   use Pleroma.DataCase
   alias Pleroma.Web.OStatus
@@ -6,6 +10,11 @@ defmodule Pleroma.Web.OStatusTest do
   import Pleroma.Factory
   import ExUnit.CaptureLog
 
+  setup_all do
+    Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+    :ok
+  end
+
   test "don't insert create notes twice" do
     incoming = File.read!("test/fixtures/incoming_note_activity.xml")
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
@@ -329,6 +338,38 @@ defmodule Pleroma.Web.OStatusTest do
       assert user == user_again
     end
 
+    test "find_or_make_user sets all the nessary input fields" do
+      uri = "https://social.heldscal.la/user/23211"
+      {:ok, user} = OStatus.find_or_make_user(uri)
+
+      assert user.info ==
+               %Pleroma.User.Info{
+                 id: user.info.id,
+                 ap_enabled: false,
+                 background: %{},
+                 banner: %{},
+                 blocks: [],
+                 deactivated: false,
+                 default_scope: "public",
+                 domain_blocks: [],
+                 follower_count: 0,
+                 is_admin: false,
+                 is_moderator: false,
+                 keys: nil,
+                 locked: false,
+                 no_rich_text: false,
+                 note_count: 0,
+                 settings: nil,
+                 source_data: %{},
+                 hub: "https://social.heldscal.la/main/push/hub",
+                 magic_key:
+                   "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB",
+                 salmon: "https://social.heldscal.la/main/salmon/user/23211",
+                 topic: "https://social.heldscal.la/api/statuses/user_timeline/23211.atom",
+                 uri: "https://social.heldscal.la/user/23211"
+               }
+    end
+
     test "find_make_or_update_user takes an author element and returns an updated user" do
       uri = "https://social.heldscal.la/user/23211"
 
@@ -447,7 +488,7 @@ defmodule Pleroma.Web.OStatusTest do
     end
   end
 
-  test "it doesn't add nil in the do field" do
+  test "it doesn't add nil in the to field" do
     incoming = File.read!("test/fixtures/nil_mention_entry.xml")
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
 
@@ -474,7 +515,7 @@ defmodule Pleroma.Web.OStatusTest do
         |> Map.put("type", "Article")
 
       cs = Object.change(note_object, %{data: note_data})
-      {:ok, article_object} = Repo.update(cs)
+      {:ok, _article_object} = Repo.update(cs)
 
       # the underlying object is now an Article instead of a note, so this should fail
       refute OStatus.is_representable?(note_activity)