1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
6 use Pleroma.Web.ConnCase
7 use Oban.Testing, repo: Pleroma.Repo
9 import ExUnit.CaptureLog
10 import Pleroma.Factory
11 import Swoosh.TestAssertions
13 alias Pleroma.Activity
15 alias Pleroma.ModerationLog
17 alias Pleroma.Tests.ObanHelpers
19 alias Pleroma.Web.CommonAPI
22 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
28 admin = insert(:user, is_admin: true)
29 token = insert(:oauth_admin_token, user: admin)
33 |> assign(:user, admin)
34 |> assign(:token, token)
36 {:ok, %{admin: admin, token: token, conn: conn}}
39 test "with valid `admin_token` query parameter, skips OAuth scopes check" do
40 clear_config([:admin_token], "password123")
45 get(build_conn(), "/api/v1/pleroma/admin/users/#{user.nickname}?admin_token=password123")
47 assert json_response(conn, 200)
50 test "GET /api/v1/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
53 url = "/api/v1/pleroma/admin/users/#{user.nickname}"
55 good_token1 = insert(:oauth_token, user: admin, scopes: ["admin"])
56 good_token2 = insert(:oauth_token, user: admin, scopes: ["admin:read"])
57 good_token3 = insert(:oauth_token, user: admin, scopes: ["admin:read:accounts"])
59 bad_token1 = insert(:oauth_token, user: admin, scopes: ["read:accounts"])
60 bad_token2 = insert(:oauth_token, user: admin, scopes: ["admin:read:accounts:partial"])
63 for good_token <- [good_token1, good_token2, good_token3] do
66 |> assign(:user, admin)
67 |> assign(:token, good_token)
70 assert json_response(conn, 200)
73 for good_token <- [good_token1, good_token2, good_token3] do
77 |> assign(:token, good_token)
80 assert json_response(conn, :forbidden)
83 for bad_token <- [bad_token1, bad_token2, bad_token3] do
86 |> assign(:user, admin)
87 |> assign(:token, bad_token)
90 assert json_response(conn, :forbidden)
94 describe "PUT /api/v1/pleroma/admin/users/tag" do
95 setup %{conn: conn} do
96 user1 = insert(:user, %{tags: ["x"]})
97 user2 = insert(:user, %{tags: ["y"]})
98 user3 = insert(:user, %{tags: ["unchanged"]})
102 |> put_req_header("accept", "application/json")
104 "/api/v1/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
105 "#{user2.nickname}&tags[]=foo&tags[]=bar"
108 %{conn: conn, user1: user1, user2: user2, user3: user3}
111 test "it appends specified tags to users with specified nicknames", %{
117 assert empty_json_response(conn)
118 assert User.get_cached_by_id(user1.id).tags == ["x", "foo", "bar"]
119 assert User.get_cached_by_id(user2.id).tags == ["y", "foo", "bar"]
121 log_entry = Repo.one(ModerationLog)
124 [user1.nickname, user2.nickname]
125 |> Enum.map(&"@#{&1}")
128 tags = ["foo", "bar"] |> Enum.join(", ")
130 assert ModerationLog.get_log_entry_message(log_entry) ==
131 "@#{admin.nickname} added tags: #{tags} to users: #{users}"
134 test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
135 assert empty_json_response(conn)
136 assert User.get_cached_by_id(user3.id).tags == ["unchanged"]
140 describe "DELETE /api/v1/pleroma/admin/users/tag" do
141 setup %{conn: conn} do
142 user1 = insert(:user, %{tags: ["x"]})
143 user2 = insert(:user, %{tags: ["y", "z"]})
144 user3 = insert(:user, %{tags: ["unchanged"]})
148 |> put_req_header("accept", "application/json")
150 "/api/v1/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
151 "#{user2.nickname}&tags[]=x&tags[]=z"
154 %{conn: conn, user1: user1, user2: user2, user3: user3}
157 test "it removes specified tags from users with specified nicknames", %{
163 assert empty_json_response(conn)
164 assert User.get_cached_by_id(user1.id).tags == []
165 assert User.get_cached_by_id(user2.id).tags == ["y"]
167 log_entry = Repo.one(ModerationLog)
170 [user1.nickname, user2.nickname]
171 |> Enum.map(&"@#{&1}")
174 tags = ["x", "z"] |> Enum.join(", ")
176 assert ModerationLog.get_log_entry_message(log_entry) ==
177 "@#{admin.nickname} removed tags: #{tags} from users: #{users}"
180 test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
181 assert empty_json_response(conn)
182 assert User.get_cached_by_id(user3.id).tags == ["unchanged"]
186 describe "/api/v1/pleroma/admin/users/:nickname/permission_group" do
187 test "GET is giving user_info", %{admin: admin, conn: conn} do
190 |> put_req_header("accept", "application/json")
191 |> get("/api/v1/pleroma/admin/users/#{admin.nickname}/permission_group/")
193 assert json_response(conn, 200) == %{
195 "is_moderator" => false
199 test "/:right POST, can add to a permission group", %{admin: admin, conn: conn} do
204 |> put_req_header("accept", "application/json")
205 |> post("/api/v1/pleroma/admin/users/#{user.nickname}/permission_group/admin")
207 assert json_response(conn, 200) == %{
211 log_entry = Repo.one(ModerationLog)
213 assert ModerationLog.get_log_entry_message(log_entry) ==
214 "@#{admin.nickname} made @#{user.nickname} admin"
217 test "/:right POST, can add to a permission group (multiple)", %{admin: admin, conn: conn} do
218 user_one = insert(:user)
219 user_two = insert(:user)
223 |> put_req_header("accept", "application/json")
224 |> post("/api/v1/pleroma/admin/users/permission_group/admin", %{
225 nicknames: [user_one.nickname, user_two.nickname]
228 assert json_response(conn, 200) == %{"is_admin" => true}
230 log_entry = Repo.one(ModerationLog)
232 assert ModerationLog.get_log_entry_message(log_entry) ==
233 "@#{admin.nickname} made @#{user_one.nickname}, @#{user_two.nickname} admin"
236 test "/:right DELETE, can remove from a permission group", %{admin: admin, conn: conn} do
237 user = insert(:user, is_admin: true)
241 |> put_req_header("accept", "application/json")
242 |> delete("/api/v1/pleroma/admin/users/#{user.nickname}/permission_group/admin")
244 assert json_response(conn, 200) == %{"is_admin" => false}
246 log_entry = Repo.one(ModerationLog)
248 assert ModerationLog.get_log_entry_message(log_entry) ==
249 "@#{admin.nickname} revoked admin role from @#{user.nickname}"
252 test "/:right DELETE, can remove from a permission group (multiple)", %{
256 user_one = insert(:user, is_admin: true)
257 user_two = insert(:user, is_admin: true)
261 |> put_req_header("accept", "application/json")
262 |> delete("/api/v1/pleroma/admin/users/permission_group/admin", %{
263 nicknames: [user_one.nickname, user_two.nickname]
266 assert json_response(conn, 200) == %{"is_admin" => false}
268 log_entry = Repo.one(ModerationLog)
270 assert ModerationLog.get_log_entry_message(log_entry) ==
271 "@#{admin.nickname} revoked admin role from @#{user_one.nickname}, @#{user_two.nickname}"
275 test "/api/v1/pleroma/admin/users/:nickname/password_reset", %{conn: conn} do
280 |> put_req_header("accept", "application/json")
281 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/password_reset")
283 resp = json_response(conn, 200)
285 assert Regex.match?(~r/(http:\/\/|https:\/\/)/, resp["link"])
288 describe "PUT disable_mfa" do
289 test "returns 200 and disable 2fa", %{conn: conn} do
292 multi_factor_authentication_settings: %MFA.Settings{
294 totp: %MFA.Settings.TOTP{secret: "otp_secret", confirmed: true}
300 |> put("/api/v1/pleroma/admin/users/disable_mfa", %{nickname: user.nickname})
301 |> json_response(200)
303 assert response == user.nickname
304 mfa_settings = refresh_record(user).multi_factor_authentication_settings
306 refute mfa_settings.enabled
307 refute mfa_settings.totp.confirmed
310 test "returns 404 if user not found", %{conn: conn} do
313 |> put("/api/v1/pleroma/admin/users/disable_mfa", %{nickname: "nickname"})
314 |> json_response(404)
316 assert response == %{"error" => "Not found"}
320 describe "GET /api/v1/pleroma/admin/restart" do
321 setup do: clear_config(:configurable_from_database, true)
323 test "pleroma restarts", %{conn: conn} do
325 assert conn |> get("/api/v1/pleroma/admin/restart") |> json_response(200) == %{}
326 end) =~ "pleroma restarted"
328 refute Restarter.Pleroma.need_reboot?()
332 test "need_reboot flag", %{conn: conn} do
334 |> get("/api/v1/pleroma/admin/need_reboot")
335 |> json_response(200) == %{"need_reboot" => false}
337 Restarter.Pleroma.need_reboot()
340 |> get("/api/v1/pleroma/admin/need_reboot")
341 |> json_response(200) == %{"need_reboot" => true}
343 on_exit(fn -> Restarter.Pleroma.refresh() end)
346 describe "GET /api/v1/pleroma/admin/users/:nickname/statuses" do
350 insert(:note_activity, user: user)
351 insert(:note_activity, user: user)
352 insert(:note_activity, user: user)
357 test "renders user's statuses", %{conn: conn, user: user} do
358 conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/statuses")
360 assert %{"total" => 3, "activities" => activities} = json_response(conn, 200)
361 assert length(activities) == 3
364 test "renders user's statuses with pagination", %{conn: conn, user: user} do
365 %{"total" => 3, "activities" => [activity1]} =
367 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=1")
368 |> json_response(200)
370 %{"total" => 3, "activities" => [activity2]} =
372 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=2")
373 |> json_response(200)
375 refute activity1 == activity2
378 test "doesn't return private statuses by default", %{conn: conn, user: user} do
379 {:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
381 {:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
383 %{"total" => 4, "activities" => activities} =
385 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses")
386 |> json_response(200)
388 assert length(activities) == 4
391 test "returns private statuses with godmode on", %{conn: conn, user: user} do
392 {:ok, _private_status} = CommonAPI.post(user, %{status: "private", visibility: "private"})
394 {:ok, _public_status} = CommonAPI.post(user, %{status: "public", visibility: "public"})
396 %{"total" => 5, "activities" => activities} =
398 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?godmode=true")
399 |> json_response(200)
401 assert length(activities) == 5
404 test "excludes reblogs by default", %{conn: conn, user: user} do
405 other_user = insert(:user)
406 {:ok, activity} = CommonAPI.post(user, %{status: "."})
407 {:ok, %Activity{}} = CommonAPI.repeat(activity.id, other_user)
409 assert %{"total" => 0, "activities" => []} ==
411 |> get("/api/v1/pleroma/admin/users/#{other_user.nickname}/statuses")
412 |> json_response(200)
414 assert %{"total" => 1, "activities" => [_]} =
417 "/api/v1/pleroma/admin/users/#{other_user.nickname}/statuses?with_reblogs=true"
419 |> json_response(200)
423 describe "GET /api/v1/pleroma/admin/moderation_log" do
425 moderator = insert(:user, is_moderator: true)
427 %{moderator: moderator}
430 test "returns the log", %{conn: conn, admin: admin} do
431 Repo.insert(%ModerationLog{
435 "nickname" => admin.nickname,
438 action: "relay_follow",
439 target: "https://example.org/relay"
441 inserted_at: NaiveDateTime.truncate(~N[2017-08-15 15:47:06.597036], :second)
444 Repo.insert(%ModerationLog{
448 "nickname" => admin.nickname,
451 action: "relay_unfollow",
452 target: "https://example.org/relay"
454 inserted_at: NaiveDateTime.truncate(~N[2017-08-16 15:47:06.597036], :second)
457 conn = get(conn, "/api/v1/pleroma/admin/moderation_log")
459 response = json_response(conn, 200)
460 [first_entry, second_entry] = response["items"]
462 assert response["total"] == 2
463 assert first_entry["data"]["action"] == "relay_unfollow"
465 assert first_entry["message"] ==
466 "@#{admin.nickname} unfollowed relay: https://example.org/relay"
468 assert second_entry["data"]["action"] == "relay_follow"
470 assert second_entry["message"] ==
471 "@#{admin.nickname} followed relay: https://example.org/relay"
474 test "returns the log with pagination", %{conn: conn, admin: admin} do
475 Repo.insert(%ModerationLog{
479 "nickname" => admin.nickname,
482 action: "relay_follow",
483 target: "https://example.org/relay"
485 inserted_at: NaiveDateTime.truncate(~N[2017-08-15 15:47:06.597036], :second)
488 Repo.insert(%ModerationLog{
492 "nickname" => admin.nickname,
495 action: "relay_unfollow",
496 target: "https://example.org/relay"
498 inserted_at: NaiveDateTime.truncate(~N[2017-08-16 15:47:06.597036], :second)
501 conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?page_size=1&page=1")
503 response1 = json_response(conn1, 200)
504 [first_entry] = response1["items"]
506 assert response1["total"] == 2
507 assert response1["items"] |> length() == 1
508 assert first_entry["data"]["action"] == "relay_unfollow"
510 assert first_entry["message"] ==
511 "@#{admin.nickname} unfollowed relay: https://example.org/relay"
513 conn2 = get(conn, "/api/v1/pleroma/admin/moderation_log?page_size=1&page=2")
515 response2 = json_response(conn2, 200)
516 [second_entry] = response2["items"]
518 assert response2["total"] == 2
519 assert response2["items"] |> length() == 1
520 assert second_entry["data"]["action"] == "relay_follow"
522 assert second_entry["message"] ==
523 "@#{admin.nickname} followed relay: https://example.org/relay"
526 test "filters log by date", %{conn: conn, admin: admin} do
527 first_date = "2017-08-15T15:47:06Z"
528 second_date = "2017-08-20T15:47:06Z"
530 Repo.insert(%ModerationLog{
534 "nickname" => admin.nickname,
537 action: "relay_follow",
538 target: "https://example.org/relay"
540 inserted_at: NaiveDateTime.from_iso8601!(first_date)
543 Repo.insert(%ModerationLog{
547 "nickname" => admin.nickname,
550 action: "relay_unfollow",
551 target: "https://example.org/relay"
553 inserted_at: NaiveDateTime.from_iso8601!(second_date)
559 "/api/v1/pleroma/admin/moderation_log?start_date=#{second_date}"
562 response1 = json_response(conn1, 200)
563 [first_entry] = response1["items"]
565 assert response1["total"] == 1
566 assert first_entry["data"]["action"] == "relay_unfollow"
568 assert first_entry["message"] ==
569 "@#{admin.nickname} unfollowed relay: https://example.org/relay"
572 test "returns log filtered by user", %{conn: conn, admin: admin, moderator: moderator} do
573 Repo.insert(%ModerationLog{
577 "nickname" => admin.nickname,
580 action: "relay_follow",
581 target: "https://example.org/relay"
585 Repo.insert(%ModerationLog{
588 "id" => moderator.id,
589 "nickname" => moderator.nickname,
592 action: "relay_unfollow",
593 target: "https://example.org/relay"
597 conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?user_id=#{moderator.id}")
599 response1 = json_response(conn1, 200)
600 [first_entry] = response1["items"]
602 assert response1["total"] == 1
603 assert get_in(first_entry, ["data", "actor", "id"]) == moderator.id
606 test "returns log filtered by search", %{conn: conn, moderator: moderator} do
607 ModerationLog.insert_log(%{
609 action: "relay_follow",
610 target: "https://example.org/relay"
613 ModerationLog.insert_log(%{
615 action: "relay_unfollow",
616 target: "https://example.org/relay"
619 conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?search=unfo")
621 response1 = json_response(conn1, 200)
622 [first_entry] = response1["items"]
624 assert response1["total"] == 1
626 assert get_in(first_entry, ["data", "message"]) ==
627 "@#{moderator.nickname} unfollowed relay: https://example.org/relay"
631 test "gets a remote users when [:instance, :limit_to_local_content] is set to :unauthenticated",
633 clear_config(Pleroma.Config.get([:instance, :limit_to_local_content]), :unauthenticated)
634 user = insert(:user, %{local: false, nickname: "u@peer1.com"})
635 conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
637 assert json_response(conn, 200)
640 describe "GET /users/:nickname/credentials" do
641 test "gets the user credentials", %{conn: conn} do
643 conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
645 response = assert json_response(conn, 200)
646 assert response["email"] == user.email
649 test "returns 403 if requested by a non-admin" do
654 |> assign(:user, user)
655 |> get("/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
657 assert json_response(conn, :forbidden)
661 describe "PATCH /users/:nickname/credentials" do
667 test "changes password and email", %{conn: conn, admin: admin, user: user} do
668 assert user.password_reset_pending == false
671 patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
672 "password" => "new_password",
673 "email" => "new_email@example.com",
677 assert json_response(conn, 200) == %{"status" => "success"}
679 ObanHelpers.perform_all()
681 updated_user = User.get_by_id(user.id)
683 assert updated_user.email == "new_email@example.com"
684 assert updated_user.name == "new_name"
685 assert updated_user.password_hash != user.password_hash
686 assert updated_user.password_reset_pending == true
688 [log_entry2, log_entry1] = ModerationLog |> Repo.all() |> Enum.sort()
690 assert ModerationLog.get_log_entry_message(log_entry1) ==
691 "@#{admin.nickname} updated users: @#{user.nickname}"
693 assert ModerationLog.get_log_entry_message(log_entry2) ==
694 "@#{admin.nickname} forced password reset for users: @#{user.nickname}"
697 test "returns 403 if requested by a non-admin", %{user: user} do
700 |> assign(:user, user)
701 |> patch("/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
702 "password" => "new_password",
703 "email" => "new_email@example.com",
707 assert json_response(conn, :forbidden)
710 test "changes actor type from permitted list", %{conn: conn, user: user} do
711 assert user.actor_type == "Person"
713 assert patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
714 "actor_type" => "Service"
716 |> json_response(200) == %{"status" => "success"}
718 updated_user = User.get_by_id(user.id)
720 assert updated_user.actor_type == "Service"
722 assert patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
723 "actor_type" => "Application"
725 |> json_response(400) == %{"errors" => %{"actor_type" => "is invalid"}}
728 test "update non existing user", %{conn: conn} do
729 assert patch(conn, "/api/v1/pleroma/admin/users/non-existing/credentials", %{
730 "password" => "new_password"
732 |> json_response(404) == %{"error" => "Not found"}
736 describe "PATCH /users/:nickname/force_password_reset" do
737 test "sets password_reset_pending to true", %{conn: conn} do
739 assert user.password_reset_pending == false
742 patch(conn, "/api/v1/pleroma/admin/users/force_password_reset", %{
743 nicknames: [user.nickname]
746 assert empty_json_response(conn) == ""
748 ObanHelpers.perform_all()
750 assert User.get_by_id(user.id).password_reset_pending == true
754 describe "PATCH /confirm_email" do
755 test "it confirms emails of two users", %{conn: conn, admin: admin} do
756 [first_user, second_user] = insert_pair(:user, is_confirmed: false)
758 refute first_user.is_confirmed
759 refute second_user.is_confirmed
762 patch(conn, "/api/v1/pleroma/admin/users/confirm_email", %{
769 assert ret_conn.status == 200
771 first_user = User.get_by_id(first_user.id)
772 second_user = User.get_by_id(second_user.id)
774 assert first_user.is_confirmed
775 assert second_user.is_confirmed
777 log_entry = Repo.one(ModerationLog)
779 assert ModerationLog.get_log_entry_message(log_entry) ==
780 "@#{admin.nickname} confirmed email for users: @#{first_user.nickname}, @#{second_user.nickname}"
784 describe "PATCH /resend_confirmation_email" do
785 test "it resend emails for two users", %{conn: conn, admin: admin} do
786 [first_user, second_user] = insert_pair(:user, is_confirmed: false)
789 patch(conn, "/api/v1/pleroma/admin/users/resend_confirmation_email", %{
796 assert ret_conn.status == 200
798 log_entry = Repo.one(ModerationLog)
800 assert ModerationLog.get_log_entry_message(log_entry) ==
801 "@#{admin.nickname} re-sent confirmation email for users: @#{first_user.nickname}, @#{second_user.nickname}"
803 ObanHelpers.perform_all()
805 Pleroma.Emails.UserEmail.account_confirmation_email(first_user)
806 |> assert_email_sent()
810 describe "/api/v1/pleroma/admin/stats" do
811 test "status visibility count", %{conn: conn} do
813 CommonAPI.post(user, %{visibility: "public", status: "hey"})
814 CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
815 CommonAPI.post(user, %{visibility: "unlisted", status: "hey"})
819 |> get("/api/v1/pleroma/admin/stats")
820 |> json_response(200)
822 assert %{"direct" => 0, "private" => 0, "public" => 1, "unlisted" => 2} =
823 response["status_visibility"]
826 test "by instance", %{conn: conn} do
827 user1 = insert(:user)
828 instance2 = "instance2.tld"
829 user2 = insert(:user, %{ap_id: "https://#{instance2}/@actor"})
831 CommonAPI.post(user1, %{visibility: "public", status: "hey"})
832 CommonAPI.post(user2, %{visibility: "unlisted", status: "hey"})
833 CommonAPI.post(user2, %{visibility: "private", status: "hey"})
837 |> get("/api/v1/pleroma/admin/stats", instance: instance2)
838 |> json_response(200)
840 assert %{"direct" => 0, "private" => 1, "public" => 0, "unlisted" => 1} =
841 response["status_visibility"]
845 describe "/api/v1/pleroma/backups" do
846 test "it creates a backup", %{conn: conn} do
847 admin = %{id: admin_id, nickname: admin_nickname} = insert(:user, is_admin: true)
848 token = insert(:oauth_admin_token, user: admin)
849 user = %{id: user_id, nickname: user_nickname} = insert(:user)
853 |> assign(:user, admin)
854 |> assign(:token, token)
855 |> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
856 |> json_response(200)
858 assert [backup] = Repo.all(Pleroma.User.Backup)
860 ObanHelpers.perform_all()
862 email = Pleroma.Emails.UserEmail.backup_is_ready_email(backup, admin.id)
864 assert String.contains?(email.html_body, "Admin @#{admin.nickname} requested a full backup")
865 assert_email_sent(to: {user.name, user.email}, html_body: email.html_body)
867 log_message = "@#{admin_nickname} requested account backup for @#{user_nickname}"
872 "action" => "create_backup",
875 "nickname" => ^admin_nickname
877 "message" => ^log_message,
880 "nickname" => ^user_nickname
884 ] = Pleroma.ModerationLog |> Repo.all()
887 test "it doesn't limit admins", %{conn: conn} do
888 admin = insert(:user, is_admin: true)
889 token = insert(:oauth_admin_token, user: admin)
894 |> assign(:user, admin)
895 |> assign(:token, token)
896 |> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
897 |> json_response(200)
899 assert [_backup] = Repo.all(Pleroma.User.Backup)
903 |> assign(:user, admin)
904 |> assign(:token, token)
905 |> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
906 |> json_response(200)
908 assert Repo.aggregate(Pleroma.User.Backup, :count) == 2
914 defmodule Pleroma.Web.Endpoint.NotReal do
917 defmodule Pleroma.Captcha.NotReal do