X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a8bf5ded794ad2b59e65d8a681b79d727f899402..f91c73aba940adf1e9fbd530d102931af45a63c5:/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb diff --git a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb index 2d12eb9d24..2cda44f4e4 100644 --- a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb +++ b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase - test "add keep node with admin token" do + test "add keep disk with admin token" do authorize_with :admin post :ping, { ping_secret: '', # required by discovery doc, but ignored @@ -13,13 +13,13 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase } assert_response :success assert_not_nil assigns(:object) - new_keep_node = JSON.parse(@response.body) - assert_not_nil new_keep_node['uuid'] - assert_not_nil new_keep_node['ping_secret'] - assert_not_equal '', new_keep_node['ping_secret'] + new_keep_disk = JSON.parse(@response.body) + assert_not_nil new_keep_disk['uuid'] + assert_not_nil new_keep_disk['ping_secret'] + assert_not_equal '', new_keep_disk['ping_secret'] end - test "refuse to add keep node with no filesystem_uuid" do + test "add keep disk with no filesystem_uuid" do authorize_with :admin opts = { ping_secret: '', @@ -28,12 +28,15 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase service_ssl_flag: false } post :ping, opts - assert_response 404 + assert_response :success + assert_not_nil JSON.parse(@response.body)['uuid'] + post :ping, opts.merge(filesystem_uuid: '') - assert_response 404 + assert_response :success + assert_not_nil JSON.parse(@response.body)['uuid'] end - test "refuse to add keep node without admin token" do + test "refuse to add keep disk without admin token" do post :ping, { ping_secret: '', service_host: '::1', @@ -43,20 +46,20 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase assert_response 404 end - test "ping from keep node" do + test "ping keep disk" do post :ping, { - uuid: keep_disks(:nonfull).uuid, + id: keep_disks(:nonfull).uuid, ping_secret: keep_disks(:nonfull).ping_secret, filesystem_uuid: keep_disks(:nonfull).filesystem_uuid } assert_response :success assert_not_nil assigns(:object) - keep_node = JSON.parse(@response.body) - assert_not_nil keep_node['uuid'] - assert_not_nil keep_node['ping_secret'] + keep_disk = JSON.parse(@response.body) + assert_not_nil keep_disk['uuid'] + assert_not_nil keep_disk['ping_secret'] end - test "should get index with ping_secret" do + test "admin should get index with ping_secret" do authorize_with :admin get :index assert_response :success @@ -66,13 +69,13 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase assert_not_nil items[0]['ping_secret'] end - # inactive user does not see any keep disks - test "inactive user should get empty index" do + # inactive user sees keep disks + test "inactive user should get index" do authorize_with :inactive get :index assert_response :success items = JSON.parse(@response.body)['items'] - assert_equal 0, items.size + assert_not_equal 0, items.size end # active user sees non-secret attributes of keep disks @@ -91,4 +94,32 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase end end + test "search keep_disks by service_port with >= query" do + authorize_with :active + get :index, { + filters: [['service_port', '>=', 25107]] + } + assert_response :success + assert_equal true, assigns(:objects).any? + end + + test "search keep_disks by service_port with < query" do + authorize_with :active + get :index, { + filters: [['service_port', '<', 25107]] + } + assert_response :success + assert_equal false, assigns(:objects).any? + end + + test "search keep_disks with 'any' operator" do + authorize_with :active + get :index, { + where: { any: ['contains', 'o2t1q5w'] } + } + assert_response :success + found = assigns(:objects).collect(&:uuid) + assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn') + end + end