[#1260] Merge remote-tracking branch 'remotes/upstream/develop' into 1260-rate-limite...
[akkoma] / test / web / ostatus / ostatus_test.exs
index d244dbcf77a4a81ed5a3fc1c1a1064fd367c2d77..70a0e44731e72534ec0bca0bcfc384360618f995 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.OStatusTest do
@@ -199,7 +199,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert retweeted_activity.data["type"] == "Create"
     assert retweeted_activity.data["actor"] == user.ap_id
     assert retweeted_activity.local
-    assert retweeted_activity.data["object"]["announcement_count"] == 1
+    assert Object.normalize(retweeted_activity).data["announcement_count"] == 1
   end
 
   test "handle incoming retweets - Mastodon, salmon" do
@@ -326,6 +326,14 @@ defmodule Pleroma.Web.OStatusTest do
     assert User.following?(follower, followed)
   end
 
+  test "refuse following over OStatus if the followed's account is locked" do
+    incoming = File.read!("test/fixtures/follow.xml")
+    _user = insert(:user, info: %{locked: true}, ap_id: "https://pawoo.net/users/pekorino")
+
+    {:ok, [{:error, "It's not possible to follow locked accounts over OStatus"}]} =
+      OStatus.handle_incoming(incoming)
+  end
+
   test "handle incoming unfollows with existing follow" do
     incoming_follow = File.read!("test/fixtures/follow.xml")
     {:ok, [_activity]} = OStatus.handle_incoming(incoming_follow)
@@ -620,4 +628,18 @@ defmodule Pleroma.Web.OStatusTest do
       refute OStatus.is_representable?(note_activity)
     end
   end
+
+  describe "make_user/2" do
+    test "creates new user" do
+      {:ok, user} = OStatus.make_user("https://social.heldscal.la/user/23211")
+
+      created_user =
+        User
+        |> Repo.get_by(ap_id: "https://social.heldscal.la/user/23211")
+        |> Map.put(:last_digest_emailed_at, nil)
+
+      assert user.info
+      assert user == created_user
+    end
+  end
 end