summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-09-05 20:55:28 +0000
committerMark Felder <feld@feld.me>2024-09-05 20:55:28 +0000
commit1797f5958a92f78dc79c5bf313755b16319c5d2d (patch)
tree60429fabbd88f1fbd21ecde1821039f4920b2ee7 /test
parent53744bf146f157ee1ecfc9ba4de9e5d65fa80784 (diff)
downloadpleroma-1797f5958a92f78dc79c5bf313755b16319c5d2d.tar.gz
pleroma-1797f5958a92f78dc79c5bf313755b16319c5d2d.zip
App orphans should only be removed if they are older than 15 mins
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/o_auth/app_test.exs11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/pleroma/web/o_auth/app_test.exs b/test/pleroma/web/o_auth/app_test.exs
index 725ea3eb8..44219cf90 100644
--- a/test/pleroma/web/o_auth/app_test.exs
+++ b/test/pleroma/web/o_auth/app_test.exs
@@ -56,13 +56,18 @@ defmodule Pleroma.Web.OAuth.AppTest do
test "removes orphaned apps" do
attrs = %{client_name: "Mastodon-Local", redirect_uris: "."}
+ {:ok, %App{} = old_app} = App.get_or_make(attrs, ["write"])
+
+ attrs = %{client_name: "PleromaFE", redirect_uris: "."}
{:ok, %App{} = app} = App.get_or_make(attrs, ["write"])
- assert app.scopes == ["write"]
- assert app == Pleroma.Repo.get_by(App, %{id: app.id})
+ # backdate the old app so it's within the threshold for being cleaned up
+ {:ok, _} =
+ "UPDATE apps SET inserted_at = now() - interval '1 hour' WHERE id = #{old_app.id}"
+ |> Pleroma.Repo.query()
App.remove_orphans()
- assert nil == Pleroma.Repo.get_by(App, %{id: app.id})
+ assert [app] == Pleroma.Repo.all(App)
end
end