Merge branch '8784-dir-listings'
[arvados.git] / services / api / test / functional / arvados / v1 / logs_controller_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class Arvados::V1::LogsControllerTest < ActionController::TestCase
8   fixtures :logs
9
10   test "non-admins can create their own logs" do
11     authorize_with :active
12     post :create, log: {summary: 'test log'}
13     assert_response :success
14     resp = assigns(:object)
15     assert_not_nil resp.uuid
16     assert_equal('test log', resp.summary, "loaded wrong log after creation")
17   end
18
19   test "non-admins can read their own logs" do
20     authorize_with :active
21     my_log = logs(:log_owned_by_active)
22     get :show, {id: my_log[:uuid]}
23     assert_response(:success, "failed to get log")
24     resp = assigns(:object)
25     assert_equal(my_log[:summary], resp.summary, "got wrong log")
26   end
27
28   test "test can still use where object_kind" do
29     authorize_with :admin
30     get :index, {
31       where: { object_kind: 'arvados#user' }
32     }
33     assert_response :success
34     found = assigns(:objects)
35     assert_not_equal 0, found.count
36     assert_equal found.count, (found.select { |f| f.object_uuid.match User.uuid_regex }).count
37     l = JSON.parse(@response.body)
38     assert_equal 'arvados#user', l['items'][0]['object_kind']
39   end
40
41   test "test can still use filter object_kind" do
42     authorize_with :admin
43     get :index, {
44       filters: [ ['object_kind', '=', 'arvados#user'] ]
45     }
46     assert_response :success
47     found = assigns(:objects)
48     assert_not_equal 0, found.count
49     assert_equal found.count, (found.select { |f| f.object_uuid.match User.uuid_regex }).count
50   end
51
52 end