mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-30 20:27:22 +00:00
98cb255d12
OTP builds to 1.15
Changelog entry
Ensure policies are fully loaded
Fix :warn
use main branch for linkify
Fix warn in tests
Migrations for phoenix 1.17
Revert "Migrations for phoenix 1.17"
This reverts commit 6a3b2f15b7
.
Oban upgrade
Add default empty whitelist
mix format
limit test to amd64
OTP 26 tests for 1.15
use OTP_VERSION tag
baka
just 1.15
Massive deps update
Update locale, deps
Mix format
shell????
multiline???
?
max cases 1
use assert_recieve
don't put_env in async tests
don't async conn/fs tests
mix format
FIx some uploader issues
Fix tests
123 lines
3.6 KiB
Elixir
123 lines
3.6 KiB
Elixir
defmodule Pleroma.Web.AkkomaAPI.FrontendSettingsControllerTest do
|
|
use Pleroma.Web.ConnCase, async: false
|
|
|
|
import Pleroma.Factory
|
|
alias Pleroma.Akkoma.FrontendSettingsProfile
|
|
|
|
describe "GET /api/v1/akkoma/frontend_settings/:frontend_name" do
|
|
test "it returns a list of profiles" do
|
|
%{conn: conn, user: user} = oauth_access(["read"])
|
|
|
|
insert(:frontend_setting_profile, user: user, frontend_name: "test", profile_name: "test1")
|
|
insert(:frontend_setting_profile, user: user, frontend_name: "test", profile_name: "test2")
|
|
|
|
response =
|
|
conn
|
|
|> get("/api/v1/akkoma/frontend_settings/test")
|
|
|> json_response_and_validate_schema(200)
|
|
|
|
assert response == [
|
|
%{"name" => "test1", "version" => 1},
|
|
%{"name" => "test2", "version" => 1}
|
|
]
|
|
end
|
|
end
|
|
|
|
describe "GET /api/v1/akkoma/frontend_settings/:frontend_name/:profile_name" do
|
|
test "it returns 404 if not found" do
|
|
%{conn: conn} = oauth_access(["read"])
|
|
|
|
conn
|
|
|> get("/api/v1/akkoma/frontend_settings/unknown_frontend/unknown_profile")
|
|
|> json_response_and_validate_schema(404)
|
|
end
|
|
|
|
test "it returns 200 if found" do
|
|
%{conn: conn, user: user} = oauth_access(["read"])
|
|
|
|
insert(:frontend_setting_profile,
|
|
user: user,
|
|
frontend_name: "test",
|
|
profile_name: "test1",
|
|
settings: %{"test" => "test"}
|
|
)
|
|
|
|
response =
|
|
conn
|
|
|> get("/api/v1/akkoma/frontend_settings/test/test1")
|
|
|> json_response_and_validate_schema(200)
|
|
|
|
assert response == %{"settings" => %{"test" => "test"}, "version" => 1}
|
|
end
|
|
end
|
|
|
|
describe "PUT /api/v1/akkoma/frontend_settings/:frontend_name/:profile_name" do
|
|
test "puts a config" do
|
|
%{conn: conn, user: user} = oauth_access(["write"])
|
|
settings = %{"test" => "test2"}
|
|
|
|
response =
|
|
conn
|
|
|> put_req_header("content-type", "application/json")
|
|
|> put("/api/v1/akkoma/frontend_settings/test/test1", %{
|
|
"settings" => settings,
|
|
"version" => 1
|
|
})
|
|
|> json_response_and_validate_schema(200)
|
|
|
|
assert response == settings
|
|
|
|
assert %FrontendSettingsProfile{settings: ^settings} =
|
|
FrontendSettingsProfile.get_by_user_and_frontend_name_and_profile_name(
|
|
user,
|
|
"test",
|
|
"test1"
|
|
)
|
|
end
|
|
|
|
test "refuses to overwrite a newer config" do
|
|
%{conn: conn, user: user} = oauth_access(["write"])
|
|
|
|
insert(:frontend_setting_profile,
|
|
user: user,
|
|
frontend_name: "test",
|
|
profile_name: "test1",
|
|
settings: %{"test" => "test"},
|
|
version: 2
|
|
)
|
|
|
|
conn
|
|
|> put_req_header("content-type", "application/json")
|
|
|> put("/api/v1/akkoma/frontend_settings/test/test1", %{
|
|
"settings" => %{"test" => "test2"},
|
|
"version" => 1
|
|
})
|
|
|> json_response_and_validate_schema(422)
|
|
end
|
|
end
|
|
|
|
describe "DELETE /api/v1/akkoma/frontend_settings/:frontend_name/:profile_name" do
|
|
test "deletes a config" do
|
|
%{conn: conn, user: user} = oauth_access(["write"])
|
|
|
|
insert(:frontend_setting_profile,
|
|
user: user,
|
|
frontend_name: "test",
|
|
profile_name: "test1",
|
|
settings: %{"test" => "test"},
|
|
version: 2
|
|
)
|
|
|
|
conn
|
|
|> delete("/api/v1/akkoma/frontend_settings/test/test1")
|
|
|> json_response_and_validate_schema(200)
|
|
|
|
assert FrontendSettingsProfile.get_by_user_and_frontend_name_and_profile_name(
|
|
user,
|
|
"test",
|
|
"test1"
|
|
) == nil
|
|
end
|
|
end
|
|
end
|