giant massive dep upgrade and dialyxir-found error emporium #371
25 changed files with 395 additions and 375 deletions
|
@ -8,11 +8,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
### Removed
|
||||
- Non-finch HTTP adapters
|
||||
### Upgrade notes
|
||||
- Ensure `config :tesla, :adapter` is either unset, or set to `{Tesla.Adapter.Finch, name: MyFinch}` in your .exs config
|
||||
- Legacy redirect from /api/pleroma/admin to /api/v1/pleroma/admin
|
||||
|
||||
### Changed
|
||||
- Return HTTP error 413 when uploading an avatar or banner that's above the configured upload limit instead of a 500.
|
||||
|
||||
### Upgrade notes
|
||||
- Ensure `config :tesla, :adapter` is either unset, or set to `{Tesla.Adapter.Finch, name: MyFinch}` in your .exs config
|
||||
|
||||
## 2022.12
|
||||
|
||||
## Added
|
||||
|
|
|
@ -209,7 +209,9 @@ def list_remote(opts) do
|
|||
|
||||
with :ok <- validate_shareable_packs_available(uri) do
|
||||
uri
|
||||
|> URI.merge("/api/pleroma/emoji/packs?page=#{opts[:page]}&page_size=#{opts[:page_size]}")
|
||||
|> URI.merge(
|
||||
"/api/v1/pleroma/emoji/packs?page=#{opts[:page]}&page_size=#{opts[:page_size]}"
|
||||
)
|
||||
|> http_get()
|
||||
end
|
||||
end
|
||||
|
@ -250,7 +252,7 @@ def download(name, url, as) do
|
|||
|
||||
with :ok <- validate_shareable_packs_available(uri),
|
||||
{:ok, remote_pack} <-
|
||||
uri |> URI.merge("/api/pleroma/emoji/pack?name=#{name}") |> http_get(),
|
||||
uri |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{name}") |> http_get(),
|
||||
{:ok, %{sha: sha, url: url} = pack_info} <- fetch_pack_info(remote_pack, uri, name),
|
||||
{:ok, archive} <- download_archive(url, sha),
|
||||
pack <- copy_as(remote_pack, as || name),
|
||||
|
@ -591,7 +593,7 @@ defp fetch_pack_info(remote_pack, uri, name) do
|
|||
{:ok,
|
||||
%{
|
||||
sha: sha,
|
||||
url: URI.merge(uri, "/api/pleroma/emoji/packs/archive?name=#{name}") |> to_string()
|
||||
url: URI.merge(uri, "/api/v1/pleroma/emoji/packs/archive?name=#{name}") |> to_string()
|
||||
}}
|
||||
|
||||
%{"fallback-src" => src, "fallback-src-sha256" => sha} when is_binary(src) ->
|
||||
|
|
|
@ -104,10 +104,10 @@ defp run_fifo(fifo_path, env, executable, args) do
|
|||
args: args
|
||||
])
|
||||
|
||||
fifo = Port.open({:spawn, to_charlist(fifo_path)}, [:eof, :binary, :stream, :out])
|
||||
fifo = File.open!(fifo_path, [:append, :binary])
|
||||
fix = Pleroma.Helpers.QtFastStart.fix(env.body)
|
||||
true = Port.command(fifo, fix)
|
||||
:erlang.port_close(fifo)
|
||||
IO.binwrite(fifo, fix)
|
||||
File.close(fifo)
|
||||
loop_recv(pid)
|
||||
after
|
||||
File.rm(fifo_path)
|
||||
|
|
|
@ -26,7 +26,7 @@ def key_id_to_actor_id(key_id) do
|
|||
{:ok, ap_id}
|
||||
|
||||
_ ->
|
||||
case Pleroma.Web.WebFinger.finger(maybe_ap_id) do
|
||||
case IO.inspect(Pleroma.Web.WebFinger.finger(maybe_ap_id), label: :fing) do
|
||||
{:ok, %{"ap_id" => ap_id}} -> {:ok, ap_id}
|
||||
_ -> {:error, maybe_ap_id}
|
||||
end
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Fallback.LegacyPleromaApiRerouterPlug do
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.Fallback.RedirectController
|
||||
|
||||
def init(opts), do: opts
|
||||
|
||||
def call(%{path_info: ["api", "pleroma" | path_info_rest]} = conn, _opts) do
|
||||
new_path_info = ["api", "v1", "pleroma" | path_info_rest]
|
||||
new_request_path = Enum.join(new_path_info, "/")
|
||||
|
||||
conn
|
||||
|> Map.merge(%{
|
||||
path_info: new_path_info,
|
||||
request_path: new_request_path
|
||||
})
|
||||
|> Endpoint.call(conn.params)
|
||||
end
|
||||
|
||||
def call(conn, _opts) do
|
||||
RedirectController.api_not_implemented(conn, %{})
|
||||
end
|
||||
end
|
|
@ -116,7 +116,7 @@ test "it deduces the actor id for gotoSocial" do
|
|||
|
||||
test "it calls webfinger for 'acct:' accounts" do
|
||||
with_mock(Pleroma.Web.WebFinger,
|
||||
finger: fn _ -> %{"ap_id" => "https://gensokyo.2hu/users/raymoo"} end
|
||||
finger: fn _ -> {:ok, %{"ap_id" => "https://gensokyo.2hu/users/raymoo"}} end
|
||||
) do
|
||||
assert Signature.key_id_to_actor_id("acct:raymoo@gensokyo.2hu") ==
|
||||
{:ok, "https://gensokyo.2hu/users/raymoo"}
|
||||
|
|
|
@ -41,15 +41,16 @@ test "with valid `admin_token` query parameter, skips OAuth scopes check" do
|
|||
|
||||
user = insert(:user)
|
||||
|
||||
conn = get(build_conn(), "/api/pleroma/admin/users/#{user.nickname}?admin_token=password123")
|
||||
conn =
|
||||
get(build_conn(), "/api/v1/pleroma/admin/users/#{user.nickname}?admin_token=password123")
|
||||
|
||||
assert json_response(conn, 200)
|
||||
end
|
||||
|
||||
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||
test "GET /api/v1/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||
%{admin: admin} do
|
||||
user = insert(:user)
|
||||
url = "/api/pleroma/admin/users/#{user.nickname}"
|
||||
url = "/api/v1/pleroma/admin/users/#{user.nickname}"
|
||||
|
||||
good_token1 = insert(:oauth_token, user: admin, scopes: ["admin"])
|
||||
good_token2 = insert(:oauth_token, user: admin, scopes: ["admin:read"])
|
||||
|
@ -90,7 +91,7 @@ test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or bro
|
|||
end
|
||||
end
|
||||
|
||||
describe "PUT /api/pleroma/admin/users/tag" do
|
||||
describe "PUT /api/v1/pleroma/admin/users/tag" do
|
||||
setup %{conn: conn} do
|
||||
user1 = insert(:user, %{tags: ["x"]})
|
||||
user2 = insert(:user, %{tags: ["y"]})
|
||||
|
@ -100,7 +101,7 @@ test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or bro
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put(
|
||||
"/api/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
|
||||
"/api/v1/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
|
||||
"#{user2.nickname}&tags[]=foo&tags[]=bar"
|
||||
)
|
||||
|
||||
|
@ -136,7 +137,7 @@ test "it does not modify tags of not specified users", %{conn: conn, user3: user
|
|||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/users/tag" do
|
||||
describe "DELETE /api/v1/pleroma/admin/users/tag" do
|
||||
setup %{conn: conn} do
|
||||
user1 = insert(:user, %{tags: ["x"]})
|
||||
user2 = insert(:user, %{tags: ["y", "z"]})
|
||||
|
@ -146,7 +147,7 @@ test "it does not modify tags of not specified users", %{conn: conn, user3: user
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> delete(
|
||||
"/api/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
|
||||
"/api/v1/pleroma/admin/users/tag?nicknames[]=#{user1.nickname}&nicknames[]=" <>
|
||||
"#{user2.nickname}&tags[]=x&tags[]=z"
|
||||
)
|
||||
|
||||
|
@ -182,12 +183,12 @@ test "it does not modify tags of not specified users", %{conn: conn, user3: user
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/users/:nickname/permission_group" do
|
||||
describe "/api/v1/pleroma/admin/users/:nickname/permission_group" do
|
||||
test "GET is giving user_info", %{admin: admin, conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> get("/api/pleroma/admin/users/#{admin.nickname}/permission_group/")
|
||||
|> get("/api/v1/pleroma/admin/users/#{admin.nickname}/permission_group/")
|
||||
|
||||
assert json_response(conn, 200) == %{
|
||||
"is_admin" => true,
|
||||
|
@ -201,7 +202,7 @@ test "/:right POST, can add to a permission group", %{admin: admin, conn: conn}
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> post("/api/pleroma/admin/users/#{user.nickname}/permission_group/admin")
|
||||
|> post("/api/v1/pleroma/admin/users/#{user.nickname}/permission_group/admin")
|
||||
|
||||
assert json_response(conn, 200) == %{
|
||||
"is_admin" => true
|
||||
|
@ -220,7 +221,7 @@ test "/:right POST, can add to a permission group (multiple)", %{admin: admin, c
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> post("/api/pleroma/admin/users/permission_group/admin", %{
|
||||
|> post("/api/v1/pleroma/admin/users/permission_group/admin", %{
|
||||
nicknames: [user_one.nickname, user_two.nickname]
|
||||
})
|
||||
|
||||
|
@ -238,7 +239,7 @@ test "/:right DELETE, can remove from a permission group", %{admin: admin, conn:
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> delete("/api/pleroma/admin/users/#{user.nickname}/permission_group/admin")
|
||||
|> delete("/api/v1/pleroma/admin/users/#{user.nickname}/permission_group/admin")
|
||||
|
||||
assert json_response(conn, 200) == %{"is_admin" => false}
|
||||
|
||||
|
@ -258,7 +259,7 @@ test "/:right DELETE, can remove from a permission group (multiple)", %{
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> delete("/api/pleroma/admin/users/permission_group/admin", %{
|
||||
|> delete("/api/v1/pleroma/admin/users/permission_group/admin", %{
|
||||
nicknames: [user_one.nickname, user_two.nickname]
|
||||
})
|
||||
|
||||
|
@ -271,13 +272,13 @@ test "/:right DELETE, can remove from a permission group (multiple)", %{
|
|||
end
|
||||
end
|
||||
|
||||
test "/api/pleroma/admin/users/:nickname/password_reset", %{conn: conn} do
|
||||
test "/api/v1/pleroma/admin/users/:nickname/password_reset", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/password_reset")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/password_reset")
|
||||
|
||||
resp = json_response(conn, 200)
|
||||
|
||||
|
@ -296,7 +297,7 @@ test "returns 200 and disable 2fa", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> put("/api/pleroma/admin/users/disable_mfa", %{nickname: user.nickname})
|
||||
|> put("/api/v1/pleroma/admin/users/disable_mfa", %{nickname: user.nickname})
|
||||
|> json_response(200)
|
||||
|
||||
assert response == user.nickname
|
||||
|
@ -309,19 +310,19 @@ test "returns 200 and disable 2fa", %{conn: conn} do
|
|||
test "returns 404 if user not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> put("/api/pleroma/admin/users/disable_mfa", %{nickname: "nickname"})
|
||||
|> put("/api/v1/pleroma/admin/users/disable_mfa", %{nickname: "nickname"})
|
||||
|> json_response(404)
|
||||
|
||||
assert response == %{"error" => "Not found"}
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/restart" do
|
||||
describe "GET /api/v1/pleroma/admin/restart" do
|
||||
setup do: clear_config(:configurable_from_database, true)
|
||||
|
||||
test "pleroma restarts", %{conn: conn} do
|
||||
capture_log(fn ->
|
||||
assert conn |> get("/api/pleroma/admin/restart") |> json_response(200) == %{}
|
||||
assert conn |> get("/api/v1/pleroma/admin/restart") |> json_response(200) == %{}
|
||||
end) =~ "pleroma restarted"
|
||||
|
||||
refute Restarter.Pleroma.need_reboot?()
|
||||
|
@ -330,19 +331,19 @@ test "pleroma restarts", %{conn: conn} do
|
|||
|
||||
test "need_reboot flag", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/admin/need_reboot")
|
||||
|> get("/api/v1/pleroma/admin/need_reboot")
|
||||
|> json_response(200) == %{"need_reboot" => false}
|
||||
|
||||
Restarter.Pleroma.need_reboot()
|
||||
|
||||
assert conn
|
||||
|> get("/api/pleroma/admin/need_reboot")
|
||||
|> get("/api/v1/pleroma/admin/need_reboot")
|
||||
|> json_response(200) == %{"need_reboot" => true}
|
||||
|
||||
on_exit(fn -> Restarter.Pleroma.refresh() end)
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/users/:nickname/statuses" do
|
||||
describe "GET /api/v1/pleroma/admin/users/:nickname/statuses" do
|
||||
setup do
|
||||
user = insert(:user)
|
||||
|
||||
|
@ -354,7 +355,7 @@ test "need_reboot flag", %{conn: conn} do
|
|||
end
|
||||
|
||||
test "renders user's statuses", %{conn: conn, user: user} do
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/statuses")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/statuses")
|
||||
|
||||
assert %{"total" => 3, "activities" => activities} = json_response(conn, 200)
|
||||
assert length(activities) == 3
|
||||
|
@ -363,12 +364,12 @@ test "renders user's statuses", %{conn: conn, user: user} do
|
|||
test "renders user's statuses with pagination", %{conn: conn, user: user} do
|
||||
%{"total" => 3, "activities" => [activity1]} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=1")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=1")
|
||||
|> json_response(200)
|
||||
|
||||
%{"total" => 3, "activities" => [activity2]} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=2")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?page_size=1&page=2")
|
||||
|> json_response(200)
|
||||
|
||||
refute activity1 == activity2
|
||||
|
@ -381,7 +382,7 @@ test "doesn't return private statuses by default", %{conn: conn, user: user} do
|
|||
|
||||
%{"total" => 4, "activities" => activities} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/statuses")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses")
|
||||
|> json_response(200)
|
||||
|
||||
assert length(activities) == 4
|
||||
|
@ -394,7 +395,7 @@ test "returns private statuses with godmode on", %{conn: conn, user: user} do
|
|||
|
||||
%{"total" => 5, "activities" => activities} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/statuses?godmode=true")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/statuses?godmode=true")
|
||||
|> json_response(200)
|
||||
|
||||
assert length(activities) == 5
|
||||
|
@ -407,19 +408,19 @@ test "excludes reblogs by default", %{conn: conn, user: user} do
|
|||
|
||||
assert %{"total" => 0, "activities" => []} ==
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users/#{other_user.nickname}/statuses")
|
||||
|> get("/api/v1/pleroma/admin/users/#{other_user.nickname}/statuses")
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"total" => 1, "activities" => [_]} =
|
||||
conn
|
||||
|> get(
|
||||
"/api/pleroma/admin/users/#{other_user.nickname}/statuses?with_reblogs=true"
|
||||
"/api/v1/pleroma/admin/users/#{other_user.nickname}/statuses?with_reblogs=true"
|
||||
)
|
||||
|> json_response(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/moderation_log" do
|
||||
describe "GET /api/v1/pleroma/admin/moderation_log" do
|
||||
setup do
|
||||
moderator = insert(:user, is_moderator: true)
|
||||
|
||||
|
@ -453,7 +454,7 @@ test "returns the log", %{conn: conn, admin: admin} do
|
|||
inserted_at: NaiveDateTime.truncate(~N[2017-08-16 15:47:06.597036], :second)
|
||||
})
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/moderation_log")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/moderation_log")
|
||||
|
||||
response = json_response(conn, 200)
|
||||
[first_entry, second_entry] = response["items"]
|
||||
|
@ -497,7 +498,7 @@ test "returns the log with pagination", %{conn: conn, admin: admin} do
|
|||
inserted_at: NaiveDateTime.truncate(~N[2017-08-16 15:47:06.597036], :second)
|
||||
})
|
||||
|
||||
conn1 = get(conn, "/api/pleroma/admin/moderation_log?page_size=1&page=1")
|
||||
conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?page_size=1&page=1")
|
||||
|
||||
response1 = json_response(conn1, 200)
|
||||
[first_entry] = response1["items"]
|
||||
|
@ -509,7 +510,7 @@ test "returns the log with pagination", %{conn: conn, admin: admin} do
|
|||
assert first_entry["message"] ==
|
||||
"@#{admin.nickname} unfollowed relay: https://example.org/relay"
|
||||
|
||||
conn2 = get(conn, "/api/pleroma/admin/moderation_log?page_size=1&page=2")
|
||||
conn2 = get(conn, "/api/v1/pleroma/admin/moderation_log?page_size=1&page=2")
|
||||
|
||||
response2 = json_response(conn2, 200)
|
||||
[second_entry] = response2["items"]
|
||||
|
@ -555,7 +556,7 @@ test "filters log by date", %{conn: conn, admin: admin} do
|
|||
conn1 =
|
||||
get(
|
||||
conn,
|
||||
"/api/pleroma/admin/moderation_log?start_date=#{second_date}"
|
||||
"/api/v1/pleroma/admin/moderation_log?start_date=#{second_date}"
|
||||
)
|
||||
|
||||
response1 = json_response(conn1, 200)
|
||||
|
@ -593,7 +594,7 @@ test "returns log filtered by user", %{conn: conn, admin: admin, moderator: mode
|
|||
}
|
||||
})
|
||||
|
||||
conn1 = get(conn, "/api/pleroma/admin/moderation_log?user_id=#{moderator.id}")
|
||||
conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?user_id=#{moderator.id}")
|
||||
|
||||
response1 = json_response(conn1, 200)
|
||||
[first_entry] = response1["items"]
|
||||
|
@ -615,7 +616,7 @@ test "returns log filtered by search", %{conn: conn, moderator: moderator} do
|
|||
target: "https://example.org/relay"
|
||||
})
|
||||
|
||||
conn1 = get(conn, "/api/pleroma/admin/moderation_log?search=unfo")
|
||||
conn1 = get(conn, "/api/v1/pleroma/admin/moderation_log?search=unfo")
|
||||
|
||||
response1 = json_response(conn1, 200)
|
||||
[first_entry] = response1["items"]
|
||||
|
@ -631,7 +632,7 @@ test "gets a remote users when [:instance, :limit_to_local_content] is set to :u
|
|||
%{conn: conn} do
|
||||
clear_config(Pleroma.Config.get([:instance, :limit_to_local_content]), :unauthenticated)
|
||||
user = insert(:user, %{local: false, nickname: "u@peer1.com"})
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|
||||
assert json_response(conn, 200)
|
||||
end
|
||||
|
@ -639,7 +640,7 @@ test "gets a remote users when [:instance, :limit_to_local_content] is set to :u
|
|||
describe "GET /users/:nickname/credentials" do
|
||||
test "gets the user credentials", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|
||||
response = assert json_response(conn, 200)
|
||||
assert response["email"] == user.email
|
||||
|
@ -651,7 +652,7 @@ test "returns 403 if requested by a non-admin" do
|
|||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> get("/api/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|> get("/api/v1/pleroma/admin/users/#{user.nickname}/credentials")
|
||||
|
||||
assert json_response(conn, :forbidden)
|
||||
end
|
||||
|
@ -667,7 +668,7 @@ test "changes password and email", %{conn: conn, admin: admin, user: user} do
|
|||
assert user.password_reset_pending == false
|
||||
|
||||
conn =
|
||||
patch(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"password" => "new_password",
|
||||
"email" => "new_email@example.com",
|
||||
"name" => "new_name"
|
||||
|
@ -697,7 +698,7 @@ test "returns 403 if requested by a non-admin", %{user: user} do
|
|||
conn =
|
||||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> patch("/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
|> patch("/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"password" => "new_password",
|
||||
"email" => "new_email@example.com",
|
||||
"name" => "new_name"
|
||||
|
@ -709,7 +710,7 @@ test "returns 403 if requested by a non-admin", %{user: user} do
|
|||
test "changes actor type from permitted list", %{conn: conn, user: user} do
|
||||
assert user.actor_type == "Person"
|
||||
|
||||
assert patch(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
assert patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"actor_type" => "Service"
|
||||
})
|
||||
|> json_response(200) == %{"status" => "success"}
|
||||
|
@ -718,14 +719,14 @@ test "changes actor type from permitted list", %{conn: conn, user: user} do
|
|||
|
||||
assert updated_user.actor_type == "Service"
|
||||
|
||||
assert patch(conn, "/api/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
assert patch(conn, "/api/v1/pleroma/admin/users/#{user.nickname}/credentials", %{
|
||||
"actor_type" => "Application"
|
||||
})
|
||||
|> json_response(400) == %{"errors" => %{"actor_type" => "is invalid"}}
|
||||
end
|
||||
|
||||
test "update non existing user", %{conn: conn} do
|
||||
assert patch(conn, "/api/pleroma/admin/users/non-existing/credentials", %{
|
||||
assert patch(conn, "/api/v1/pleroma/admin/users/non-existing/credentials", %{
|
||||
"password" => "new_password"
|
||||
})
|
||||
|> json_response(404) == %{"error" => "Not found"}
|
||||
|
@ -738,7 +739,9 @@ test "sets password_reset_pending to true", %{conn: conn} do
|
|||
assert user.password_reset_pending == false
|
||||
|
||||
conn =
|
||||
patch(conn, "/api/pleroma/admin/users/force_password_reset", %{nicknames: [user.nickname]})
|
||||
patch(conn, "/api/v1/pleroma/admin/users/force_password_reset", %{
|
||||
nicknames: [user.nickname]
|
||||
})
|
||||
|
||||
assert empty_json_response(conn) == ""
|
||||
|
||||
|
@ -756,7 +759,7 @@ test "it confirms emails of two users", %{conn: conn, admin: admin} do
|
|||
refute second_user.is_confirmed
|
||||
|
||||
ret_conn =
|
||||
patch(conn, "/api/pleroma/admin/users/confirm_email", %{
|
||||
patch(conn, "/api/v1/pleroma/admin/users/confirm_email", %{
|
||||
nicknames: [
|
||||
first_user.nickname,
|
||||
second_user.nickname
|
||||
|
@ -783,7 +786,7 @@ test "it resend emails for two users", %{conn: conn, admin: admin} do
|
|||
[first_user, second_user] = insert_pair(:user, is_confirmed: false)
|
||||
|
||||
ret_conn =
|
||||
patch(conn, "/api/pleroma/admin/users/resend_confirmation_email", %{
|
||||
patch(conn, "/api/v1/pleroma/admin/users/resend_confirmation_email", %{
|
||||
nicknames: [
|
||||
first_user.nickname,
|
||||
second_user.nickname
|
||||
|
@ -804,7 +807,7 @@ test "it resend emails for two users", %{conn: conn, admin: admin} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/stats" do
|
||||
describe "/api/v1/pleroma/admin/stats" do
|
||||
test "status visibility count", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
CommonAPI.post(user, %{visibility: "public", status: "hey"})
|
||||
|
@ -813,7 +816,7 @@ test "status visibility count", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/stats")
|
||||
|> get("/api/v1/pleroma/admin/stats")
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"direct" => 0, "private" => 0, "public" => 1, "unlisted" => 2} =
|
||||
|
@ -831,7 +834,7 @@ test "by instance", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/stats", instance: instance2)
|
||||
|> get("/api/v1/pleroma/admin/stats", instance: instance2)
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"direct" => 0, "private" => 1, "public" => 0, "unlisted" => 1} =
|
||||
|
@ -839,7 +842,7 @@ test "by instance", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/backups" do
|
||||
describe "/api/v1/pleroma/backups" do
|
||||
test "it creates a backup", %{conn: conn} do
|
||||
admin = %{id: admin_id, nickname: admin_nickname} = insert(:user, is_admin: true)
|
||||
token = insert(:oauth_admin_token, user: admin)
|
||||
|
@ -849,7 +852,7 @@ test "it creates a backup", %{conn: conn} do
|
|||
conn
|
||||
|> assign(:user, admin)
|
||||
|> assign(:token, token)
|
||||
|> post("/api/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> json_response(200)
|
||||
|
||||
assert [backup] = Repo.all(Pleroma.User.Backup)
|
||||
|
@ -890,7 +893,7 @@ test "it doesn't limit admins", %{conn: conn} do
|
|||
conn
|
||||
|> assign(:user, admin)
|
||||
|> assign(:token, token)
|
||||
|> post("/api/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> json_response(200)
|
||||
|
||||
assert [_backup] = Repo.all(Pleroma.User.Backup)
|
||||
|
@ -899,7 +902,7 @@ test "it doesn't limit admins", %{conn: conn} do
|
|||
conn
|
||||
|> assign(:user, admin)
|
||||
|> assign(:token, token)
|
||||
|> post("/api/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> post("/api/v1/pleroma/admin/backups", %{nickname: user.nickname})
|
||||
|> json_response(200)
|
||||
|
||||
assert Repo.aggregate(Pleroma.User.Backup, :count) == 2
|
||||
|
|
|
@ -30,11 +30,11 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/frontends" do
|
||||
describe "GET /api/v1/pleroma/admin/frontends" do
|
||||
test "it lists available frontends", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/frontends")
|
||||
|> get("/api/v1/pleroma/admin/frontends")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert Enum.map(response, & &1["name"]) ==
|
||||
|
@ -48,7 +48,7 @@ test "it lists available frontends when no frontend folder was created yet", %{c
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/frontends")
|
||||
|> get("/api/v1/pleroma/admin/frontends")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert Enum.map(response, & &1["name"]) ==
|
||||
|
@ -58,7 +58,7 @@ test "it lists available frontends when no frontend folder was created yet", %{c
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/frontends/install" do
|
||||
describe "POST /api/v1/pleroma/admin/frontends/install" do
|
||||
test "from available frontends", %{conn: conn} do
|
||||
clear_config([:frontends, :available], %{
|
||||
"pleroma" => %{
|
||||
|
@ -74,14 +74,14 @@ test "from available frontends", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/frontends/install", %{name: "pleroma"})
|
||||
|> post("/api/v1/pleroma/admin/frontends/install", %{name: "pleroma"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/frontends")
|
||||
|> get("/api/v1/pleroma/admin/frontends")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response == [
|
||||
|
@ -106,7 +106,7 @@ test "from a file", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/frontends/install", %{
|
||||
|> post("/api/v1/pleroma/admin/frontends/install", %{
|
||||
name: "pleroma",
|
||||
file: "test/fixtures/tesla_mock/frontend.zip"
|
||||
})
|
||||
|
@ -122,7 +122,7 @@ test "from an URL", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/frontends/install", %{
|
||||
|> post("/api/v1/pleroma/admin/frontends/install", %{
|
||||
name: "unknown",
|
||||
ref: "baka",
|
||||
build_url: "http://gensokyo.2hu/madeup.zip",
|
||||
|
@ -141,7 +141,7 @@ test "failing returns an error", %{conn: conn} do
|
|||
result =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/frontends/install", %{
|
||||
|> post("/api/v1/pleroma/admin/frontends/install", %{
|
||||
name: "unknown",
|
||||
ref: "baka",
|
||||
build_url: "http://gensokyo.2hu/madeup.zip",
|
||||
|
|
|
@ -37,26 +37,28 @@ test "GET /instances/:instance/statuses", %{conn: conn} do
|
|||
activity = insert(:note_activity, user: user2)
|
||||
|
||||
%{"total" => 2, "activities" => activities} =
|
||||
conn |> get("/api/pleroma/admin/instances/archae.me/statuses") |> json_response(200)
|
||||
conn |> get("/api/v1/pleroma/admin/instances/archae.me/statuses") |> json_response(200)
|
||||
|
||||
assert length(activities) == 2
|
||||
|
||||
%{"total" => 1, "activities" => [_]} =
|
||||
conn |> get("/api/pleroma/admin/instances/test.com/statuses") |> json_response(200)
|
||||
conn |> get("/api/v1/pleroma/admin/instances/test.com/statuses") |> json_response(200)
|
||||
|
||||
%{"total" => 0, "activities" => []} =
|
||||
conn |> get("/api/pleroma/admin/instances/nonexistent.com/statuses") |> json_response(200)
|
||||
conn
|
||||
|> get("/api/v1/pleroma/admin/instances/nonexistent.com/statuses")
|
||||
|> json_response(200)
|
||||
|
||||
CommonAPI.repeat(activity.id, user)
|
||||
|
||||
%{"total" => 2, "activities" => activities} =
|
||||
conn |> get("/api/pleroma/admin/instances/archae.me/statuses") |> json_response(200)
|
||||
conn |> get("/api/v1/pleroma/admin/instances/archae.me/statuses") |> json_response(200)
|
||||
|
||||
assert length(activities) == 2
|
||||
|
||||
%{"total" => 3, "activities" => activities} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/instances/archae.me/statuses?with_reblogs=true")
|
||||
|> get("/api/v1/pleroma/admin/instances/archae.me/statuses?with_reblogs=true")
|
||||
|> json_response(200)
|
||||
|
||||
assert length(activities) == 3
|
||||
|
@ -68,7 +70,7 @@ test "DELETE /instances/:instance", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/instances/lain.com")
|
||||
|> delete("/api/v1/pleroma/admin/instances/lain.com")
|
||||
|> json_response(200)
|
||||
|
||||
[:ok] = ObanHelpers.perform_all()
|
||||
|
|
|
@ -28,9 +28,9 @@ defmodule Pleroma.Web.AdminAPI.InstanceDocumentControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/instance_document/:name" do
|
||||
describe "GET /api/v1/pleroma/admin/instance_document/:name" do
|
||||
test "return the instance document url", %{conn: conn} do
|
||||
conn = get(conn, "/api/pleroma/admin/instance_document/instance-panel")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/instance_document/instance-panel")
|
||||
|
||||
assert content = html_response(conn, 200)
|
||||
assert String.contains?(content, @default_instance_panel)
|
||||
|
@ -44,7 +44,7 @@ test "it returns 403 if requested by a non-admin" do
|
|||
build_conn()
|
||||
|> assign(:user, non_admin_user)
|
||||
|> assign(:token, token)
|
||||
|> get("/api/pleroma/admin/instance_document/instance-panel")
|
||||
|> get("/api/v1/pleroma/admin/instance_document/instance-panel")
|
||||
|
||||
assert json_response(conn, :forbidden)
|
||||
end
|
||||
|
@ -52,13 +52,13 @@ test "it returns 403 if requested by a non-admin" do
|
|||
test "it returns 404 if the instance document with the given name doesn't exist", %{
|
||||
conn: conn
|
||||
} do
|
||||
conn = get(conn, "/api/pleroma/admin/instance_document/1234")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/instance_document/1234")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 404)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/pleroma/admin/instance_document/:name" do
|
||||
describe "PATCH /api/v1/pleroma/admin/instance_document/:name" do
|
||||
test "uploads the instance document", %{conn: conn} do
|
||||
image = %Plug.Upload{
|
||||
content_type: "text/html",
|
||||
|
@ -69,7 +69,7 @@ test "uploads the instance document", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/admin/instance_document/instance-panel", %{
|
||||
|> patch("/api/v1/pleroma/admin/instance_document/instance-panel", %{
|
||||
"file" => image
|
||||
})
|
||||
|
||||
|
@ -79,24 +79,24 @@ test "uploads the instance document", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/instance_document/:name" do
|
||||
describe "DELETE /api/v1/pleroma/admin/instance_document/:name" do
|
||||
test "deletes the instance document", %{conn: conn} do
|
||||
File.mkdir!(@dir <> "/instance/")
|
||||
File.write!(@dir <> "/instance/panel.html", "Custom instance panel")
|
||||
|
||||
conn_resp =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/instance_document/instance-panel")
|
||||
|> get("/api/v1/pleroma/admin/instance_document/instance-panel")
|
||||
|
||||
assert html_response(conn_resp, 200) == "Custom instance panel"
|
||||
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/instance_document/instance-panel")
|
||||
|> delete("/api/v1/pleroma/admin/instance_document/instance-panel")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
conn_resp =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/instance_document/instance-panel")
|
||||
|> get("/api/v1/pleroma/admin/instance_document/instance-panel")
|
||||
|
||||
assert content = html_response(conn_resp, 200)
|
||||
assert String.contains?(content, @default_instance_panel)
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule Pleroma.Web.AdminAPI.InviteControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/email_invite, with valid config" do
|
||||
describe "POST /api/v1/pleroma/admin/users/email_invite, with valid config" do
|
||||
setup do: clear_config([:instance, :registrations_open], false)
|
||||
setup do: clear_config([:instance, :invites_enabled], true)
|
||||
|
||||
|
@ -33,7 +33,7 @@ test "sends invitation and returns 204", %{admin: admin, conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json;charset=utf-8")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{
|
||||
|> post("/api/v1/pleroma/admin/users/email_invite", %{
|
||||
email: recipient_email,
|
||||
name: recipient_name
|
||||
})
|
||||
|
@ -71,7 +71,7 @@ test "it returns 403 if requested by a non-admin" do
|
|||
|> assign(:user, non_admin_user)
|
||||
|> assign(:token, token)
|
||||
|> put_req_header("content-type", "application/json;charset=utf-8")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{
|
||||
|> post("/api/v1/pleroma/admin/users/email_invite", %{
|
||||
email: "foo@bar.com",
|
||||
name: "JD"
|
||||
})
|
||||
|
@ -84,7 +84,7 @@ test "email with +", %{conn: conn, admin: admin} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json;charset=utf-8")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{email: recipient_email})
|
||||
|> post("/api/v1/pleroma/admin/users/email_invite", %{email: recipient_email})
|
||||
|> json_response_and_validate_schema(:no_content)
|
||||
|
||||
token_record =
|
||||
|
@ -113,7 +113,7 @@ test "email with +", %{conn: conn, admin: admin} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/email_invite, with invalid config" do
|
||||
describe "POST /api/v1/pleroma/admin/users/email_invite, with invalid config" do
|
||||
setup do: clear_config([:instance, :registrations_open])
|
||||
setup do: clear_config([:instance, :invites_enabled])
|
||||
|
||||
|
@ -124,7 +124,7 @@ test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{
|
||||
|> post("/api/v1/pleroma/admin/users/email_invite", %{
|
||||
email: "foo@bar.com",
|
||||
name: "JD"
|
||||
})
|
||||
|
@ -143,7 +143,7 @@ test "it returns 500 if `registrations_open` is enabled", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{
|
||||
|> post("/api/v1/pleroma/admin/users/email_invite", %{
|
||||
email: "foo@bar.com",
|
||||
name: "JD"
|
||||
})
|
||||
|
@ -156,12 +156,12 @@ test "it returns 500 if `registrations_open` is enabled", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/invite_token" do
|
||||
describe "POST /api/v1/pleroma/admin/users/invite_token" do
|
||||
test "without options", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/invite_token")
|
||||
|> post("/api/v1/pleroma/admin/users/invite_token")
|
||||
|
||||
invite_json = json_response_and_validate_schema(conn, 200)
|
||||
invite = UserInviteToken.find_by_token!(invite_json["token"])
|
||||
|
@ -175,7 +175,7 @@ test "with expires_at", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/invite_token", %{
|
||||
|> post("/api/v1/pleroma/admin/users/invite_token", %{
|
||||
"expires_at" => Date.to_string(Date.utc_today())
|
||||
})
|
||||
|
||||
|
@ -192,7 +192,7 @@ test "with max_use", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/invite_token", %{"max_use" => 150})
|
||||
|> post("/api/v1/pleroma/admin/users/invite_token", %{"max_use" => 150})
|
||||
|
||||
invite_json = json_response_and_validate_schema(conn, 200)
|
||||
invite = UserInviteToken.find_by_token!(invite_json["token"])
|
||||
|
@ -206,7 +206,7 @@ test "with max use and expires_at", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/invite_token", %{
|
||||
|> post("/api/v1/pleroma/admin/users/invite_token", %{
|
||||
"max_use" => 150,
|
||||
"expires_at" => Date.to_string(Date.utc_today())
|
||||
})
|
||||
|
@ -220,9 +220,9 @@ test "with max use and expires_at", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/users/invites" do
|
||||
describe "GET /api/v1/pleroma/admin/users/invites" do
|
||||
test "no invites", %{conn: conn} do
|
||||
conn = get(conn, "/api/pleroma/admin/users/invites")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/invites")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{"invites" => []}
|
||||
end
|
||||
|
@ -230,7 +230,7 @@ test "no invites", %{conn: conn} do
|
|||
test "with invite", %{conn: conn} do
|
||||
{:ok, invite} = UserInviteToken.create_invite()
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users/invites")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/invites")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"invites" => [
|
||||
|
@ -248,14 +248,14 @@ test "with invite", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/revoke_invite" do
|
||||
describe "POST /api/v1/pleroma/admin/users/revoke_invite" do
|
||||
test "with token", %{conn: conn} do
|
||||
{:ok, invite} = UserInviteToken.create_invite()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/revoke_invite", %{"token" => invite.token})
|
||||
|> post("/api/v1/pleroma/admin/users/revoke_invite", %{"token" => invite.token})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"expires_at" => nil,
|
||||
|
@ -272,7 +272,7 @@ test "with invalid token", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/revoke_invite", %{"token" => "foo"})
|
||||
|> post("/api/v1/pleroma/admin/users/revoke_invite", %{"token" => "foo"})
|
||||
|
||||
assert json_response_and_validate_schema(conn, :not_found) == %{"error" => "Not found"}
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/media_proxy_caches" do
|
||||
describe "GET /api/v1/pleroma/admin/media_proxy_caches" do
|
||||
test "shows banned MediaProxy URLs", %{conn: conn} do
|
||||
MediaProxy.put_in_banned_urls([
|
||||
"http://localhost:4001/media/a688346.jpg",
|
||||
|
@ -41,7 +41,7 @@ test "shows banned MediaProxy URLs", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2")
|
||||
|> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["page_size"] == 2
|
||||
|
@ -51,7 +51,7 @@ test "shows banned MediaProxy URLs", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=2")
|
||||
|> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&page=2")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["page_size"] == 2
|
||||
|
@ -61,7 +61,7 @@ test "shows banned MediaProxy URLs", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=3")
|
||||
|> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&page=3")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
results = results ++ response["urls"]
|
||||
|
@ -89,7 +89,7 @@ test "search banned MediaProxy URLs", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/media_proxy_caches?page_size=2&query=F44")
|
||||
|> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&query=F44")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["urls"] |> Enum.sort() == [
|
||||
|
@ -102,7 +102,7 @@ test "search banned MediaProxy URLs", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/media_proxy_caches/delete" do
|
||||
describe "POST /api/v1/pleroma/admin/media_proxy_caches/delete" do
|
||||
test "deleted MediaProxy URLs from banned", %{conn: conn} do
|
||||
MediaProxy.put_in_banned_urls([
|
||||
"http://localhost:4001/media/a688346.jpg",
|
||||
|
@ -111,7 +111,7 @@ test "deleted MediaProxy URLs from banned", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/media_proxy_caches/delete", %{
|
||||
|> post("/api/v1/pleroma/admin/media_proxy_caches/delete", %{
|
||||
urls: ["http://localhost:4001/media/a688346.jpg"]
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
@ -121,7 +121,7 @@ test "deleted MediaProxy URLs from banned", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/media_proxy_caches/purge" do
|
||||
describe "POST /api/v1/pleroma/admin/media_proxy_caches/purge" do
|
||||
test "perform invalidates cache of MediaProxy", %{conn: conn} do
|
||||
urls = [
|
||||
"http://example.com/media/a688346.jpg",
|
||||
|
@ -136,7 +136,7 @@ test "perform invalidates cache of MediaProxy", %{conn: conn} do
|
|||
] do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/media_proxy_caches/purge", %{urls: urls, ban: false})
|
||||
|> post("/api/v1/pleroma/admin/media_proxy_caches/purge", %{urls: urls, ban: false})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
refute MediaProxy.in_banned_urls("http://example.com/media/a688346.jpg")
|
||||
|
@ -154,7 +154,7 @@ test "perform invalidates cache of MediaProxy and adds url to banned", %{conn: c
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post(
|
||||
"/api/pleroma/admin/media_proxy_caches/purge",
|
||||
"/api/v1/pleroma/admin/media_proxy_caches/purge",
|
||||
%{urls: urls, ban: true}
|
||||
)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
|
|
@ -22,12 +22,12 @@ defmodule Pleroma.Web.AdminAPI.OAuthAppControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/oauth_app" do
|
||||
describe "POST /api/v1/pleroma/admin/oauth_app" do
|
||||
test "errors", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/oauth_app", %{})
|
||||
|> post("/api/v1/pleroma/admin/oauth_app", %{})
|
||||
|> json_response_and_validate_schema(400)
|
||||
|
||||
assert %{
|
||||
|
@ -42,7 +42,7 @@ test "success", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/oauth_app", %{
|
||||
|> post("/api/v1/pleroma/admin/oauth_app", %{
|
||||
name: app_name,
|
||||
redirect_uris: base_url
|
||||
})
|
||||
|
@ -64,7 +64,7 @@ test "with trusted", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/oauth_app", %{
|
||||
|> post("/api/v1/pleroma/admin/oauth_app", %{
|
||||
name: app_name,
|
||||
redirect_uris: base_url,
|
||||
trusted: true
|
||||
|
@ -81,7 +81,7 @@ test "with trusted", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/oauth_app" do
|
||||
describe "GET /api/v1/pleroma/admin/oauth_app" do
|
||||
setup do
|
||||
app = insert(:oauth_app)
|
||||
{:ok, app: app}
|
||||
|
@ -90,7 +90,7 @@ test "with trusted", %{conn: conn} do
|
|||
test "list", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app")
|
||||
|> get("/api/v1/pleroma/admin/oauth_app")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"apps" => apps, "count" => count, "page_size" => _} = response
|
||||
|
@ -104,7 +104,7 @@ test "with page size", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app?page_size=#{page_size}")
|
||||
|> get("/api/v1/pleroma/admin/oauth_app?page_size=#{page_size}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"apps" => apps, "count" => _, "page_size" => ^page_size} = response
|
||||
|
@ -115,7 +115,7 @@ test "with page size", %{conn: conn} do
|
|||
test "search by client name", %{conn: conn, app: app} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app?name=#{app.client_name}")
|
||||
|> get("/api/v1/pleroma/admin/oauth_app?name=#{app.client_name}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
@ -127,7 +127,7 @@ test "search by client name", %{conn: conn, app: app} do
|
|||
test "search by client id", %{conn: conn, app: app} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app?client_id=#{app.client_id}")
|
||||
|> get("/api/v1/pleroma/admin/oauth_app?client_id=#{app.client_id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
@ -141,7 +141,7 @@ test "only trusted", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app?trusted=true")
|
||||
|> get("/api/v1/pleroma/admin/oauth_app?trusted=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
@ -151,13 +151,13 @@ test "only trusted", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/oauth_app/:id" do
|
||||
describe "DELETE /api/v1/pleroma/admin/oauth_app/:id" do
|
||||
test "with id", %{conn: conn} do
|
||||
app = insert(:oauth_app)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/oauth_app/" <> to_string(app.id))
|
||||
|> delete("/api/v1/pleroma/admin/oauth_app/" <> to_string(app.id))
|
||||
|> json_response_and_validate_schema(:no_content)
|
||||
|
||||
assert response == ""
|
||||
|
@ -166,14 +166,14 @@ test "with id", %{conn: conn} do
|
|||
test "with non existance id", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/oauth_app/0")
|
||||
|> delete("/api/v1/pleroma/admin/oauth_app/0")
|
||||
|> json_response_and_validate_schema(:bad_request)
|
||||
|
||||
assert response == ""
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/pleroma/admin/oauth_app/:id" do
|
||||
describe "PATCH /api/v1/pleroma/admin/oauth_app/:id" do
|
||||
test "with id", %{conn: conn} do
|
||||
app = insert(:oauth_app)
|
||||
|
||||
|
@ -186,7 +186,7 @@ test "with id", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/oauth_app/#{id}", %{
|
||||
|> patch("/api/v1/pleroma/admin/oauth_app/#{id}", %{
|
||||
name: name,
|
||||
trusted: true,
|
||||
redirect_uris: url,
|
||||
|
@ -210,7 +210,7 @@ test "without id", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/oauth_app/0")
|
||||
|> patch("/api/v1/pleroma/admin/oauth_app/0")
|
||||
|> json_response_and_validate_schema(:bad_request)
|
||||
|
||||
assert response == ""
|
||||
|
|
|
@ -34,7 +34,7 @@ test "POST /relay", %{conn: conn, admin: admin} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/relay", %{
|
||||
|> post("/api/v1/pleroma/admin/relay", %{
|
||||
relay_url: "http://mastodon.example.org/users/admin"
|
||||
})
|
||||
|
||||
|
@ -58,7 +58,7 @@ test "GET /relay", %{conn: conn} do
|
|||
User.follow(relay_user, user)
|
||||
end)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/relay")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/relay")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200)["relays"] |> Enum.sort() == [
|
||||
%{
|
||||
|
@ -72,14 +72,14 @@ test "GET /relay", %{conn: conn} do
|
|||
test "DELETE /relay", %{conn: conn, admin: admin} do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/relay", %{
|
||||
|> post("/api/v1/pleroma/admin/relay", %{
|
||||
relay_url: "http://mastodon.example.org/users/admin"
|
||||
})
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/pleroma/admin/relay", %{
|
||||
|> delete("/api/v1/pleroma/admin/relay", %{
|
||||
relay_url: "http://mastodon.example.org/users/admin"
|
||||
})
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/reports/:id" do
|
||||
describe "GET /api/v1/pleroma/admin/reports/:id" do
|
||||
test "returns report by its id", %{conn: conn} do
|
||||
[reporter, target_user] = insert_pair(:user)
|
||||
activity = insert(:note_activity, user: target_user)
|
||||
|
@ -39,13 +39,13 @@ test "returns report by its id", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
|> post("/api/v1/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
content: "this is an admin note"
|
||||
})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/reports/#{report_id}")
|
||||
|> get("/api/v1/pleroma/admin/reports/#{report_id}")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response["id"] == report_id
|
||||
|
@ -55,13 +55,13 @@ test "returns report by its id", %{conn: conn} do
|
|||
end
|
||||
|
||||
test "returns 404 when report id is invalid", %{conn: conn} do
|
||||
conn = get(conn, "/api/pleroma/admin/reports/test")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/reports/test")
|
||||
|
||||
assert json_response_and_validate_schema(conn, :not_found) == %{"error" => "Not found"}
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/pleroma/admin/reports" do
|
||||
describe "PATCH /api/v1/pleroma/admin/reports" do
|
||||
setup do
|
||||
[reporter, target_user] = insert_pair(:user)
|
||||
activity = insert(:note_activity, user: target_user)
|
||||
|
@ -94,7 +94,7 @@ test "requires admin:write:reports scope", %{conn: conn, id: id, admin: admin} d
|
|||
conn
|
||||
|> assign(:token, read_token)
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [%{"state" => "resolved", "id" => id}]
|
||||
})
|
||||
|> json_response_and_validate_schema(403)
|
||||
|
@ -106,7 +106,7 @@ test "requires admin:write:reports scope", %{conn: conn, id: id, admin: admin} d
|
|||
conn
|
||||
|> assign(:token, write_token)
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [%{"state" => "resolved", "id" => id}]
|
||||
})
|
||||
|> json_response_and_validate_schema(:no_content)
|
||||
|
@ -115,7 +115,7 @@ test "requires admin:write:reports scope", %{conn: conn, id: id, admin: admin} d
|
|||
test "mark report as resolved", %{conn: conn, id: id, admin: admin} do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [
|
||||
%{"state" => "resolved", "id" => id}
|
||||
]
|
||||
|
@ -134,7 +134,7 @@ test "mark report as resolved", %{conn: conn, id: id, admin: admin} do
|
|||
test "closes report", %{conn: conn, id: id, admin: admin} do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [
|
||||
%{"state" => "closed", "id" => id}
|
||||
]
|
||||
|
@ -154,7 +154,7 @@ test "returns 400 when state is unknown", %{conn: conn, id: id} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [
|
||||
%{"state" => "test", "id" => id}
|
||||
]
|
||||
|
@ -168,7 +168,7 @@ test "returns 404 when report is not exist", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [
|
||||
%{"state" => "closed", "id" => "test"}
|
||||
]
|
||||
|
@ -185,7 +185,7 @@ test "updates state of multiple reports", %{
|
|||
} do
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/reports", %{
|
||||
|> patch("/api/v1/pleroma/admin/reports", %{
|
||||
"reports" => [
|
||||
%{"state" => "resolved", "id" => id},
|
||||
%{"state" => "closed", "id" => second_report_id}
|
||||
|
@ -208,7 +208,7 @@ test "updates state of multiple reports", %{
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/reports" do
|
||||
describe "GET /api/v1/pleroma/admin/reports" do
|
||||
test "returns empty response when no reports created", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|
@ -300,14 +300,14 @@ test "returns 403 when requested by a non-admin" do
|
|||
build_conn()
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, token)
|
||||
|> get("/api/pleroma/admin/reports")
|
||||
|> get("/api/v1/pleroma/admin/reports")
|
||||
|
||||
assert json_response(conn, :forbidden) ==
|
||||
%{"error" => "User is not a staff member."}
|
||||
end
|
||||
|
||||
test "returns 403 when requested by anonymous" do
|
||||
conn = get(build_conn(), "/api/pleroma/admin/reports")
|
||||
conn = get(build_conn(), "/api/v1/pleroma/admin/reports")
|
||||
|
||||
assert json_response(conn, :forbidden) == %{
|
||||
"error" => "Invalid credentials."
|
||||
|
@ -315,7 +315,7 @@ test "returns 403 when requested by anonymous" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/reports/:id/notes" do
|
||||
describe "POST /api/v1/pleroma/admin/reports/:id/notes" do
|
||||
setup %{conn: conn, admin: admin} do
|
||||
[reporter, target_user] = insert_pair(:user)
|
||||
activity = insert(:note_activity, user: target_user)
|
||||
|
@ -329,13 +329,13 @@ test "returns 403 when requested by anonymous" do
|
|||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
|> post("/api/v1/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
content: "this is disgusting!"
|
||||
})
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
|> post("/api/v1/pleroma/admin/reports/#{report_id}/notes", %{
|
||||
content: "this is disgusting2!"
|
||||
})
|
||||
|
||||
|
@ -356,7 +356,7 @@ test "it creates report note", %{admin_id: admin_id, report_id: report_id} do
|
|||
end
|
||||
|
||||
test "it returns reports with notes", %{conn: conn, admin: admin} do
|
||||
conn = get(conn, "/api/pleroma/admin/reports")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/reports")
|
||||
|
||||
response = json_response_and_validate_schema(conn, 200)
|
||||
notes = hd(response["reports"])["notes"]
|
||||
|
@ -379,7 +379,7 @@ test "it deletes the note", %{conn: conn, report_id: report_id} do
|
|||
assert ReportNote |> Repo.all() |> length() == 2
|
||||
assert [note, _] = Repo.all(ReportNote)
|
||||
|
||||
delete(conn, "/api/pleroma/admin/reports/#{report_id}/notes/#{note.id}")
|
||||
delete(conn, "/api/v1/pleroma/admin/reports/#{report_id}/notes/#{note.id}")
|
||||
|
||||
assert ReportNote |> Repo.all() |> length() == 1
|
||||
end
|
||||
|
|
|
@ -25,10 +25,10 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
|
|||
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/statuses/:id" do
|
||||
describe "GET /api/v1/pleroma/admin/statuses/:id" do
|
||||
test "not found", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/admin/statuses/not_found")
|
||||
|> get("/api/v1/pleroma/admin/statuses/not_found")
|
||||
|> json_response_and_validate_schema(:not_found)
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ test "shows activity", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/statuses/#{activity.id}")
|
||||
|> get("/api/v1/pleroma/admin/statuses/#{activity.id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["id"] == activity.id
|
||||
|
@ -52,7 +52,7 @@ test "shows activity", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "PUT /api/pleroma/admin/statuses/:id" do
|
||||
describe "PUT /api/v1/pleroma/admin/statuses/:id" do
|
||||
setup do
|
||||
activity = insert(:note_activity)
|
||||
|
||||
|
@ -63,7 +63,7 @@ test "toggle sensitive flag", %{conn: conn, id: id, admin: admin} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{"sensitive" => "true"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{"sensitive" => "true"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response["sensitive"]
|
||||
|
@ -76,7 +76,7 @@ test "toggle sensitive flag", %{conn: conn, id: id, admin: admin} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{"sensitive" => "false"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{"sensitive" => "false"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
refute response["sensitive"]
|
||||
|
@ -86,7 +86,7 @@ test "change visibility flag", %{conn: conn, id: id, admin: admin} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "public"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{visibility: "public"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response["visibility"] == "public"
|
||||
|
@ -99,7 +99,7 @@ test "change visibility flag", %{conn: conn, id: id, admin: admin} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "private"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{visibility: "private"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response["visibility"] == "private"
|
||||
|
@ -107,7 +107,7 @@ test "change visibility flag", %{conn: conn, id: id, admin: admin} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "unlisted"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{visibility: "unlisted"})
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
assert response["visibility"] == "unlisted"
|
||||
|
@ -117,14 +117,14 @@ test "returns 400 when visibility is unknown", %{conn: conn, id: id} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> put("/api/pleroma/admin/statuses/#{id}", %{visibility: "test"})
|
||||
|> put("/api/v1/pleroma/admin/statuses/#{id}", %{visibility: "test"})
|
||||
|
||||
assert %{"error" => "test - Invalid value for enum."} =
|
||||
json_response_and_validate_schema(conn, :bad_request)
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/statuses/:id" do
|
||||
describe "DELETE /api/v1/pleroma/admin/statuses/:id" do
|
||||
setup do
|
||||
activity = insert(:note_activity)
|
||||
|
||||
|
@ -133,7 +133,7 @@ test "returns 400 when visibility is unknown", %{conn: conn, id: id} do
|
|||
|
||||
test "deletes status", %{conn: conn, id: id, admin: admin} do
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/statuses/#{id}")
|
||||
|> delete("/api/v1/pleroma/admin/statuses/#{id}")
|
||||
|> json_response_and_validate_schema(:ok)
|
||||
|
||||
refute Activity.get_by_id(id)
|
||||
|
@ -145,13 +145,13 @@ test "deletes status", %{conn: conn, id: id, admin: admin} do
|
|||
end
|
||||
|
||||
test "returns 404 when the status does not exist", %{conn: conn} do
|
||||
conn = delete(conn, "/api/pleroma/admin/statuses/test")
|
||||
conn = delete(conn, "/api/v1/pleroma/admin/statuses/test")
|
||||
|
||||
assert json_response_and_validate_schema(conn, :not_found) == %{"error" => "Not found"}
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/statuses" do
|
||||
describe "GET /api/v1/pleroma/admin/statuses" do
|
||||
test "returns all public and unlisted statuses", %{conn: conn, admin: admin} do
|
||||
blocked = insert(:user)
|
||||
user = insert(:user)
|
||||
|
@ -166,7 +166,7 @@ test "returns all public and unlisted statuses", %{conn: conn, admin: admin} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/statuses")
|
||||
|> get("/api/v1/pleroma/admin/statuses")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
refute "private" in Enum.map(response, & &1["visibility"])
|
||||
|
@ -181,7 +181,7 @@ test "returns only local statuses with local_only on", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/statuses?local_only=true")
|
||||
|> get("/api/v1/pleroma/admin/statuses?local_only=true")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert length(response) == 1
|
||||
|
@ -194,7 +194,7 @@ test "returns private and direct statuses with godmode on", %{conn: conn, admin:
|
|||
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "private"})
|
||||
{:ok, _} = CommonAPI.post(user, %{status: ".", visibility: "public"})
|
||||
conn = get(conn, "/api/pleroma/admin/statuses?godmode=true")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/statuses?godmode=true")
|
||||
assert json_response_and_validate_schema(conn, 200) |> length() == 3
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,15 +42,16 @@ test "with valid `admin_token` query parameter, skips OAuth scopes check" do
|
|||
|
||||
user = insert(:user)
|
||||
|
||||
conn = get(build_conn(), "/api/pleroma/admin/users/#{user.nickname}?admin_token=password123")
|
||||
conn =
|
||||
get(build_conn(), "/api/v1/pleroma/admin/users/#{user.nickname}?admin_token=password123")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||
test "GET /api/v1/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
|
||||
%{admin: admin} do
|
||||
user = insert(:user)
|
||||
url = "/api/pleroma/admin/users/#{user.nickname}"
|
||||
url = "/api/v1/pleroma/admin/users/#{user.nickname}"
|
||||
|
||||
good_token1 = insert(:oauth_token, user: admin, scopes: ["admin"])
|
||||
good_token2 = insert(:oauth_token, user: admin, scopes: ["admin:read"])
|
||||
|
@ -91,7 +92,7 @@ test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or bro
|
|||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/users" do
|
||||
describe "DELETE /api/v1/pleroma/admin/users" do
|
||||
test "single user", %{admin: admin, conn: conn} do
|
||||
clear_config([:instance, :federating], true)
|
||||
|
||||
|
@ -120,7 +121,7 @@ test "single user", %{admin: admin, conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> delete("/api/pleroma/admin/users?nickname=#{user.nickname}")
|
||||
|> delete("/api/v1/pleroma/admin/users?nickname=#{user.nickname}")
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
|
@ -156,7 +157,7 @@ test "multiple users", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/pleroma/admin/users", %{
|
||||
|> delete("/api/v1/pleroma/admin/users", %{
|
||||
nicknames: [user_one.nickname, user_two.nickname]
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
@ -170,13 +171,13 @@ test "multiple users", %{admin: admin, conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/users" do
|
||||
describe "/api/v1/pleroma/admin/users" do
|
||||
test "Create", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users", %{
|
||||
|> post("/api/v1/pleroma/admin/users", %{
|
||||
"users" => [
|
||||
%{
|
||||
"nickname" => "lain",
|
||||
|
@ -207,7 +208,7 @@ test "Cannot create user with existing email", %{conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users", %{
|
||||
|> post("/api/v1/pleroma/admin/users", %{
|
||||
"users" => [
|
||||
%{
|
||||
"nickname" => "lain",
|
||||
|
@ -237,7 +238,7 @@ test "Cannot create user with existing nickname", %{conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users", %{
|
||||
|> post("/api/v1/pleroma/admin/users", %{
|
||||
"users" => [
|
||||
%{
|
||||
"nickname" => user.nickname,
|
||||
|
@ -267,7 +268,7 @@ test "Multiple user creation works in transaction", %{conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users", %{
|
||||
|> post("/api/v1/pleroma/admin/users", %{
|
||||
"users" => [
|
||||
%{
|
||||
"nickname" => "newuser",
|
||||
|
@ -307,11 +308,11 @@ test "Multiple user creation works in transaction", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/users/:nickname" do
|
||||
describe "/api/v1/pleroma/admin/users/:nickname" do
|
||||
test "Show", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}")
|
||||
|
||||
assert user_response(user) == json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
@ -319,13 +320,13 @@ test "Show", %{conn: conn} do
|
|||
test "when the user doesn't exist", %{conn: conn} do
|
||||
user = build(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users/#{user.nickname}")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users/#{user.nickname}")
|
||||
|
||||
assert %{"error" => "Not found"} == json_response_and_validate_schema(conn, 404)
|
||||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/users/follow" do
|
||||
describe "/api/v1/pleroma/admin/users/follow" do
|
||||
test "allows to force-follow another user", %{admin: admin, conn: conn} do
|
||||
user = insert(:user)
|
||||
follower = insert(:user)
|
||||
|
@ -333,7 +334,7 @@ test "allows to force-follow another user", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/follow", %{
|
||||
|> post("/api/v1/pleroma/admin/users/follow", %{
|
||||
"follower" => follower.nickname,
|
||||
"followed" => user.nickname
|
||||
})
|
||||
|
@ -350,7 +351,7 @@ test "allows to force-follow another user", %{admin: admin, conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/admin/users/unfollow" do
|
||||
describe "/api/v1/pleroma/admin/users/unfollow" do
|
||||
test "allows to force-unfollow another user", %{admin: admin, conn: conn} do
|
||||
user = insert(:user)
|
||||
follower = insert(:user)
|
||||
|
@ -360,7 +361,7 @@ test "allows to force-unfollow another user", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("accept", "application/json")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/users/unfollow", %{
|
||||
|> post("/api/v1/pleroma/admin/users/unfollow", %{
|
||||
"follower" => follower.nickname,
|
||||
"followed" => user.nickname
|
||||
})
|
||||
|
@ -377,12 +378,12 @@ test "allows to force-unfollow another user", %{admin: admin, conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/users" do
|
||||
describe "GET /api/v1/pleroma/admin/users" do
|
||||
test "renders users array for the first page", %{conn: conn, admin: admin} do
|
||||
user = insert(:user, local: false, tags: ["foo", "bar"])
|
||||
user2 = insert(:user, is_approved: false, registration_reason: "I'm a chill dude")
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?page=1")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?page=1")
|
||||
|
||||
users = [
|
||||
user_response(
|
||||
|
@ -415,7 +416,7 @@ test "pagination works correctly with service users", %{conn: conn} do
|
|||
|
||||
assert %{"count" => 26, "page_size" => 10, "users" => users1} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users?page=1&filters=", %{page_size: "10"})
|
||||
|> get("/api/v1/pleroma/admin/users?page=1&filters=", %{page_size: "10"})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert Enum.count(users1) == 10
|
||||
|
@ -423,7 +424,7 @@ test "pagination works correctly with service users", %{conn: conn} do
|
|||
|
||||
assert %{"count" => 26, "page_size" => 10, "users" => users2} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users?page=2&filters=", %{page_size: "10"})
|
||||
|> get("/api/v1/pleroma/admin/users?page=2&filters=", %{page_size: "10"})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert Enum.count(users2) == 10
|
||||
|
@ -431,7 +432,7 @@ test "pagination works correctly with service users", %{conn: conn} do
|
|||
|
||||
assert %{"count" => 26, "page_size" => 10, "users" => users3} =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users?page=3&filters=", %{page_size: "10"})
|
||||
|> get("/api/v1/pleroma/admin/users?page=3&filters=", %{page_size: "10"})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert Enum.count(users3) == 6
|
||||
|
@ -441,7 +442,7 @@ test "pagination works correctly with service users", %{conn: conn} do
|
|||
test "renders empty array for the second page", %{conn: conn} do
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?page=2")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?page=2")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 2,
|
||||
|
@ -453,7 +454,7 @@ test "renders empty array for the second page", %{conn: conn} do
|
|||
test "regular search", %{conn: conn} do
|
||||
user = insert(:user, nickname: "bob")
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?query=bo")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?query=bo")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -466,7 +467,7 @@ test "search by domain", %{conn: conn} do
|
|||
user = insert(:user, nickname: "nickname@domain.com")
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?query=domain.com")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?query=domain.com")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -479,7 +480,7 @@ test "search by full nickname", %{conn: conn} do
|
|||
user = insert(:user, nickname: "nickname@domain.com")
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?query=nickname@domain.com")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?query=nickname@domain.com")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -492,7 +493,7 @@ test "search by display name", %{conn: conn} do
|
|||
user = insert(:user, name: "Display name")
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?name=display")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?name=display")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -505,7 +506,7 @@ test "search by email", %{conn: conn} do
|
|||
user = insert(:user, email: "email@example.com")
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?email=email@example.com")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?email=email@example.com")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -518,7 +519,7 @@ test "regular search with page size", %{conn: conn} do
|
|||
user = insert(:user, nickname: "aalice")
|
||||
user2 = insert(:user, nickname: "alice")
|
||||
|
||||
conn1 = get(conn, "/api/pleroma/admin/users?query=a&page_size=1&page=1")
|
||||
conn1 = get(conn, "/api/v1/pleroma/admin/users?query=a&page_size=1&page=1")
|
||||
|
||||
assert json_response_and_validate_schema(conn1, 200) == %{
|
||||
"count" => 2,
|
||||
|
@ -526,7 +527,7 @@ test "regular search with page size", %{conn: conn} do
|
|||
"users" => [user_response(user2)]
|
||||
}
|
||||
|
||||
conn2 = get(conn, "/api/pleroma/admin/users?query=a&page_size=1&page=2")
|
||||
conn2 = get(conn, "/api/v1/pleroma/admin/users?query=a&page_size=1&page=2")
|
||||
|
||||
assert json_response_and_validate_schema(conn2, 200) == %{
|
||||
"count" => 2,
|
||||
|
@ -546,7 +547,7 @@ test "only local users" do
|
|||
build_conn()
|
||||
|> assign(:user, admin)
|
||||
|> assign(:token, token)
|
||||
|> get("/api/pleroma/admin/users?query=bo&filters=local")
|
||||
|> get("/api/v1/pleroma/admin/users?query=bo&filters=local")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -561,7 +562,7 @@ test "only local users with no query", %{conn: conn, admin: old_admin} do
|
|||
|
||||
insert(:user, nickname: "bobb", local: false)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?filters=local")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?filters=local")
|
||||
|
||||
users = [
|
||||
user_response(user),
|
||||
|
@ -590,7 +591,7 @@ test "only unconfirmed users", %{conn: conn} do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/users?filters=unconfirmed")
|
||||
|> get("/api/v1/pleroma/admin/users?filters=unconfirmed")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
users =
|
||||
|
@ -614,7 +615,7 @@ test "only unapproved users", %{conn: conn} do
|
|||
|
||||
insert(:user, nickname: "happyboy", is_approved: true)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?filters=need_approval")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?filters=need_approval")
|
||||
|
||||
users = [
|
||||
user_response(
|
||||
|
@ -635,7 +636,7 @@ test "load only admins", %{conn: conn, admin: admin} do
|
|||
insert(:user)
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?filters=is_admin")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?filters=is_admin")
|
||||
|
||||
users = [
|
||||
user_response(second_admin, %{
|
||||
|
@ -660,7 +661,7 @@ test "load only moderators", %{conn: conn} do
|
|||
insert(:user)
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?filters=is_moderator")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?filters=is_moderator")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -739,7 +740,7 @@ test "load users with tags list", %{conn: conn} do
|
|||
insert(:user)
|
||||
insert(:user)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?tags[]=first&tags[]=second")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users?tags[]=first&tags[]=second")
|
||||
|
||||
users = [
|
||||
user_response(user2, %{"tags" => ["second"]}),
|
||||
|
@ -762,7 +763,7 @@ test "`active` filters out users pending approval", %{token: token} do
|
|||
build_conn()
|
||||
|> assign(:user, token.user)
|
||||
|> assign(:token, token)
|
||||
|> get("/api/pleroma/admin/users?filters=active")
|
||||
|> get("/api/v1/pleroma/admin/users?filters=active")
|
||||
|
||||
assert %{
|
||||
"count" => 2,
|
||||
|
@ -786,7 +787,7 @@ test "it works with multiple filters" do
|
|||
build_conn()
|
||||
|> assign(:user, admin)
|
||||
|> assign(:token, token)
|
||||
|> get("/api/pleroma/admin/users?filters=deactivated,external")
|
||||
|> get("/api/v1/pleroma/admin/users?filters=deactivated,external")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -798,7 +799,7 @@ test "it works with multiple filters" do
|
|||
test "it omits relay user", %{admin: admin, conn: conn} do
|
||||
assert %User{} = Relay.get_actor()
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users")
|
||||
conn = get(conn, "/api/v1/pleroma/admin/users")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"count" => 1,
|
||||
|
@ -810,7 +811,7 @@ test "it omits relay user", %{admin: admin, conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
|
||||
user_one = insert(:user, is_active: false)
|
||||
user_two = insert(:user, is_active: false)
|
||||
|
||||
|
@ -818,7 +819,7 @@ test "PATCH /api/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch(
|
||||
"/api/pleroma/admin/users/activate",
|
||||
"/api/v1/pleroma/admin/users/activate",
|
||||
%{nicknames: [user_one.nickname, user_two.nickname]}
|
||||
)
|
||||
|
||||
|
@ -831,7 +832,7 @@ test "PATCH /api/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
|
|||
"@#{admin.nickname} activated users: @#{user_one.nickname}, @#{user_two.nickname}"
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
|
||||
user_one = insert(:user, is_active: true)
|
||||
user_two = insert(:user, is_active: true)
|
||||
|
||||
|
@ -839,7 +840,7 @@ test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch(
|
||||
"/api/pleroma/admin/users/deactivate",
|
||||
"/api/v1/pleroma/admin/users/deactivate",
|
||||
%{nicknames: [user_one.nickname, user_two.nickname]}
|
||||
)
|
||||
|
||||
|
@ -852,7 +853,7 @@ test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
|
|||
"@#{admin.nickname} deactivated users: @#{user_one.nickname}, @#{user_two.nickname}"
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
|
||||
user_one = insert(:user, is_approved: false)
|
||||
user_two = insert(:user, is_approved: false)
|
||||
|
||||
|
@ -860,7 +861,7 @@ test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch(
|
||||
"/api/pleroma/admin/users/approve",
|
||||
"/api/v1/pleroma/admin/users/approve",
|
||||
%{nicknames: [user_one.nickname, user_two.nickname]}
|
||||
)
|
||||
|
||||
|
@ -873,7 +874,7 @@ test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
|
|||
"@#{admin.nickname} approved users: @#{user_one.nickname}, @#{user_two.nickname}"
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
||||
user1 = insert(:user, is_suggested: false)
|
||||
user2 = insert(:user, is_suggested: false)
|
||||
|
||||
|
@ -881,7 +882,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch(
|
||||
"/api/pleroma/admin/users/suggest",
|
||||
"/api/v1/pleroma/admin/users/suggest",
|
||||
%{nicknames: [user1.nickname, user2.nickname]}
|
||||
)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
@ -898,7 +899,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
|||
"@#{admin.nickname} added suggested users: @#{user1.nickname}, @#{user2.nickname}"
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
|
||||
user1 = insert(:user, is_suggested: true)
|
||||
user2 = insert(:user, is_suggested: true)
|
||||
|
||||
|
@ -906,7 +907,7 @@ test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
|
|||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch(
|
||||
"/api/pleroma/admin/users/unsuggest",
|
||||
"/api/v1/pleroma/admin/users/unsuggest",
|
||||
%{nicknames: [user1.nickname, user2.nickname]}
|
||||
)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
@ -923,13 +924,16 @@ test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
|
|||
"@#{admin.nickname} removed suggested users: @#{user1.nickname}, @#{user2.nickname}"
|
||||
end
|
||||
|
||||
test "PATCH /api/pleroma/admin/users/:nickname/toggle_activation", %{admin: admin, conn: conn} do
|
||||
test "PATCH /api/v1/pleroma/admin/users/:nickname/toggle_activation", %{
|
||||
admin: admin,
|
||||
conn: conn
|
||||
} do
|
||||
user = insert(:user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> patch("/api/pleroma/admin/users/#{user.nickname}/toggle_activation")
|
||||
|> patch("/api/v1/pleroma/admin/users/#{user.nickname}/toggle_activation")
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) ==
|
||||
user_response(
|
||||
|
|
|
@ -72,12 +72,6 @@ test "GET /main/all", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
test "GET /api*path", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/foo")
|
||||
|> json_response(404) == %{"error" => "Not implemented"}
|
||||
end
|
||||
|
||||
test "GET /pleroma/admin -> /pleroma/admin/", %{conn: conn} do
|
||||
assert redirected_to(get(conn, "/pleroma/admin")) =~ "/pleroma/admin/"
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ test "posting a status does not increment reblog_count when relaying", %{conn: c
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"content_type" => "text/plain",
|
||||
"source" => "Pleroma FE",
|
||||
"status" => "Hello world",
|
||||
|
@ -51,7 +51,7 @@ test "posting a status does not increment reblog_count when relaying", %{conn: c
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("api/v1/statuses/#{response["id"]}", %{})
|
||||
|> get("/api/v1/statuses/#{response["id"]}", %{})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert response["reblogs_count"] == 0
|
||||
|
@ -110,7 +110,7 @@ test "posting a status", %{conn: conn} do
|
|||
conn_four =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "oolong",
|
||||
"expires_in" => expires_in
|
||||
})
|
||||
|
@ -133,7 +133,7 @@ test "automatically setting a post expiry if status_ttl_days is set" do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "aa chikichiki banban"
|
||||
})
|
||||
|
||||
|
@ -164,7 +164,7 @@ test "it fails to create a status if `expires_in` is less or equal than an hour"
|
|||
assert %{"error" => "Expiry date is too soon"} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "oolong",
|
||||
"expires_in" => expires_in
|
||||
})
|
||||
|
@ -176,7 +176,7 @@ test "it fails to create a status if `expires_in` is less or equal than an hour"
|
|||
assert %{"error" => "Expiry date is too soon"} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "oolong",
|
||||
"expires_in" => expires_in
|
||||
})
|
||||
|
@ -190,7 +190,7 @@ test "Get MRF reason when posting a status is rejected by one", %{conn: conn} do
|
|||
assert %{"error" => "[KeywordPolicy] Matches with rejected keyword"} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{"status" => "GNO/Linux"})
|
||||
|> post("/api/v1/statuses", %{"status" => "GNO/Linux"})
|
||||
|> json_response_and_validate_schema(422)
|
||||
end
|
||||
|
||||
|
@ -383,7 +383,7 @@ test "posting a direct status", %{conn: conn} do
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{"status" => content, "visibility" => "direct"})
|
||||
|> post("/api/v1/statuses", %{"status" => content, "visibility" => "direct"})
|
||||
|
||||
assert %{"id" => id} = response = json_response_and_validate_schema(conn, 200)
|
||||
assert response["visibility"] == "direct"
|
||||
|
@ -420,7 +420,7 @@ test "discloses application metadata when enabled" do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> get("api/v1/statuses/#{activity}")
|
||||
|> get("/api/v1/statuses/#{activity}")
|
||||
|
||||
assert %{
|
||||
"content" => "cofe is my copilot",
|
||||
|
@ -449,7 +449,7 @@ test "hides application metadata when disabled" do
|
|||
|
||||
result =
|
||||
conn
|
||||
|> get("api/v1/statuses/#{activity}")
|
||||
|> get("/api/v1/statuses/#{activity}")
|
||||
|
||||
assert %{
|
||||
"content" => "club mate is my wingman",
|
||||
|
@ -1342,7 +1342,7 @@ test "on pin removes deletion job, on unpin reschedule deletion" do
|
|||
assert %{"id" => id} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("api/v1/statuses", %{
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "oolong",
|
||||
"expires_in" => expires_in
|
||||
})
|
||||
|
@ -1511,7 +1511,7 @@ test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{c
|
|||
conn
|
||||
|> assign(:user, user3)
|
||||
|> assign(:token, insert(:oauth_token, user: user3, scopes: ["read:statuses"]))
|
||||
|> get("api/v1/timelines/home")
|
||||
|> get("/api/v1/timelines/home")
|
||||
|
||||
[reblogged_activity] = json_response_and_validate_schema(conn3, 200)
|
||||
|
||||
|
|
|
@ -539,7 +539,7 @@ test "direct timeline", %{conn: conn} do
|
|||
build_conn()
|
||||
|> assign(:user, user_one)
|
||||
|> assign(:token, insert(:oauth_token, user: user_one, scopes: ["read:statuses"]))
|
||||
|> get("api/v1/timelines/direct")
|
||||
|> get("/api/v1/timelines/direct")
|
||||
|
||||
[status] = json_response_and_validate_schema(res_conn, :ok)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
|
|||
{:ok, %{admin_conn: admin_conn}}
|
||||
end
|
||||
|
||||
describe "POST/PATCH/DELETE /api/pleroma/emoji/packs/files?name=:name" do
|
||||
describe "POST/PATCH/DELETE /api/v1/pleroma/emoji/packs/files?name=:name" do
|
||||
setup do
|
||||
pack_file = "#{@emoji_path}/test_pack/pack.json"
|
||||
original_content = File.read!(pack_file)
|
||||
|
@ -55,7 +55,7 @@ test "upload zip file with emojies", %{admin_conn: admin_conn} do
|
|||
resp =
|
||||
admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
file: %Plug.Upload{
|
||||
content_type: "application/zip",
|
||||
filename: "emojis.zip",
|
||||
|
@ -82,7 +82,7 @@ test "upload zip file with emojies", %{admin_conn: admin_conn} do
|
|||
test "create shortcode exists", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -100,7 +100,7 @@ test "don't rewrite old emoji", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank3",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -118,7 +118,7 @@ test "don't rewrite old emoji", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank",
|
||||
new_shortcode: "blank2",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
|
@ -134,7 +134,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank3",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -152,7 +152,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank3",
|
||||
new_shortcode: "blank4",
|
||||
new_filename: "dir_2/blank_3.png",
|
||||
|
@ -170,7 +170,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
|
|||
test "with empty filename", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank2",
|
||||
filename: "",
|
||||
file: %Plug.Upload{
|
||||
|
@ -186,7 +186,7 @@ test "with empty filename", %{admin_conn: admin_conn} do
|
|||
test "add file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
shortcode: "blank3",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -209,7 +209,7 @@ test "returns an error on add file when file system is not writable", %{
|
|||
]) do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
shortcode: "blank3",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -226,7 +226,7 @@ test "returns an error on add file when file system is not writable", %{
|
|||
|
||||
test "remove file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
|
||||
|> delete("/api/v1/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "pack \"not_loaded\" is not found"
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ test "remove file with not loaded pack", %{admin_conn: admin_conn} do
|
|||
|
||||
test "remove file with empty shortcode", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=")
|
||||
|> delete("/api/v1/pleroma/emoji/packs/files?name=not_loaded&shortcode=")
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "pack \"not_loaded\" is not found"
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ test "remove file with empty shortcode", %{admin_conn: admin_conn} do
|
|||
test "update file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=not_loaded", %{
|
||||
shortcode: "blank4",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
|
@ -256,7 +256,7 @@ test "update file with not loaded pack", %{admin_conn: admin_conn} do
|
|||
test "new with shortcode as file with update", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank4",
|
||||
filename: "dir/blank.png",
|
||||
file: %Plug.Upload{
|
||||
|
@ -274,7 +274,7 @@ test "new with shortcode as file with update", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank4",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
|
@ -289,7 +289,7 @@ test "new with shortcode as file with update", %{admin_conn: admin_conn} do
|
|||
assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
|
||||
|> delete("/api/v1/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank" => "blank.png",
|
||||
"blank2" => "blank2.png"
|
||||
|
@ -311,7 +311,7 @@ test "new with shortcode from url", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank_url",
|
||||
file: "https://test-blank/blank_url.png"
|
||||
})
|
||||
|
@ -331,7 +331,7 @@ test "new without shortcode", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
file: %Plug.Upload{
|
||||
filename: "shortcode.png",
|
||||
path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png"
|
||||
|
@ -346,7 +346,7 @@ test "new without shortcode", %{admin_conn: admin_conn} do
|
|||
|
||||
test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
|
||||
|> delete("/api/v1/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "Emoji \"blank3\" does not exist"
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
|
|||
test "update non existing emoji", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank3",
|
||||
new_shortcode: "blank4",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
|
@ -371,7 +371,7 @@ test "update with empty shortcode", %{admin_conn: admin_conn} do
|
|||
} =
|
||||
admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/packs/files?name=test_pack", %{
|
||||
shortcode: "blank",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|
|
|
@ -29,13 +29,16 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
|
|||
{:ok, %{admin_conn: admin_conn}}
|
||||
end
|
||||
|
||||
test "GET /api/pleroma/emoji/packs when :public: false", %{conn: conn} do
|
||||
test "GET /api/v1/pleroma/emoji/packs when :public: false", %{conn: conn} do
|
||||
clear_config([:instance, :public], false)
|
||||
conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
conn |> get("/api/v1/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
test "GET /api/v1/pleroma/emoji/packs", %{conn: conn} do
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/emoji/packs")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["count"] == 4
|
||||
|
||||
|
@ -55,7 +58,7 @@ test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
|||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs?page_size=1")
|
||||
|> get("/api/v1/pleroma/emoji/packs?page_size=1")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["count"] == 4
|
||||
|
@ -68,7 +71,7 @@ test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
|||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs?page_size=1&page=2")
|
||||
|> get("/api/v1/pleroma/emoji/packs?page_size=1&page=2")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["count"] == 4
|
||||
|
@ -78,7 +81,7 @@ test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
|||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs?page_size=1&page=3")
|
||||
|> get("/api/v1/pleroma/emoji/packs?page_size=1&page=3")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["count"] == 4
|
||||
|
@ -88,7 +91,7 @@ test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
|||
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs?page_size=1&page=4")
|
||||
|> get("/api/v1/pleroma/emoji/packs?page_size=1&page=4")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["count"] == 4
|
||||
|
@ -98,11 +101,11 @@ test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
|||
assert [pack1, pack2, pack3, pack4] |> Enum.uniq() |> length() == 4
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/emoji/packs/remote" do
|
||||
describe "GET /api/v1/pleroma/emoji/packs/remote" do
|
||||
test "shareable instance", %{admin_conn: admin_conn, conn: conn} do
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs?page=2&page_size=1")
|
||||
|> get("/api/v1/pleroma/emoji/packs?page=2&page_size=1")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
mock(fn
|
||||
|
@ -112,12 +115,17 @@ test "shareable instance", %{admin_conn: admin_conn, conn: conn} do
|
|||
%{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
|
||||
json(%{metadata: %{features: ["shareable_emoji_packs"]}})
|
||||
|
||||
%{method: :get, url: "https://example.com/api/pleroma/emoji/packs?page=2&page_size=1"} ->
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/v1/pleroma/emoji/packs?page=2&page_size=1"
|
||||
} ->
|
||||
json(resp)
|
||||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/remote?url=https://example.com&page=2&page_size=1")
|
||||
|> get(
|
||||
"/api/v1/pleroma/emoji/packs/remote?url=https://example.com&page=2&page_size=1"
|
||||
)
|
||||
|> json_response_and_validate_schema(200) == resp
|
||||
end
|
||||
|
||||
|
@ -131,18 +139,18 @@ test "non shareable instance", %{admin_conn: admin_conn} do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/remote?url=https://example.com")
|
||||
|> get("/api/v1/pleroma/emoji/packs/remote?url=https://example.com")
|
||||
|> json_response_and_validate_schema(500) == %{
|
||||
"error" => "The requested instance does not support sharing emoji packs"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/emoji/packs/archive?name=:name" do
|
||||
describe "GET /api/v1/pleroma/emoji/packs/archive?name=:name" do
|
||||
test "download shared pack", %{conn: conn} do
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs/archive?name=test_pack")
|
||||
|> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack")
|
||||
|> response(200)
|
||||
|
||||
{:ok, arch} = :zip.unzip(resp, [:memory])
|
||||
|
@ -153,7 +161,7 @@ test "download shared pack", %{conn: conn} do
|
|||
|
||||
test "non existing pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/archive?name=test_pack_for_import")
|
||||
|> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack_for_import")
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack test_pack_for_import does not exist"
|
||||
}
|
||||
|
@ -161,7 +169,7 @@ test "non existing pack", %{conn: conn} do
|
|||
|
||||
test "non downloadable pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/archive?name=test_pack_nonshared")
|
||||
|> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack_nonshared")
|
||||
|> json_response_and_validate_schema(:forbidden) == %{
|
||||
"error" =>
|
||||
"Pack test_pack_nonshared cannot be downloaded from this instance, either pack sharing was disabled for this pack or some files are missing"
|
||||
|
@ -169,7 +177,7 @@ test "non downloadable pack", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/emoji/packs/download" do
|
||||
describe "POST /api/v1/pleroma/emoji/packs/download" do
|
||||
test "shared pack from remote and non shared from fallback-src", %{
|
||||
admin_conn: admin_conn,
|
||||
conn: conn
|
||||
|
@ -183,28 +191,28 @@ test "shared pack from remote and non shared from fallback-src", %{
|
|||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/pack?name=test_pack"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack"
|
||||
} ->
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=test_pack")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=test_pack")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> json()
|
||||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/packs/archive?name=test_pack"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/packs/archive?name=test_pack"
|
||||
} ->
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs/archive?name=test_pack")
|
||||
|> get("/api/v1/pleroma/emoji/packs/archive?name=test_pack")
|
||||
|> response(200)
|
||||
|> text()
|
||||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/pack?name=test_pack_nonshared"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack_nonshared"
|
||||
} ->
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=test_pack_nonshared")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=test_pack_nonshared")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> json()
|
||||
|
||||
|
@ -217,7 +225,7 @@ test "shared pack from remote and non shared from fallback-src", %{
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "test_pack",
|
||||
as: "test_pack2"
|
||||
|
@ -228,7 +236,7 @@ test "shared pack from remote and non shared from fallback-src", %{
|
|||
assert File.exists?("#{@emoji_path}/test_pack2/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name=test_pack2")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name=test_pack2")
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack2")
|
||||
|
@ -236,7 +244,7 @@ test "shared pack from remote and non shared from fallback-src", %{
|
|||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post(
|
||||
"/api/pleroma/emoji/packs/download",
|
||||
"/api/v1/pleroma/emoji/packs/download",
|
||||
%{
|
||||
url: "https://example.com",
|
||||
name: "test_pack_nonshared",
|
||||
|
@ -249,7 +257,7 @@ test "shared pack from remote and non shared from fallback-src", %{
|
|||
assert File.exists?("#{@emoji_path}/test_pack_nonshared2/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name=test_pack_nonshared2")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name=test_pack_nonshared2")
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack_nonshared2")
|
||||
|
@ -267,7 +275,7 @@ test "nonshareable instance", %{admin_conn: admin_conn} do
|
|||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post(
|
||||
"/api/pleroma/emoji/packs/download",
|
||||
"/api/v1/pleroma/emoji/packs/download",
|
||||
%{
|
||||
url: "https://old-instance",
|
||||
name: "test_pack",
|
||||
|
@ -289,14 +297,14 @@ test "checksum fail", %{admin_conn: admin_conn} do
|
|||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/pack?name=pack_bad_sha"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/pack?name=pack_bad_sha"
|
||||
} ->
|
||||
{:ok, pack} = Pleroma.Emoji.Pack.load_pack("pack_bad_sha")
|
||||
%Tesla.Env{status: 200, body: Jason.encode!(pack)}
|
||||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/packs/archive?name=pack_bad_sha"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/packs/archive?name=pack_bad_sha"
|
||||
} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -306,7 +314,7 @@ test "checksum fail", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "pack_bad_sha",
|
||||
as: "pack_bad_sha2"
|
||||
|
@ -326,7 +334,7 @@ test "other error", %{admin_conn: admin_conn} do
|
|||
|
||||
%{
|
||||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/pack?name=test_pack"
|
||||
url: "https://example.com/api/v1/pleroma/emoji/pack?name=test_pack"
|
||||
} ->
|
||||
{:ok, pack} = Pleroma.Emoji.Pack.load_pack("test_pack")
|
||||
%Tesla.Env{status: 200, body: Jason.encode!(pack)}
|
||||
|
@ -334,7 +342,7 @@ test "other error", %{admin_conn: admin_conn} do
|
|||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
|> post("/api/v1/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "test_pack",
|
||||
as: "test_pack2"
|
||||
|
@ -346,7 +354,7 @@ test "other error", %{admin_conn: admin_conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "PATCH/update /api/pleroma/emoji/pack?name=:name" do
|
||||
describe "PATCH/update /api/v1/pleroma/emoji/pack?name=:name" do
|
||||
setup do
|
||||
pack_file = "#{@emoji_path}/test_pack/pack.json"
|
||||
original_content = File.read!(pack_file)
|
||||
|
@ -372,7 +380,7 @@ test "returns error when file system not writable", %{admin_conn: conn} = ctx do
|
|||
assert conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch(
|
||||
"/api/pleroma/emoji/pack?name=test_pack",
|
||||
"/api/v1/pleroma/emoji/pack?name=test_pack",
|
||||
%{"metadata" => ctx[:new_data]}
|
||||
)
|
||||
|> json_response_and_validate_schema(500)
|
||||
|
@ -382,7 +390,7 @@ test "returns error when file system not writable", %{admin_conn: conn} = ctx do
|
|||
test "for a pack without a fallback source", ctx do
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/pack?name=test_pack", %{
|
||||
|> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{
|
||||
"metadata" => ctx[:new_data]
|
||||
})
|
||||
|> json_response_and_validate_schema(200) == ctx[:new_data]
|
||||
|
@ -410,7 +418,7 @@ test "for a pack with a fallback source", ctx do
|
|||
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
|
||||
|> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
|
||||
|> json_response_and_validate_schema(200) == new_data_with_sha
|
||||
|
||||
assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == new_data_with_sha
|
||||
|
@ -430,14 +438,14 @@ test "when the fallback source doesn't have all the files", ctx do
|
|||
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
|
||||
|> patch("/api/v1/pleroma/emoji/pack?name=test_pack", %{metadata: new_data})
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "The fallback archive does not have all files specified in pack.json"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST/DELETE /api/pleroma/emoji/pack?name=:name" do
|
||||
describe "POST/DELETE /api/v1/pleroma/emoji/pack?name=:name" do
|
||||
test "returns an error on creates pack when file system not writable", %{
|
||||
admin_conn: admin_conn
|
||||
} do
|
||||
|
@ -447,7 +455,7 @@ test "returns an error on creates pack when file system not writable", %{
|
|||
{File, [:passthrough], [mkdir: fn ^path_pack -> {:error, :eacces} end]}
|
||||
]) do
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/pack?name=test_pack")
|
||||
|> post("/api/v1/pleroma/emoji/pack?name=test_pack")
|
||||
|> json_response_and_validate_schema(500) == %{
|
||||
"error" =>
|
||||
"Unexpected error occurred while creating pack. (POSIX error: Permission denied)"
|
||||
|
@ -467,7 +475,7 @@ test "returns an error on deletes pack when the file system is not writable", %{
|
|||
{File, [:passthrough], [rm_rf: fn ^path_pack -> {:error, :eacces, path_pack} end]}
|
||||
]) do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name=test_emoji_pack")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name=test_emoji_pack")
|
||||
|> json_response_and_validate_schema(500) == %{
|
||||
"error" =>
|
||||
"Couldn't delete the `test_emoji_pack` pack (POSIX error: Permission denied)"
|
||||
|
@ -480,7 +488,7 @@ test "returns an error on deletes pack when the file system is not writable", %{
|
|||
|
||||
test "creating and deleting a pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/pack?name=test_created")
|
||||
|> post("/api/v1/pleroma/emoji/pack?name=test_created")
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_created/pack.json")
|
||||
|
@ -492,7 +500,7 @@ test "creating and deleting a pack", %{admin_conn: admin_conn} do
|
|||
}
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name=test_created")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name=test_created")
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_created/pack.json")
|
||||
|
@ -505,7 +513,7 @@ test "if pack exists", %{admin_conn: admin_conn} do
|
|||
File.write!(Path.join(path, "pack.json"), pack_file)
|
||||
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/pack?name=test_created")
|
||||
|> post("/api/v1/pleroma/emoji/pack?name=test_created")
|
||||
|> json_response_and_validate_schema(:conflict) == %{
|
||||
"error" => "A pack named \"test_created\" already exists"
|
||||
}
|
||||
|
@ -515,7 +523,7 @@ test "if pack exists", %{admin_conn: admin_conn} do
|
|||
|
||||
test "with empty name", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/pack?name= ")
|
||||
|> post("/api/v1/pleroma/emoji/pack?name= ")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
|
@ -524,7 +532,7 @@ test "with empty name", %{admin_conn: admin_conn} do
|
|||
|
||||
test "deleting nonexisting pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name=non_existing")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name=non_existing")
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack non_existing does not exist"
|
||||
}
|
||||
|
@ -532,7 +540,7 @@ test "deleting nonexisting pack", %{admin_conn: admin_conn} do
|
|||
|
||||
test "deleting with empty name", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/pack?name= ")
|
||||
|> delete("/api/v1/pleroma/emoji/pack?name= ")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
|
@ -544,15 +552,22 @@ test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
|
|||
File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
|
||||
end)
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/emoji/packs")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
refute Map.has_key?(resp["packs"], "test_pack_for_import")
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/import")
|
||||
|> get("/api/v1/pleroma/emoji/packs/import")
|
||||
|> json_response_and_validate_schema(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/emoji/packs")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["packs"]["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
|
||||
|
||||
File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
|
||||
|
@ -568,10 +583,13 @@ test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
|
|||
File.write!("#{@emoji_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/import")
|
||||
|> get("/api/v1/pleroma/emoji/packs/import")
|
||||
|> json_response_and_validate_schema(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/emoji/packs")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["packs"]["test_pack_for_import"]["files"] == %{
|
||||
"blank" => "blank.png",
|
||||
|
@ -580,7 +598,7 @@ test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
|
|||
}
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/emoji/pack?name=:name" do
|
||||
describe "GET /api/v1/pleroma/emoji/pack?name=:name" do
|
||||
test "shows pack.json", %{conn: conn} do
|
||||
assert %{
|
||||
"files" => files,
|
||||
|
@ -595,7 +613,7 @@ test "shows pack.json", %{conn: conn} do
|
|||
}
|
||||
} =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=test_pack")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=test_pack")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert files == %{"blank" => "blank.png", "blank2" => "blank2.png"}
|
||||
|
@ -605,7 +623,7 @@ test "shows pack.json", %{conn: conn} do
|
|||
"files_count" => 2
|
||||
} =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=test_pack&page_size=1")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=test_pack&page_size=1")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert files |> Map.keys() |> length() == 1
|
||||
|
@ -615,7 +633,7 @@ test "shows pack.json", %{conn: conn} do
|
|||
"files_count" => 2
|
||||
} =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=test_pack&page_size=1&page=2")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=test_pack&page_size=1&page=2")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert files |> Map.keys() |> length() == 1
|
||||
|
@ -635,13 +653,13 @@ test "for pack name with special chars", %{conn: conn} do
|
|||
}
|
||||
} =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/pack?name=blobs.gg")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=blobs.gg")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "non existing pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/pack?name=non_existing")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name=non_existing")
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack non_existing does not exist"
|
||||
}
|
||||
|
@ -649,7 +667,7 @@ test "non existing pack", %{conn: conn} do
|
|||
|
||||
test "error name", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/pack?name= ")
|
||||
|> get("/api/v1/pleroma/emoji/pack?name= ")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
|
|
|
@ -151,7 +151,10 @@ test "returns success result", %{conn: conn} do
|
|||
|
||||
assert conn
|
||||
|> put_req_header("authorization", "Bearer #{token.token}")
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{password: "test", code: code})
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{
|
||||
password: "test",
|
||||
code: code
|
||||
})
|
||||
|> json_response(:ok)
|
||||
|
||||
settings = refresh_record(user).multi_factor_authentication_settings
|
||||
|
@ -162,7 +165,10 @@ test "returns success result", %{conn: conn} do
|
|||
|
||||
assert conn
|
||||
|> put_req_header("authorization", "Bearer #{token2.token}")
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{password: "test", code: code})
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{
|
||||
password: "test",
|
||||
code: code
|
||||
})
|
||||
|> json_response(403) == %{
|
||||
"error" => "Insufficient permissions: write:security."
|
||||
}
|
||||
|
@ -185,7 +191,10 @@ test "returns error if password incorrect", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("authorization", "Bearer #{token.token}")
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{password: "xxx", code: code})
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{
|
||||
password: "xxx",
|
||||
code: code
|
||||
})
|
||||
|> json_response(422)
|
||||
|
||||
settings = refresh_record(user).multi_factor_authentication_settings
|
||||
|
@ -212,7 +221,10 @@ test "returns error if code incorrect", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> put_req_header("authorization", "Bearer #{token.token}")
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{password: "test", code: "code"})
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{
|
||||
password: "test",
|
||||
code: "code"
|
||||
})
|
||||
|> json_response(422)
|
||||
|
||||
settings = refresh_record(user).multi_factor_authentication_settings
|
||||
|
@ -223,7 +235,10 @@ test "returns error if code incorrect", %{conn: conn} do
|
|||
|
||||
assert conn
|
||||
|> put_req_header("authorization", "Bearer #{token2.token}")
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{password: "test", code: "code"})
|
||||
|> post("/api/pleroma/accounts/mfa/confirm/totp", %{
|
||||
password: "test",
|
||||
code: "code"
|
||||
})
|
||||
|> json_response(403) == %{
|
||||
"error" => "Insufficient permissions: write:security."
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ defmodule Pleroma.Web.TwitterAPI.PasswordControllerTest do
|
|||
import Pleroma.Factory
|
||||
import Swoosh.TestAssertions
|
||||
|
||||
describe "GET /api/pleroma/password_reset/token" do
|
||||
describe "GET /api/v1/pleroma/password_reset/token" do
|
||||
test "it returns error when token invalid", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/password_reset/token")
|
||||
|> get("/api/v1/pleroma/password_reset/token")
|
||||
|> html_response(:ok)
|
||||
|
||||
assert response =~ "<h2>Invalid Token</h2>"
|
||||
|
@ -30,7 +30,7 @@ test "it shows password reset form", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/password_reset/#{token.token}")
|
||||
|> get("/api/v1/pleroma/password_reset/#{token.token}")
|
||||
|> html_response(:ok)
|
||||
|
||||
assert response =~ "<h2>Password Reset for #{user.nickname}</h2>"
|
||||
|
@ -45,14 +45,14 @@ test "it returns an error when the token has expired", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/password_reset/#{token.token}")
|
||||
|> get("/api/v1/pleroma/password_reset/#{token.token}")
|
||||
|> html_response(:ok)
|
||||
|
||||
assert response =~ "<h2>Invalid Token</h2>"
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/password_reset" do
|
||||
describe "POST /api/v1/pleroma/password_reset" do
|
||||
test "it fails for an expired token", %{conn: conn} do
|
||||
clear_config([:instance, :password_reset_token_validity], 0)
|
||||
|
||||
|
@ -70,7 +70,7 @@ test "it fails for an expired token", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/password_reset", %{data: params})
|
||||
|> post("/api/v1/pleroma/password_reset", %{data: params})
|
||||
|> html_response(:ok)
|
||||
|
||||
refute response =~ "<h2>Password changed!</h2>"
|
||||
|
@ -90,7 +90,7 @@ test "it returns HTTP 200", %{conn: conn} do
|
|||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/password_reset", %{data: params})
|
||||
|> post("/api/v1/pleroma/password_reset", %{data: params})
|
||||
|> html_response(:ok)
|
||||
|
||||
assert response =~ "<h2>Password changed!</h2>"
|
||||
|
@ -114,7 +114,7 @@ test "it sets password_reset_pending to false", %{conn: conn} do
|
|||
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/pleroma/password_reset", %{data: params})
|
||||
|> post("/api/v1/pleroma/password_reset", %{data: params})
|
||||
|> html_response(:ok)
|
||||
|
||||
assert User.get_by_id(user.id).password_reset_pending == false
|
||||
|
|
|
@ -77,11 +77,11 @@ test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} d
|
|||
end
|
||||
end
|
||||
|
||||
describe "/api/pleroma/emoji" do
|
||||
describe "/api/v1/pleroma/emoji" do
|
||||
test "returns json with custom emoji with tags", %{conn: conn} do
|
||||
emoji =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji")
|
||||
|> get("/api/v1/pleroma/emoji")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert Enum.all?(emoji, fn
|
||||
|
@ -95,7 +95,7 @@ test "returns json with custom emoji with tags", %{conn: conn} do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/healthcheck" do
|
||||
describe "GET /api/v1/pleroma/healthcheck" do
|
||||
setup do: clear_config([:instance, :healthcheck])
|
||||
|
||||
test "returns 503 when healthcheck disabled", %{conn: conn} do
|
||||
|
@ -103,7 +103,7 @@ test "returns 503 when healthcheck disabled", %{conn: conn} do
|
|||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/healthcheck")
|
||||
|> get("/api/v1/pleroma/healthcheck")
|
||||
|> json_response_and_validate_schema(503)
|
||||
|
||||
assert response == %{}
|
||||
|
@ -116,7 +116,7 @@ test "returns 200 when healthcheck enabled and all ok", %{conn: conn} do
|
|||
system_info: fn -> %Pleroma.Healthcheck{healthy: true} end do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/healthcheck")
|
||||
|> get("/api/v1/pleroma/healthcheck")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{
|
||||
|
@ -136,7 +136,7 @@ test "returns 503 when healthcheck enabled and health is false", %{conn: conn} d
|
|||
system_info: fn -> %Pleroma.Healthcheck{healthy: false} end do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/healthcheck")
|
||||
|> get("/api/v1/pleroma/healthcheck")
|
||||
|> json_response_and_validate_schema(503)
|
||||
|
||||
assert %{
|
||||
|
@ -334,7 +334,7 @@ test "it returns new captcha", %{conn: conn} do
|
|||
new: fn -> "test_captcha" end do
|
||||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/captcha")
|
||||
|> get("/api/v1/pleroma/captcha")
|
||||
|> response(200)
|
||||
|
||||
assert resp == "\"test_captcha\""
|
||||
|
@ -459,7 +459,10 @@ test "with proper permissions, valid password and valid email", %{
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/change_email", %{password: "test", email: "cofe@foobar.com"})
|
||||
|> post("/api/pleroma/change_email", %{
|
||||
password: "test",
|
||||
email: "cofe@foobar.com"
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"}
|
||||
end
|
||||
|
@ -961,7 +964,9 @@ test "with permissions, account does not have such alias", %{
|
|||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/pleroma/aliases", %{alias: non_alias_user |> User.full_nickname()})
|
||||
|> delete("/api/pleroma/aliases", %{
|
||||
alias: non_alias_user |> User.full_nickname()
|
||||
})
|
||||
|
||||
assert %{"error" => "Account has no such alias."} =
|
||||
json_response_and_validate_schema(conn, 404)
|
||||
|
|
Loading…
Reference in a new issue