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
72 # active user sees non-secret attributes of keep disks
73 test "active user should get non-empty index with no ping_secret" do
74 authorize_with :active
76 assert_response :success
77 items = JSON.parse(@response.body)['items']
78 assert_not_equal 0, items.size
80 assert_nil item['ping_secret']
81 assert_not_nil item['is_readable']
82 assert_not_nil item['is_writable']
83 assert_not_nil item['service_host']
84 assert_not_nil item['service_port']
88 test "search keep_services with 'any' operator" do
89 authorize_with :active
91 where: { any: ['contains', 'o2t1q5w'] }
93 assert_response :success
94 found = assigns(:objects).collect(&:uuid)
95 assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')