tests: add regression test for locking/unlocking account updates
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 8 Jun 2018 02:28:08 +0000 (02:28 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 8 Jun 2018 02:52:34 +0000 (02:52 +0000)
test/web/activity_pub/transmogrifier_test.exs

index 38484409560e15184b37246f112ae561669b7bb3..7e771b9f8f5232c7df84abb7f68df6fcaba94d35 100644 (file)
@@ -266,6 +266,29 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert user.bio == "<p>Some bio</p>"
     end
 
+    test "it works for incoming update activities which lock the account" do
+      data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
+
+      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+      update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!()
+
+      object =
+        update_data["object"]
+        |> Map.put("actor", data["actor"])
+        |> Map.put("id", data["actor"])
+        |> Map.put("manuallyApprovesFollowers", true)
+
+      update_data =
+        update_data
+        |> Map.put("actor", data["actor"])
+        |> Map.put("object", object)
+
+      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(update_data)
+
+      user = User.get_cached_by_ap_id(data["actor"])
+      assert user.info["locked"] == true
+    end
+
     test "it works for incoming deletes" do
       activity = insert(:note_activity)