assert_equal 'a name', json_response['name']
end
+ test "create collection, verify file_names not returned, and search with filename" do
+ signing_opts = {
+ key: Rails.configuration.blob_signing_key,
+ api_token: api_token(:active),
+ }
+ signed_locator = Blob.sign_locator('bad42fa702ae3ea7d999fef11b46f450+44', signing_opts)
+ post "/arvados/v1/collections", {
+ format: :json,
+ collection: "{\"manifest_text\":\". #{signed_locator} 0:44:my_test_file.txt\\n\"}"
+ }, auth(:active)
+ assert_response 200
+ assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', json_response['portable_data_hash']
+ assert_nil json_response['description']
+ assert_nil json_response['file_names']
+
+ put "/arvados/v1/collections/#{json_response['uuid']}", {
+ format: :json,
+ collection: { description: "my test collection description" }
+ }, auth(:active)
+ assert_response :success
+ assert_equal 'my test collection description', json_response['description']
+ assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', json_response['portable_data_hash']
+ assert_nil json_response['file_names']
+
+ get '/arvados/v1/collections', {
+ where: { any: ['contains', '87beb13dec46d36db9fa'] }
+ }, auth(:active)
+ assert_response :success
+ response_items = json_response['items']
+ assert_not_nil response_items
+ first_item = json_response['items'].first
+ assert_not_nil first_item
+ assert_equal 'my test collection description', first_item['description']
+ assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', first_item['portable_data_hash']
+ assert_nil first_item['file_names']
+
+ get '/arvados/v1/collections', {
+ where: { any: ['contains', 'my_test_file.txt'] }
+ }, auth(:active)
+ assert_response :success
+ response_items = json_response['items']
+ assert_not_nil response_items
+ assert_equal 1, response_items.size
+ first_item = response_items.first
+ assert_not_nil first_item
+ assert_equal 'my test collection description', first_item['description']
+ assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', first_item['portable_data_hash']
+ assert_nil first_item['file_names']
+
+ get '/arvados/v1/collections', {
+ where: { any: ['contains', 'there_is_no_such_file.txt'] }
+ }, auth(:active)
+ assert_response :success
+ assert_equal 0, json_response['items_available']
+ response_items = json_response['items']
+ assert_not_nil response_items
+ assert_equal 0, response_items.size
+ end
end
end
end
- test 'create collection with large manifest text and verify file_names' do
- act_as_system_user do
- manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0"
- index = 0
- while manifest_text.length < 2**15
- manifest_text += ' ' + "0:0:foo#{index}.txt"
- index += 1
- end
- manifest_text += "\n"
+ [
+ [2**15, 0, false],
+ [2**15, 100, false],
+ [2**15, 2**13, false],
+ [2**15, 2**18, true],
+ [100, 2**18, true],
+ [2**18, 100, false], # file_names has a max size, hence no error even on large manifest
+ ].each do |manifest_size, description_size, expect_exception|
+ test "create collection with manifest size #{manifest_size},
+ description size #{description_size},
+ expect exception #{expect_exception}" do
+ act_as_system_user do
+ manifest_text = '. d41d8cd98f00b204e9800998ecf8427e+0'
+ index = 0
+ while manifest_text.length < manifest_size
+ manifest_text += ' ' + "0:0:longlongfile#{index}.txt"
+ index += 1
+ end
+ manifest_text += "\n"
- c = Collection.create(manifest_text: manifest_text)
+ description = ''
+ while description.length < description_size
+ description += 'a'
+ end
- assert c.valid?
- created_file_names = c.file_names
- assert created_file_names
+ begin
+ c = Collection.create(manifest_text: manifest_text, description: description)
+ rescue Exception => e
+ end
+
+ if !expect_exception
+ assert c.valid?
+ created_file_names = c.file_names
+ assert created_file_names
+ else
+ assert e
+ assert e.message.include? 'exceeds maximum'
+ end
+ end
end
end