clear_oauth_token_worker_test.exs (698B)
1 # Pleroma: A lightweight social networking server 2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> 3 # SPDX-License-Identifier: AGPL-3.0-only 4 5 defmodule Pleroma.Workers.Cron.ClearOauthTokenWorkerTest do 6 use Pleroma.DataCase 7 8 import Pleroma.Factory 9 alias Pleroma.Workers.Cron.ClearOauthTokenWorker 10 11 setup do: clear_config([:oauth2, :clean_expired_tokens]) 12 13 test "deletes expired tokens" do 14 insert(:oauth_token, 15 valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), -60 * 10) 16 ) 17 18 Pleroma.Config.put([:oauth2, :clean_expired_tokens], true) 19 ClearOauthTokenWorker.perform(%Oban.Job{}) 20 assert Pleroma.Repo.all(Pleroma.Web.OAuth.Token) == [] 21 end 22 end