1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'sweep_trashed_objects'
8 class ApiClientAuthorizationTest < ActiveSupport::TestCase
9 include CurrentApiClient
11 [:admin_trustedclient, :active_trustedclient].each do |token|
12 test "ApiClientAuthorization can be created then deleted by #{token}" do
13 set_user_from_auth token
14 x = ApiClientAuthorization.create!(user_id: current_user.id,
17 newtoken = x.api_token
18 assert x.destroy, "Failed to destroy new ApiClientAuth"
19 assert_empty ApiClientAuthorization.where(api_token: newtoken), "Destroyed ApiClientAuth is still in database"
23 test "delete expired in SweepTrashedObjects" do
24 assert_not_empty ApiClientAuthorization.where(uuid: api_client_authorizations(:expired).uuid)
25 SweepTrashedObjects.sweep_now
26 assert_empty ApiClientAuthorization.where(uuid: api_client_authorizations(:expired).uuid)