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']
19 test "add keep disk with no filesystem_uuid" do
25 assert_response :success
26 assert_not_nil JSON.parse(@response.body)['uuid']
28 post :ping, opts.merge(filesystem_uuid: '')
29 assert_response :success
30 assert_not_nil JSON.parse(@response.body)['uuid']
33 test "refuse to add keep disk without admin token" do
40 test "ping keep disk" do
42 id: keep_disks(:nonfull).uuid,
43 ping_secret: keep_disks(:nonfull).ping_secret,
44 filesystem_uuid: keep_disks(:nonfull).filesystem_uuid
46 assert_response :success
47 assert_not_nil assigns(:object)
48 keep_disk = JSON.parse(@response.body)
49 assert_not_nil keep_disk['uuid']
50 assert_not_nil keep_disk['ping_secret']
53 test "admin should get index with ping_secret" do
56 assert_response :success
57 assert_not_nil assigns(:objects)
58 items = JSON.parse(@response.body)['items']
59 assert_not_equal 0, items.size
60 assert_not_nil items[0]['ping_secret']
63 # inactive user sees keep disks
64 test "inactive user should get index" do
65 authorize_with :inactive
67 assert_response :success
68 items = JSON.parse(@response.body)['items']
69 assert_not_equal 0, items.size
71 # Check these are still included
72 assert items[0]['service_host']
73 assert items[0]['service_port']
76 # active user sees non-secret attributes of keep disks
77 test "active user should get non-empty index with no ping_secret" do
78 authorize_with :active
80 assert_response :success
81 items = JSON.parse(@response.body)['items']
82 assert_not_equal 0, items.size
84 assert_nil item['ping_secret']
85 assert_not_nil item['is_readable']
86 assert_not_nil item['is_writable']
87 assert_not_nil item['service_host']
88 assert_not_nil item['service_port']
92 test "search keep_services with 'any' operator" do
93 authorize_with :active
95 where: { any: ['contains', 'o2t1q5w'] }
97 assert_response :success
98 found = assigns(:objects).collect(&:uuid)
99 assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')