3 class Arvados::V1::NodesControllerTest < ActionController::TestCase
5 test "should get index with ping_secret" do
8 assert_response :success
9 assert_not_nil assigns(:objects)
10 node_items = JSON.parse(@response.body)['items']
11 assert_not_equal 0, node_items.size
12 assert_not_nil node_items[0]['info'].andand['ping_secret']
15 # inactive user does not see any nodes
16 test "inactive user should get empty index" do
17 authorize_with :inactive
19 assert_response :success
20 node_items = JSON.parse(@response.body)['items']
21 assert_equal 0, node_items.size
24 # active user sees non-secret attributes of up and recently-up nodes
25 test "active user should get non-empty index with no ping_secret" do
26 authorize_with :active
28 assert_response :success
29 node_items = JSON.parse(@response.body)['items']
30 assert_not_equal 0, node_items.size
31 found_busy_node = false
32 node_items.each do |node|
33 assert_nil node['info'].andand['ping_secret']
34 assert_not_nil node['crunch_worker_state']
35 if node['uuid'] == nodes(:busy).uuid
36 found_busy_node = true
37 assert_equal 'busy', node['crunch_worker_state']
40 assert_equal true, found_busy_node
43 test "node should ping with ping_secret and no token" do
45 id: 'zzzzz-7ekkf-2z3mc76g2q73aio',
46 instance_id: 'i-0000000',
47 local_ipv4: '172.17.2.174',
48 ping_secret: '69udawxvn3zzj45hs8bumvndricrha4lcpi23pd69e44soanc0'
50 assert_response :success
51 response = JSON.parse(@response.body)
52 assert_equal 'zzzzz-7ekkf-2z3mc76g2q73aio', response['uuid']
53 # Ensure we are getting the "superuser" attributes, too
54 assert_not_nil response['first_ping_at'], '"first_ping_at" attr missing'
55 assert_not_nil response['info'], '"info" attr missing'
56 assert_not_nil response['nameservers'], '"nameservers" attr missing'
59 test "node should fail ping with invalid ping_secret" do
61 id: 'zzzzz-7ekkf-2z3mc76g2q73aio',
62 instance_id: 'i-0000000',
63 local_ipv4: '172.17.2.174',
64 ping_secret: 'dricrha4lcpi23pd69e44soanc069udawxvn3zzj45hs8bumvn'
72 assert_response :success
73 assert_not_nil json_response['uuid']
74 assert_not_nil json_response['info'].is_a? Hash
75 assert_not_nil json_response['info']['ping_secret']