fix tests and behavior for nodes#list as called by inactive user. refs #1594
[arvados.git] / services / api / test / functional / arvados / v1 / nodes_controller_test.rb
1 require 'test_helper'
2
3 class Arvados::V1::NodesControllerTest < ActionController::TestCase
4
5   test "should get index with ping_secret" do
6     authorize_with :admin
7     get :index
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']
13   end
14
15   # inactive user does not see any nodes
16   test "inactive user should get empty index" do
17     authorize_with :inactive
18     get :index
19     assert_response :success
20     node_items = JSON.parse(@response.body)['items']
21     assert_equal 0, node_items.size
22   end
23
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
27     get :index
28     assert_response :success
29     node_items = JSON.parse(@response.body)['items']
30     assert_not_equal 0, node_items.size
31     node_items.each do |node|
32       assert_nil node['info'].andand['ping_secret']
33     end
34   end
35
36 end