3 class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
6 {ping_secret: '', service_ssl_flag: false, service_port: 1234}
9 test "add keep disk with admin token" do
11 post :ping, default_ping_opts.
12 merge(filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f')
13 assert_response :success
14 assert_not_nil assigns(:object)
15 new_keep_disk = JSON.parse(@response.body)
16 assert_not_nil new_keep_disk['uuid']
17 assert_not_nil new_keep_disk['ping_secret']
18 assert_not_equal '', new_keep_disk['ping_secret']
23 {filesystem_uuid: ''},
25 test "add keep disk with[out] filesystem_uuid #{opts}" do
27 post :ping, default_ping_opts.merge(opts)
28 assert_response :success
29 assert_not_nil JSON.parse(@response.body)['uuid']
33 test "refuse to add keep disk without admin token" do
34 post :ping, default_ping_opts
38 test "ping keep disk" do
39 post :ping, default_ping_opts.
40 merge(id: keep_disks(:nonfull).uuid,
41 ping_secret: keep_disks(:nonfull).ping_secret,
42 filesystem_uuid: keep_disks(:nonfull).filesystem_uuid)
43 assert_response :success
44 assert_not_nil assigns(:object)
45 keep_disk = JSON.parse(@response.body)
46 assert_not_nil keep_disk['uuid']
47 assert_not_nil keep_disk['ping_secret']
50 test "admin should get index with ping_secret" do
53 assert_response :success
54 assert_not_nil assigns(:objects)
55 items = JSON.parse(@response.body)['items']
56 assert_not_equal 0, items.size
57 assert_not_nil items[0]['ping_secret']
60 # inactive user sees keep disks
61 test "inactive user should get index" do
62 authorize_with :inactive
64 assert_response :success
65 items = JSON.parse(@response.body)['items']
66 assert_not_equal 0, items.size
68 # Check these are still included
69 assert items[0]['service_host']
70 assert items[0]['service_port']
73 # active user sees non-secret attributes of keep disks
74 test "active user should get non-empty index with no ping_secret" do
75 authorize_with :active
77 assert_response :success
78 items = JSON.parse(@response.body)['items']
79 assert_not_equal 0, items.size
81 assert_nil item['ping_secret']
82 assert_not_nil item['is_readable']
83 assert_not_nil item['is_writable']
84 assert_not_nil item['service_host']
85 assert_not_nil item['service_port']
89 test "search keep_services with 'any' operator" do
90 authorize_with :active
92 where: { any: ['contains', 'o2t1q5w'] }
94 assert_response :success
95 found = assigns(:objects).collect(&:uuid)
96 assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')