Move API endpoints to `/api/v1/pleroma/backups`

This commit is contained in:
Egor Kislitsyn 2020-09-20 20:43:27 +04:00
parent a9efd441e2
commit 17562bf414
No known key found for this signature in database
GPG Key ID: 1B49CB15B71E7805
3 changed files with 12 additions and 12 deletions

View File

@ -616,7 +616,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
]
```
## `POST /api/pleroma/backups`
## `POST /api/v1/pleroma/backups`
### Create a user backup archive
* Method: `POST`
@ -635,7 +635,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
}]
```
## `GET /api/pleroma/backups`
## `GET /api/v1/pleroma/backups`
### Lists user backups
* Method: `GET`

View File

@ -295,9 +295,6 @@ defmodule Pleroma.Web.Router do
get("/accounts/mfa/setup/:method", TwoFactorAuthenticationController, :setup)
post("/accounts/mfa/confirm/:method", TwoFactorAuthenticationController, :confirm)
delete("/accounts/mfa/:method", TwoFactorAuthenticationController, :disable)
get("/backups", BackupController, :index)
post("/backups", BackupController, :create)
end
scope "/oauth", Pleroma.Web.OAuth do
@ -358,6 +355,9 @@ defmodule Pleroma.Web.Router do
put("/mascot", MascotController, :update)
post("/scrobble", ScrobbleController, :create)
get("/backups", BackupController, :index)
post("/backups", BackupController, :create)
end
scope [] do

View File

@ -14,14 +14,14 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
oauth_access(["read:accounts"])
end
test "GET /api/pleroma/backups", %{user: user, conn: conn} do
test "GET /api/v1/pleroma/backups", %{user: user, conn: conn} do
assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id}}} = Backup.create(user)
backup = Backup.get(backup_id)
response =
conn
|> get("/api/pleroma/backups")
|> get("/api/v1/pleroma/backups")
|> json_response_and_validate_schema(:ok)
assert [
@ -45,11 +45,11 @@ test "GET /api/pleroma/backups", %{user: user, conn: conn} do
}
] =
conn
|> get("/api/pleroma/backups")
|> get("/api/v1/pleroma/backups")
|> json_response_and_validate_schema(:ok)
end
test "POST /api/pleroma/backups", %{user: _user, conn: conn} do
test "POST /api/v1/pleroma/backups", %{user: _user, conn: conn} do
assert [
%{
"content_type" => "application/zip",
@ -60,7 +60,7 @@ test "POST /api/pleroma/backups", %{user: _user, conn: conn} do
}
] =
conn
|> post("/api/pleroma/backups")
|> post("/api/v1/pleroma/backups")
|> json_response_and_validate_schema(:ok)
Pleroma.Tests.ObanHelpers.perform_all()
@ -72,14 +72,14 @@ test "POST /api/pleroma/backups", %{user: _user, conn: conn} do
}
] =
conn
|> get("/api/pleroma/backups")
|> get("/api/v1/pleroma/backups")
|> json_response_and_validate_schema(:ok)
days = Pleroma.Config.get([Backup, :limit_days])
assert %{"error" => "Last export was less than #{days} days ago"} ==
conn
|> post("/api/pleroma/backups")
|> post("/api/v1/pleroma/backups")
|> json_response_and_validate_schema(400)
end
end