3 class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
5 test "add keep disk with admin token" do
8 ping_secret: '', # required by discovery doc, but ignored
9 filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f'
11 assert_response :success
12 assert_not_nil assigns(:object)
13 new_keep_disk = JSON.parse(@response.body)
14 assert_not_nil new_keep_disk['uuid']
15 assert_not_nil new_keep_disk['ping_secret']
16 assert_not_equal '', new_keep_disk['ping_secret']
21 {ping_secret: '', filesystem_uuid: ''},
23 test "add keep disk with no filesystem_uuid #{opts}" do
26 assert_response :success
27 assert_not_nil JSON.parse(@response.body)['uuid']
31 test "refuse to add keep disk without admin token" do
38 test "ping keep disk" do
40 id: keep_disks(:nonfull).uuid,
41 ping_secret: keep_disks(:nonfull).ping_secret,
42 filesystem_uuid: keep_disks(:nonfull).filesystem_uuid
44 assert_response :success
45 assert_not_nil assigns(:object)
46 keep_disk = JSON.parse(@response.body)
47 assert_not_nil keep_disk['uuid']
48 assert_not_nil keep_disk['ping_secret']
51 test "admin should get index with ping_secret" do
54 assert_response :success
55 assert_not_nil assigns(:objects)
56 items = JSON.parse(@response.body)['items']
57 assert_not_equal 0, items.size
58 assert_not_nil items[0]['ping_secret']
61 # inactive user sees keep disks
62 test "inactive user should get index" do
63 authorize_with :inactive
65 assert_response :success
66 items = JSON.parse(@response.body)['items']
67 assert_not_equal 0, items.size
69 # Check these are still included
70 assert items[0]['service_host']
71 assert items[0]['service_port']
74 # active user sees non-secret attributes of keep disks
75 test "active user should get non-empty index with no ping_secret" do
76 authorize_with :active
78 assert_response :success
79 items = JSON.parse(@response.body)['items']
80 assert_not_equal 0, items.size
82 assert_nil item['ping_secret']
83 assert_not_nil item['is_readable']
84 assert_not_nil item['is_writable']
85 assert_not_nil item['service_host']
86 assert_not_nil item['service_port']
90 test "search keep_services with 'any' operator" do
91 authorize_with :active
93 where: { any: ['contains', 'o2t1q5w'] }
95 assert_response :success
96 found = assigns(:objects).collect(&:uuid)
97 assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')