Add privilige :status_delete
It also allows to update a message, so it's not just deleting. I need a better name...
This commit is contained in:
parent
34a98990db
commit
0ee8f33250
5 changed files with 54 additions and 9 deletions
|
|
@ -27,7 +27,10 @@ defmodule Pleroma.Web.AdminAPI.ChatControllerTest do
|
|||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/chats/:id/messages/:message_id" do
|
||||
setup do: admin_setup()
|
||||
setup do
|
||||
clear_config([:instance, :admin_privileges], [:status_delete])
|
||||
admin_setup()
|
||||
end
|
||||
|
||||
test "it deletes a message from the chat", %{conn: conn, admin: admin} do
|
||||
user = insert(:user)
|
||||
|
|
@ -60,6 +63,15 @@ defmodule Pleroma.Web.AdminAPI.ChatControllerTest do
|
|||
refute MessageReference.get_by_id(recipient_cm_ref.id)
|
||||
assert %{data: %{"type" => "Tombstone"}} = Object.get_by_id(object.id)
|
||||
end
|
||||
|
||||
test "it requires privileged role :status_delete", %{conn: conn} do
|
||||
clear_config([:instance, :admin_privileges], [])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/pleroma/admin/chats/some_id/messages/some_ref_id")
|
||||
|> json_response(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/chats/:id/messages" do
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
|
|||
|
||||
describe "PUT /api/pleroma/admin/statuses/:id" do
|
||||
setup do
|
||||
clear_config([:instance, :admin_privileges], [:status_delete])
|
||||
activity = insert(:note_activity)
|
||||
|
||||
%{id: activity.id}
|
||||
|
|
@ -132,10 +133,20 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
|
|||
assert %{"error" => "test - Invalid value for enum."} =
|
||||
json_response_and_validate_schema(conn, :bad_request)
|
||||
end
|
||||
|
||||
test "it requires privileged role :status_delete", %{conn: conn} do
|
||||
clear_config([:instance, :admin_privileges], [])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/some_id", %{})
|
||||
|> json_response(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/statuses/:id" do
|
||||
setup do
|
||||
clear_config([:instance, :admin_privileges], [:status_delete])
|
||||
activity = insert(:note_activity)
|
||||
|
||||
%{id: activity.id}
|
||||
|
|
@ -159,6 +170,15 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
|
|||
|
||||
assert json_response_and_validate_schema(conn, :not_found) == %{"error" => "Not found"}
|
||||
end
|
||||
|
||||
test "it requires privileged role :status_delete", %{conn: conn} do
|
||||
clear_config([:instance, :admin_privileges], [])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/pleroma/admin/statuses/some_id")
|
||||
|> json_response(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/statuses" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue