fix tests

This commit is contained in:
MediaFormat 2026-01-11 17:47:27 +00:00
commit 12002830bc
2 changed files with 8 additions and 8 deletions

View file

@ -10,20 +10,20 @@ defmodule Pleroma.Web.OAuth.AppTest do
describe "get_or_make/2" do
test "gets exist app" do
attrs = %{client_name: "Mastodon-Local", redirect_uris: "."}
attrs = %{client_name: "Mastodon-Local", redirect_uris: ["."]}
app = insert(:oauth_app, Map.merge(attrs, %{scopes: ["read", "write"]}))
{:ok, %App{} = exist_app} = App.get_or_make(attrs, [])
assert exist_app == app
end
test "make app" do
attrs = %{client_name: "Mastodon-Local", redirect_uris: "."}
attrs = %{client_name: "Mastodon-Local", redirect_uris: ["."]}
{:ok, %App{} = app} = App.get_or_make(attrs, ["write"])
assert app.scopes == ["write"]
end
test "gets exist app and updates scopes" do
attrs = %{client_name: "Mastodon-Local", redirect_uris: "."}
attrs = %{client_name: "Mastodon-Local", redirect_uris: ["."]}
app = insert(:oauth_app, Map.merge(attrs, %{scopes: ["read", "write"]}))
{:ok, %App{} = exist_app} = App.get_or_make(attrs, ["read", "write", "follow", "push"])
assert exist_app.id == app.id
@ -31,10 +31,10 @@ defmodule Pleroma.Web.OAuth.AppTest do
end
test "has unique client_id" do
insert(:oauth_app, client_name: "", redirect_uris: "", client_id: "boop")
insert(:oauth_app, client_name: "", redirect_uris: [""], client_id: "boop")
error =
catch_error(insert(:oauth_app, client_name: "", redirect_uris: "", client_id: "boop"))
catch_error(insert(:oauth_app, client_name: "", redirect_uris: [""], client_id: "boop"))
assert %Ecto.ConstraintError{} = error
assert error.constraint == "apps_client_id_index"
@ -55,7 +55,7 @@ defmodule Pleroma.Web.OAuth.AppTest do
end
test "removes orphaned apps" do
attrs = %{client_name: "Mastodon-Local", redirect_uris: "."}
attrs = %{client_name: "Mastodon-Local", redirect_uris: ["."]}
{:ok, %App{} = old_app} = App.get_or_make(attrs, ["write"])
# backdate the old app so it's within the threshold for being cleaned up
@ -66,7 +66,7 @@ defmodule Pleroma.Web.OAuth.AppTest do
|> Pleroma.Repo.query([one_hour_ago, old_app.id])
# Create the new app after backdating the old one
attrs = %{client_name: "PleromaFE", redirect_uris: "."}
attrs = %{client_name: "PleromaFE", redirect_uris: ["."]}
{:ok, %App{} = app} = App.get_or_make(attrs, ["write"])
# Ensure the new app has a recent timestamp

View file

@ -406,7 +406,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
describe "GET /oauth/authorize" do
setup do
[
app: insert(:oauth_app, redirect_uris: "https://redirect.url"),
app: insert(:oauth_app, redirect_uris: ["https://redirect.url"]),
conn:
build_conn()
|> Plug.Session.call(Plug.Session.init(@session_opts))