X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/40df5992d4d8071a6e10a20ecdeb0470a80764cc..b6487d6773406f0da6724e24ad5ce6a94e1009cd:/services/api/test/functional/arvados/v1/collections_controller_test.rb diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb index e4bbd5cd25..9c7f4886af 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -21,7 +21,52 @@ class Arvados::V1::CollectionsControllerTest < ActionController::TestCase authorize_with :active get :index assert_response :success - assert_not_nil assigns(:objects) + assert(assigns(:objects).andand.any?, "no Collections returned in index") + refute(json_response["items"].any? { |c| c.has_key?("manifest_text") }, + "basic Collections index included manifest_text") + end + + test "can get non-database fields via index select" do + authorize_with :active + get(:index, filters: [["uuid", "=", collections(:foo_file).uuid]], + select: %w(uuid owner_uuid files)) + assert_response :success + assert_equal(1, json_response["items"].andand.size, + "wrong number of items returned for index") + assert_equal([[".", "foo", 3]], json_response["items"].first["files"], + "wrong file list in index result") + end + + test "can select only non-database fields for index" do + authorize_with :active + get(:index, select: %w(data_size files)) + assert_response :success + assert(json_response["items"].andand.any?, "no items found in index") + json_response["items"].each do |coll| + assert_equal(coll["data_size"], + coll["files"].inject(0) { |size, fspec| size + fspec.last }, + "mismatch between data size and file list") + end + end + + test "index with manifest_text selected returns signed locators" do + columns = %w(uuid owner_uuid data_size files manifest_text) + authorize_with :active + get :index, select: columns + assert_response :success + assert(assigns(:objects).andand.any?, + "no Collections returned for index with columns selected") + json_response["items"].each do |coll| + assert_equal(columns, columns & coll.keys, + "Collections index did not respect selected columns") + loc_regexp = / [[:xdigit:]]{32}\+\d+\S+/ + pos = 0 + while match = loc_regexp.match(coll["manifest_text"], pos) + assert_match(/\+A[[:xdigit:]]+@[[:xdigit:]]{8}\b/, match.to_s, + "Locator in manifest_text was not signed") + pos = match.end(0) + end + end end [0,1,2].each do |limit|