Fix 404 at api_client_authorizations.create_system_auth and add tests.
[arvados.git] / services / api / test / functional / arvados / v1 / api_client_authorizations_controller_test.rb
1 require 'test_helper'
2
3 class Arvados::V1::ApiClientAuthorizationsControllerTest < ActionController::TestCase
4
5   test "should get index" do
6     authorize_with :active_trustedclient
7     get :index
8     assert_response :success
9   end
10
11   test "should not get index with expired auth" do
12     authorize_with :expired
13     get :index, format: :json
14     assert_response 401
15   end
16
17   test "should not get index from untrusted client" do
18     authorize_with :active
19     get :index
20     assert_response 403
21   end
22
23   test "create system auth" do
24     authorize_with :admin_trustedclient
25     post :create_system_auth, scopes: '["test"]'
26     assert_response :success
27   end
28
29   test "prohibit create system auth with token from non-trusted client" do
30     authorize_with :admin
31     post :create_system_auth, scopes: '["test"]'
32     assert_response 403
33   end
34
35   test "prohibit create system auth by non-admin" do
36     authorize_with :active
37     post :create_system_auth, scopes: '["test"]'
38     assert_response 403
39   end
40
41 end