Merge branch '1579-keep-server-in-docker' of git.clinicalfuture.com:arvados into...
[arvados.git] / services / api / test / functional / arvados / v1 / nodes_controller_test.rb
index 49d3a30d201188faf9cced3c55890b0482dd5048..0c18d5f68d02ce122e7714420b488fca85eb2720 100644 (file)
@@ -12,14 +12,32 @@ class Arvados::V1::NodesControllerTest < ActionController::TestCase
     assert_not_nil node_items[0]['info'].andand['ping_secret']
   end
 
-  # inactive user should not see any nodes
-  test "should get index without ping_secret" do
+  # inactive user does not see any nodes
+  test "inactive user should get empty index" do
     authorize_with :inactive
     get :index
     assert_response :success
     node_items = JSON.parse(@response.body)['items']
+    assert_equal 0, node_items.size
+  end
+
+  # active user sees non-secret attributes of up and recently-up nodes
+  test "active user should get non-empty index with no ping_secret" do
+    authorize_with :active
+    get :index
+    assert_response :success
+    node_items = JSON.parse(@response.body)['items']
     assert_not_equal 0, node_items.size
-    assert_nil node_items[0]['info'].andand['ping_secret']
+    found_busy_node = false
+    node_items.each do |node|
+      assert_nil node['info'].andand['ping_secret']
+      assert_not_nil node['crunch_worker_state']
+      if node['uuid'] == nodes(:busy).uuid
+        found_busy_node = true
+        assert_equal 'busy', node['crunch_worker_state']
+      end
+    end
+    assert_equal true, found_busy_node
   end
 
 end