8784: Merge branch 'master' into 8784-dir-listings
[arvados.git] / services / api / test / unit / api_client_authorization_test.rb
1 require 'test_helper'
2
3 class ApiClientAuthorizationTest < ActiveSupport::TestCase
4   include CurrentApiClient
5
6   [:admin_trustedclient, :active_trustedclient].each do |token|
7     test "ApiClientAuthorization can be created then deleted by #{token}" do
8       set_user_from_auth token
9       x = ApiClientAuthorization.create!(user_id: current_user.id,
10                                          api_client_id: 0,
11                                          scopes: [])
12       newtoken = x.api_token
13       assert x.destroy, "Failed to destroy new ApiClientAuth"
14       assert_empty ApiClientAuthorization.where(api_token: newtoken), "Destroyed ApiClientAuth is still in database"
15     end
16   end
17 end