3 class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
5 test "add keep node with admin token" do
8 ping_secret: '', # required by discovery doc, but ignored
11 service_ssl_flag: false,
12 filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f'
14 assert_response :success
15 assert_not_nil assigns(:object)
16 new_keep_node = JSON.parse(@response.body)
17 assert_not_nil new_keep_node['uuid']
18 assert_not_nil new_keep_node['ping_secret']
19 assert_not_equal '', new_keep_node['ping_secret']
22 test "refuse to add keep node with no filesystem_uuid" do
28 service_ssl_flag: false
32 post :ping, opts.merge(filesystem_uuid: '')
36 test "refuse to add keep node without admin token" do
41 service_ssl_flag: false
46 test "ping from keep node" do
48 uuid: keep_disks(:nonfull).uuid,
49 ping_secret: keep_disks(:nonfull).ping_secret,
50 filesystem_uuid: keep_disks(:nonfull).filesystem_uuid
52 assert_response :success
53 assert_not_nil assigns(:object)
54 keep_node = JSON.parse(@response.body)
55 assert_not_nil keep_node['uuid']
56 assert_not_nil keep_node['ping_secret']
59 test "should get index with ping_secret" do
62 assert_response :success
63 assert_not_nil assigns(:objects)
64 items = JSON.parse(@response.body)['items']
65 assert_not_equal 0, items.size
66 assert_not_nil items[0]['ping_secret']
69 # inactive user does not see any keep disks
70 test "inactive user should get empty index" do
71 authorize_with :inactive
73 assert_response :success
74 items = JSON.parse(@response.body)['items']
75 assert_equal 0, items.size
78 # active user sees non-secret attributes of keep disks
79 test "active user should get non-empty index with no ping_secret" do
80 authorize_with :active
82 assert_response :success
83 items = JSON.parse(@response.body)['items']
84 assert_not_equal 0, items.size
86 assert_nil item['ping_secret']
87 assert_not_nil item['is_readable']
88 assert_not_nil item['is_writable']
89 assert_not_nil item['service_host']
90 assert_not_nil item['service_port']