11870: minor update
[arvados.git] / services / api / test / unit / api_client_authorization_test.rb
index b5b07d1f788746d33ee00a47dfab485544974ee4..dd255fb0e0b459c32605049da94896e886776aad 100644 (file)
@@ -1,7 +1,17 @@
 require 'test_helper'
 
 class ApiClientAuthorizationTest < ActiveSupport::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+  include CurrentApiClient
+
+  [:admin_trustedclient, :active_trustedclient].each do |token|
+    test "ApiClientAuthorization can be created then deleted by #{token}" do
+      set_user_from_auth token
+      x = ApiClientAuthorization.create!(user_id: current_user.id,
+                                         api_client_id: 0,
+                                         scopes: [])
+      newtoken = x.api_token
+      assert x.destroy, "Failed to destroy new ApiClientAuth"
+      assert_empty ApiClientAuthorization.where(api_token: newtoken), "Destroyed ApiClientAuth is still in database"
+    end
+  end
 end