X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/73e28547278ddff84847c12ad7f926e717ae553a..8b7ed36ff057c4a483f4ee8a1c66929425b366c6:/services/api/test/integration/collections_api_test.rb diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb index 8856fd509b..76805922be 100644 --- a/services/api/test/integration/collections_api_test.rb +++ b/services/api/test/integration/collections_api_test.rb @@ -15,6 +15,42 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest assert_equal "arvados#collectionList", json_response['kind'] end + test "get index with invalid filters (array of strings) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :filters => ['uuid', '=', 'ad02e37b6a7f45bbe2ead3c29a109b8a+54'].to_json + }, auth(:active) + assert_response 422 + assert_match /nvalid element.*not an array/, json_response['errors'].join(' ') + end + + test "get index with invalid filters (unsearchable column) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :filters => [['this_column_does_not_exist', '=', 'bogus']].to_json + }, auth(:active) + assert_response 422 + assert_match /nvalid attribute/, json_response['errors'].join(' ') + end + + test "get index with invalid filters (invalid operator) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :filters => [['uuid', ':-(', 'displeased']].to_json + }, auth(:active) + assert_response 422 + assert_match /nvalid operator/, json_response['errors'].join(' ') + end + + test "get index with invalid filters (invalid operand type) responds 422" do + get "/arvados/v1/collections", { + :format => :json, + :filters => [['uuid', '=', {foo: 'bar'}]].to_json + }, auth(:active) + assert_response 422 + assert_match /nvalid operand type/, json_response['errors'].join(' ') + end + test "get index with where= (empty string)" do get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active) assert_response :success @@ -36,11 +72,66 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest end test "store collection as json" do + signing_opts = { + key: Rails.configuration.blob_signing_key, + api_token: api_token(:active), + } + signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44', + signing_opts) + post "/arvados/v1/collections", { + format: :json, + collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}" + }, auth(:active) + assert_response 200 + assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash'] + end + + test "store collection with manifest_text only" do + signing_opts = { + key: Rails.configuration.blob_signing_key, + api_token: api_token(:active), + } + signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44', + signing_opts) post "/arvados/v1/collections", { format: :json, - collection: "{\"manifest_text\":\". bad42fa702ae3ea7d888fef11b46f450+44 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}" + collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\"}" }, auth(:active) assert_response 200 - assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['uuid'] + assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash'] end + + test "store collection then update name" do + signing_opts = { + key: Rails.configuration.blob_signing_key, + api_token: api_token(:active), + } + signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44', + signing_opts) + post "/arvados/v1/collections", { + format: :json, + collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}" + }, auth(:active) + assert_response 200 + assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash'] + + put "/arvados/v1/collections/#{json_response['uuid']}", { + format: :json, + collection: { name: "a name" } + }, auth(:active) + + assert_response 200 + assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash'] + assert_equal 'a name', json_response['name'] + + get "/arvados/v1/collections/#{json_response['uuid']}", { + format: :json, + }, auth(:active) + + assert_response 200 + assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash'] + assert_equal 'a name', json_response['name'] + end + + end