X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5b3187552676947ee74e4b652e7a04d3d9b9a3a4..19ae770973482257117fe8ded5619c3018c4b60f:/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 1418f69c35..a8583be12b 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -809,4 +809,82 @@ EOS assert_not_nil json_response['uuid'] assert_equal 'value_1', json_response['properties']['property_1'] end + + [ + ". 0:0:foo.txt", + ". d41d8cd98f00b204e9800998ecf8427e foo.txt", + "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt", + ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt", + ].each do |manifest_text| + test "create collection with invalid manifest #{manifest_text} and expect error" do + authorize_with :active + post :create, { + collection: { + manifest_text: manifest_text, + portable_data_hash: "d41d8cd98f00b204e9800998ecf8427e+0" + } + } + assert_response 422 + response_errors = json_response['errors'] + assert_not_nil response_errors, 'Expected error in response' + assert(response_errors.first.include?('Invalid manifest'), + "Expected 'Invalid manifest' error in #{response_errors.first}") + end + end + + [ + [nil, "d41d8cd98f00b204e9800998ecf8427e+0"], + ["", "d41d8cd98f00b204e9800998ecf8427e+0"], + [". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n", "d30fe8ae534397864cb96c544f4cf102+47"], + ].each do |manifest_text, pdh| + test "create collection with valid manifest #{manifest_text.inspect} and expect success" do + authorize_with :active + post :create, { + collection: { + manifest_text: manifest_text, + portable_data_hash: pdh + } + } + assert_response 200 + end + end + + [ + ". 0:0:foo.txt", + ". d41d8cd98f00b204e9800998ecf8427e foo.txt", + "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt", + ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt", + ].each do |manifest_text| + test "update collection with invalid manifest #{manifest_text} and expect error" do + authorize_with :active + post :update, { + id: 'zzzzz-4zz18-bv31uwvy3neko21', + collection: { + manifest_text: manifest_text, + } + } + assert_response 422 + response_errors = json_response['errors'] + assert_not_nil response_errors, 'Expected error in response' + assert(response_errors.first.include?('Invalid manifest'), + "Expected 'Invalid manifest' error in #{response_errors.first}") + end + end + + [ + nil, + "", + ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n", + ].each do |manifest_text| + test "update collection with valid manifest #{manifest_text.inspect} and expect success" do + authorize_with :active + post :update, { + id: 'zzzzz-4zz18-bv31uwvy3neko21', + collection: { + manifest_text: manifest_text, + } + } + assert_response 200 + end + end end