1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class CollectionsControllerTest < ActionController::TestCase
8 # These tests don't do state-changing API calls. Save some time by
9 # skipping the database reset.
10 reset_api_fixtures :after_each_test, false
11 reset_api_fixtures :after_suite, true
13 include PipelineInstancesHelper
15 NONEXISTENT_COLLECTION = "ffffffffffffffffffffffffffffffff+0"
17 def config_anonymous enable
18 Rails.configuration.anonymous_user_token =
20 api_token('anonymous')
26 def collection_params(collection_name, file_name=nil)
27 uuid = api_fixture('collections')[collection_name.to_s]['uuid']
28 params = {uuid: uuid, id: uuid}
29 params[:file] = file_name if file_name
33 def assert_hash_includes(actual_hash, expected_hash, msg=nil)
34 expected_hash.each do |key, value|
35 assert_equal(value, actual_hash[key], msg)
40 assert_hash_includes(session, {arvados_api_token: nil},
41 "session includes unexpected API token")
44 def assert_session_for_auth(client_auth)
46 self.api_token(client_auth.to_s)
47 assert_hash_includes(session, {arvados_api_token: api_token},
48 "session token does not belong to #{client_auth}")
51 def show_collection(params, session={}, response=:success)
52 params = collection_params(params) if not params.is_a? Hash
53 session = session_for(session) if not session.is_a? Hash
54 get(:show, params, session)
55 assert_response response
58 test "viewing a collection" do
59 show_collection(:foo_file, :active)
60 assert_equal([['.', 'foo', 3]], assigns(:object).files)
63 test "viewing a collection with spaces in filename" do
64 show_collection(:w_a_z_file, :active)
65 assert_equal([['.', 'w a z', 5]], assigns(:object).files)
68 test "download a file with spaces in filename" do
70 collection = api_fixture('collections')['w_a_z_file']
72 uuid: collection['uuid'],
74 }, session_for(:active)
75 assert_response :redirect
76 assert_match /w%20a%20z/, response.redirect_url
79 test "viewing a collection fetches related projects" do
80 show_collection({id: api_fixture('collections')["foo_file"]['portable_data_hash']}, :active)
81 assert_includes(assigns(:same_pdh).map(&:owner_uuid),
82 api_fixture('groups')['aproject']['uuid'],
83 "controller did not find linked project")
86 test "viewing a collection fetches related permissions" do
87 show_collection(:bar_file, :active)
88 assert_includes(assigns(:permissions).map(&:uuid),
89 api_fixture('links')['bar_file_readable_by_active']['uuid'],
90 "controller did not find permission link")
93 test "viewing a collection fetches jobs that output it" do
94 show_collection(:bar_file, :active)
95 assert_includes(assigns(:output_of).map(&:uuid),
96 api_fixture('jobs')['foobar']['uuid'],
97 "controller did not find output job")
100 test "viewing a collection fetches jobs that logged it" do
101 show_collection(:baz_file, :active)
102 assert_includes(assigns(:log_of).map(&:uuid),
103 api_fixture('jobs')['foobar']['uuid'],
104 "controller did not find logger job")
107 test "sharing auths available to admin" do
108 show_collection("collection_owned_by_active", "admin_trustedclient")
109 assert_not_nil assigns(:search_sharing)
112 test "sharing auths available to owner" do
113 show_collection("collection_owned_by_active", "active_trustedclient")
114 assert_not_nil assigns(:search_sharing)
117 test "sharing auths available to reader" do
118 show_collection("foo_collection_in_aproject",
119 "project_viewer_trustedclient")
120 assert_not_nil assigns(:search_sharing)
123 test "viewing collection files with a reader token" do
124 params = collection_params(:foo_file)
125 params[:reader_token] = api_token("active_all_collections")
126 get(:show_file_links, params)
127 assert_response :redirect
131 test "fetching collection file with reader token" do
133 params = collection_params(:foo_file, "foo")
134 params[:reader_token] = api_token("active_all_collections")
135 get(:show_file, params)
136 assert_response :redirect
137 assert_match /foo/, response.redirect_url
141 test "reader token Collection links end with trailing slash" do
142 # Testing the fix for #2937.
143 session = session_for(:active_trustedclient)
144 post(:share, collection_params(:foo_file), session)
145 assert(@controller.download_link.ends_with? '/',
146 "Collection share link does not end with slash for wget")
149 test "getting a file from Keep" do
151 params = collection_params(:foo_file, 'foo')
152 sess = session_for(:active)
153 get(:show_file, params, sess)
154 assert_response :redirect
155 assert_match /foo/, response.redirect_url
158 test 'anonymous download' do
160 config_anonymous true
162 uuid: api_fixture('collections')['user_agreement_in_anonymously_accessible_project']['uuid'],
163 file: 'GNU_General_Public_License,_version_3.pdf',
165 assert_response :redirect
166 assert_match /GNU_General_Public_License/, response.redirect_url
169 test "can't get a file from Keep without permission" do
170 params = collection_params(:foo_file, 'foo')
171 sess = session_for(:spectator)
172 get(:show_file, params, sess)
176 test "getting a file from Keep with a good reader token" do
178 params = collection_params(:foo_file, 'foo')
179 read_token = api_token('active')
180 params[:reader_token] = read_token
181 get(:show_file, params)
182 assert_response :redirect
183 assert_match /foo/, response.redirect_url
184 assert_not_equal(read_token, session[:arvados_api_token],
185 "using a reader token set the session's API token")
188 [false, true].each do |anon|
189 test "download a file using a reader token with insufficient scope, anon #{anon}" do
190 config_anonymous anon
191 params = collection_params(:foo_file, 'foo')
192 params[:reader_token] =
193 api_token('active_noscope')
194 get(:show_file, params)
196 # Some files can be shown without a valid token, but not this one.
199 # No files will ever be shown without a valid token. You
200 # should log in and try again.
201 assert_response :redirect
206 test "can get a file with an unpermissioned auth but in-scope reader token" do
208 params = collection_params(:foo_file, 'foo')
209 sess = session_for(:expired)
210 read_token = api_token('active')
211 params[:reader_token] = read_token
212 get(:show_file, params, sess)
213 assert_response :redirect
214 assert_not_equal(read_token, session[:arvados_api_token],
215 "using a reader token set the session's API token")
218 test "inactive user can retrieve user agreement" do
220 ua_collection = api_fixture('collections')['user_agreement']
221 # Here we don't test whether the agreement can be retrieved from
222 # Keep. We only test that show_file decides to send file content.
224 uuid: ua_collection['uuid'],
225 file: ua_collection['manifest_text'].match(/ \d+:\d+:(\S+)/)[1]
226 }, session_for(:inactive)
227 assert_nil(assigns(:unsigned_user_agreements),
228 "Did not skip check_user_agreements filter " +
229 "when showing the user agreement.")
230 assert_response :redirect
233 test "requesting nonexistent Collection returns 404" do
234 show_collection({uuid: NONEXISTENT_COLLECTION, id: NONEXISTENT_COLLECTION},
238 test "show file in a subdirectory of a collection" do
240 params = collection_params(:collection_with_files_in_subdir, 'subdir2/subdir3/subdir4/file1_in_subdir4.txt')
241 get(:show_file, params, session_for(:user1_with_load))
242 assert_response :redirect
243 assert_match /subdir2\/subdir3\/subdir4\/file1_in_subdir4\.txt/, response.redirect_url
246 test 'provenance graph' do
249 obj = find_fixture Collection, "graph_test_collection3"
251 provenance = obj.provenance.stringify_keys
253 [obj[:portable_data_hash]].each do |k|
254 assert_not_nil provenance[k], "Expected key #{k} in provenance set"
257 prov_svg = ProvenanceHelper::create_provenance_graph(provenance, "provenance_svg",
258 {:request => RequestDuck,
259 :direction => :bottom_up,
260 :combine_jobs => :script_only})
262 stage1 = find_fixture Job, "graph_stage1"
263 stage3 = find_fixture Job, "graph_stage3"
264 previous_job_run = find_fixture Job, "previous_job_run"
266 obj_id = obj.portable_data_hash.gsub('+', '\\\+')
267 stage1_out = stage1.output.gsub('+', '\\\+')
268 stage1_id = "#{stage1.script}_#{Digest::MD5.hexdigest(stage1[:script_parameters].to_json)}"
269 stage3_id = "#{stage3.script}_#{Digest::MD5.hexdigest(stage3[:script_parameters].to_json)}"
271 assert /#{obj_id}->#{stage3_id}/.match(prov_svg)
273 assert /#{stage3_id}->#{stage1_out}/.match(prov_svg)
275 assert /#{stage1_out}->#{stage1_id}/.match(prov_svg)
279 test 'used_by graph' do
281 obj = find_fixture Collection, "graph_test_collection1"
283 used_by = obj.used_by.stringify_keys
285 used_by_svg = ProvenanceHelper::create_provenance_graph(used_by, "used_by_svg",
286 {:request => RequestDuck,
287 :direction => :top_down,
288 :combine_jobs => :script_only,
289 :pdata_only => true})
291 stage2 = find_fixture Job, "graph_stage2"
292 stage3 = find_fixture Job, "graph_stage3"
294 stage2_id = "#{stage2.script}_#{Digest::MD5.hexdigest(stage2[:script_parameters].to_json)}"
295 stage3_id = "#{stage3.script}_#{Digest::MD5.hexdigest(stage3[:script_parameters].to_json)}"
297 obj_id = obj.portable_data_hash.gsub('+', '\\\+')
298 stage3_out = stage3.output.gsub('+', '\\\+')
300 assert /#{obj_id}->#{stage2_id}/.match(used_by_svg)
302 assert /#{obj_id}->#{stage3_id}/.match(used_by_svg)
304 assert /#{stage3_id}->#{stage3_out}/.match(used_by_svg)
306 assert /#{stage3_id}->#{stage3_out}/.match(used_by_svg)
310 test "view collection with empty properties" do
311 fixture_name = :collection_with_empty_properties
312 show_collection(fixture_name, :active)
313 assert_equal(api_fixture('collections')[fixture_name.to_s]['name'], assigns(:object).name)
314 assert_not_nil(assigns(:object).properties)
315 assert_empty(assigns(:object).properties)
318 test "view collection with one property" do
319 fixture_name = :collection_with_one_property
320 show_collection(fixture_name, :active)
321 fixture = api_fixture('collections')[fixture_name.to_s]
322 assert_equal(fixture['name'], assigns(:object).name)
323 assert_equal(fixture['properties'][0], assigns(:object).properties[0])
326 test "create collection with properties" do
329 name: 'collection created with properties',
332 property_1: 'value_1'
336 }, session_for(:active)
337 assert_response :success
338 assert_not_nil assigns(:object).uuid
339 assert_equal 'collection created with properties', assigns(:object).name
340 assert_equal 'value_1', assigns(:object).properties[:property_1]
343 test "update description and check manifest_text is not lost" do
344 collection = api_fixture("collections")["multilevel_collection_1"]
346 id: collection["uuid"],
348 description: 'test description update'
351 }, session_for(:active)
352 assert_response :success
353 assert_not_nil assigns(:object)
354 # Ensure the Workbench response still has the original manifest_text
355 assert_equal 'test description update', assigns(:object).description
356 assert_equal true, strip_signatures_and_compare(collection['manifest_text'], assigns(:object).manifest_text)
357 # Ensure the API server still has the original manifest_text after
358 # we called arvados.v1.collections.update
360 assert_equal true, strip_signatures_and_compare(Collection.find(collection['uuid']).manifest_text,
361 collection['manifest_text'])
365 # Since we got the initial collection from fixture, there are no signatures in manifest_text.
366 # However, after update or find, the collection retrieved will have singed manifest_text.
367 # Hence, let's compare each line after excluding signatures.
368 def strip_signatures_and_compare m1, m2
369 m1_lines = m1.split "\n"
370 m2_lines = m2.split "\n"
372 return false if m1_lines.size != m2_lines.size
374 m1_lines.each_with_index do |line, i|
376 line.split.each do |word|
377 m1_words << word.split('+A')[0]
380 m2_lines[i].split.each do |word|
381 m2_words << word.split('+A')[0]
383 return false if !m1_words.join(' ').eql?(m2_words.join(' '))
389 test "view collection and verify none of the file types listed are disabled" do
390 show_collection(:collection_with_several_supported_file_types, :active)
392 files = assigns(:object).files
393 assert_equal true, files.length>0, "Expected one or more files in collection"
395 disabled = css_select('[disabled="disabled"]').collect do |el|
398 assert_equal 0, disabled.length, "Expected no disabled files in collection viewables list"
401 test "view collection and verify file types listed are all disabled" do
402 show_collection(:collection_with_several_unsupported_file_types, :active)
404 files = assigns(:object).files.collect do |_, file, _|
407 assert_equal true, files.length>0, "Expected one or more files in collection"
409 disabled = css_select('[disabled="disabled"]').collect do |el|
410 el.attributes['title'].value.split[-1]
413 assert_equal files.sort, disabled.sort, "Expected to see all collection files in disabled list of files"
416 test "anonymous user accesses collection in shared project" do
417 config_anonymous true
418 collection = api_fixture('collections')['public_text_file']
419 get(:show, {id: collection['uuid']})
421 response_object = assigns(:object)
422 assert_equal collection['name'], response_object['name']
423 assert_equal collection['uuid'], response_object['uuid']
424 assert_includes @response.body, 'Hello world'
425 assert_includes @response.body, 'Content address'
426 refute_nil css_select('[href="#Advanced"]')
429 test "can view empty collection" do
430 get :show, {id: 'd41d8cd98f00b204e9800998ecf8427e+0'}, session_for(:active)
431 assert_includes @response.body, 'The following collections have this content'
434 test "collection portable data hash redirect" do
435 di = api_fixture('collections')['docker_image']
436 get :show, {id: di['portable_data_hash']}, session_for(:active)
437 assert_match /\/collections\/#{di['uuid']}/, @response.redirect_url
440 test "collection portable data hash with multiple matches" do
441 pdh = api_fixture('collections')['foo_file']['portable_data_hash']
442 get :show, {id: pdh}, session_for(:admin)
443 matches = api_fixture('collections').select {|k,v| v["portable_data_hash"] == pdh}
444 assert matches.size > 1
446 matches.each do |k,v|
447 assert_match /href="\/collections\/#{v['uuid']}">.*#{v['name']}<\/a>/, @response.body
450 assert_includes @response.body, 'The following collections have this content:'
451 assert_not_includes @response.body, 'more results are not shown'
452 assert_not_includes @response.body, 'Activity'
453 assert_not_includes @response.body, 'Sharing and permissions'
456 test "collection page renders name" do
457 collection = api_fixture('collections')['foo_file']
458 get :show, {id: collection['uuid']}, session_for(:active)
459 assert_includes @response.body, collection['name']
460 assert_match /not authorized to manage collection sharing links/, @response.body
463 test "No Upload tab on non-writable collection" do
464 get :show, {id: api_fixture('collections')['user_agreement']['uuid']}, session_for(:active)
465 assert_not_includes @response.body, '<a href="#Upload"'
468 def setup_for_keep_web cfg='https://%{uuid_or_pdh}.example', dl_cfg=false
469 Rails.configuration.keep_web_url = cfg
470 Rails.configuration.keep_web_download_url = dl_cfg
473 %w(uuid portable_data_hash).each do |id_type|
474 test "Redirect to keep_web_url via #{id_type}" do
476 tok = api_token('active')
477 id = api_fixture('collections')['w_a_z_file'][id_type]
478 get :show_file, {uuid: id, file: "w a z"}, session_for(:active)
479 assert_response :redirect
480 assert_equal "https://#{id.sub '+', '-'}.example/_/w%20a%20z?api_token=#{URI.escape tok, '/'}", @response.redirect_url
483 test "Redirect to keep_web_url via #{id_type} with reader token" do
485 tok = api_token('active')
486 id = api_fixture('collections')['w_a_z_file'][id_type]
487 get :show_file, {uuid: id, file: "w a z", reader_token: tok}, session_for(:expired)
488 assert_response :redirect
489 assert_equal "https://#{id.sub '+', '-'}.example/t=#{URI.escape tok}/_/w%20a%20z", @response.redirect_url
492 test "Redirect to keep_web_url via #{id_type} with no token" do
494 config_anonymous true
495 id = api_fixture('collections')['public_text_file'][id_type]
496 get :show_file, {uuid: id, file: "Hello World.txt"}
497 assert_response :redirect
498 assert_equal "https://#{id.sub '+', '-'}.example/_/Hello%20World.txt", @response.redirect_url
501 test "Redirect to keep_web_url via #{id_type} with disposition param" do
503 config_anonymous true
504 id = api_fixture('collections')['public_text_file'][id_type]
507 file: "Hello World.txt",
508 disposition: 'attachment',
510 assert_response :redirect
511 assert_equal "https://#{id.sub '+', '-'}.example/_/Hello%20World.txt?disposition=attachment", @response.redirect_url
514 test "Redirect to keep_web_download_url via #{id_type}" do
515 setup_for_keep_web('https://collections.example/c=%{uuid_or_pdh}',
516 'https://download.example/c=%{uuid_or_pdh}')
517 tok = api_token('active')
518 id = api_fixture('collections')['w_a_z_file'][id_type]
519 get :show_file, {uuid: id, file: "w a z"}, session_for(:active)
520 assert_response :redirect
521 assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{URI.escape tok, '/'}", @response.redirect_url
524 test "Redirect to keep_web_url via #{id_type} when trust_all_content enabled" do
525 Rails.configuration.trust_all_content = true
526 setup_for_keep_web('https://collections.example/c=%{uuid_or_pdh}',
527 'https://download.example/c=%{uuid_or_pdh}')
528 tok = api_token('active')
529 id = api_fixture('collections')['w_a_z_file'][id_type]
530 get :show_file, {uuid: id, file: "w a z"}, session_for(:active)
531 assert_response :redirect
532 assert_equal "https://collections.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{URI.escape tok, '/'}", @response.redirect_url
536 [false, true].each do |anon|
537 test "No redirect to keep_web_url if collection not found, anon #{anon}" do
539 config_anonymous anon
540 id = api_fixture('collections')['w_a_z_file']['uuid']
541 get :show_file, {uuid: id, file: "w a z"}, session_for(:spectator)
545 test "Redirect download to keep_web_download_url, anon #{anon}" do
546 config_anonymous anon
547 setup_for_keep_web('https://collections.example/c=%{uuid_or_pdh}',
548 'https://download.example/c=%{uuid_or_pdh}')
549 tok = api_token('active')
550 id = api_fixture('collections')['public_text_file']['uuid']
553 file: 'Hello world.txt',
554 disposition: 'attachment',
555 }, session_for(:active)
556 assert_response :redirect
557 expect_url = "https://download.example/c=#{id.sub '+', '-'}/_/Hello%20world.txt"
559 expect_url += "?api_token=#{URI.escape tok, '/'}"
561 assert_equal expect_url, @response.redirect_url
565 test "Error if file is impossible to retrieve from keep_web_url" do
566 # Cannot pass a session token using a single-origin keep-web URL,
567 # cannot read this collection without a session token.
568 setup_for_keep_web 'https://collections.example/c=%{uuid_or_pdh}', false
569 id = api_fixture('collections')['w_a_z_file']['uuid']
570 get :show_file, {uuid: id, file: "w a z"}, session_for(:active)
574 [false, true].each do |trust_all_content|
575 test "Redirect preview to keep_web_download_url when preview is disabled and trust_all_content is #{trust_all_content}" do
576 Rails.configuration.trust_all_content = trust_all_content
577 setup_for_keep_web false, 'https://download.example/c=%{uuid_or_pdh}'
578 tok = api_token('active')
579 id = api_fixture('collections')['w_a_z_file']['uuid']
580 get :show_file, {uuid: id, file: "w a z"}, session_for(:active)
581 assert_response :redirect
582 assert_equal "https://download.example/c=#{id.sub '+', '-'}/_/w%20a%20z?api_token=#{URI.escape tok, '/'}", @response.redirect_url
586 test "remove selected files from collection" do
589 # create a new collection to test; using existing collections will cause other tests to fail,
590 # and resetting fixtures after each test makes it take almost 4 times to run this test file.
591 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n"
593 collection = Collection.create(manifest_text: manifest_text)
594 assert_includes(collection['manifest_text'], "0:0:file1")
596 # now remove all files named 'file1' from the collection
597 post :remove_selected_files, {
598 id: collection['uuid'],
599 selection: ["#{collection['uuid']}/file1",
600 "#{collection['uuid']}/dir1/file1"],
602 }, session_for(:active)
603 assert_response :success
605 # verify no 'file1' in the updated collection
606 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
607 assert_not_includes(collection['manifest_text'], "0:0:file1")
608 assert_includes(collection['manifest_text'], "0:0:file2") # but other files still exist
611 test "remove all files from a subdir of a collection" do
614 # create a new collection to test
615 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n"
617 collection = Collection.create(manifest_text: manifest_text)
618 assert_includes(collection['manifest_text'], "0:0:file1")
620 # now remove all files from "dir1" subdir of the collection
621 post :remove_selected_files, {
622 id: collection['uuid'],
623 selection: ["#{collection['uuid']}/dir1/file1",
624 "#{collection['uuid']}/dir1/file2"],
626 }, session_for(:active)
627 assert_response :success
629 # verify that "./dir1" no longer exists in this collection's manifest text
630 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
631 assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1 0:0:file2\n$/, collection['manifest_text']
632 assert_not_includes(collection['manifest_text'], 'dir1')
635 test "rename file in a collection" do
638 # create a new collection to test
639 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n./dir1 d41d8cd98f00b204e9800998ecf8427e+0 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png\n"
641 collection = Collection.create(manifest_text: manifest_text)
642 assert_includes(collection['manifest_text'], "0:0:file1")
644 # rename 'file1' as 'file1renamed' and verify
646 id: collection['uuid'],
648 'rename-file-path:file1' => 'file1renamed'
651 }, session_for(:active)
652 assert_response :success
654 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
655 assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed 0:0:file2\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png\n$/, collection['manifest_text']
657 # now rename 'file2' such that it is moved into 'dir1'
660 id: collection['uuid'],
662 'rename-file-path:file2' => 'dir1/file2'
665 }, session_for(:active)
666 assert_response :success
668 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
669 assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n$/, collection['manifest_text']
671 # now rename 'dir1/dir1file1' such that it is moved into a new subdir
674 id: collection['uuid'],
676 'rename-file-path:dir1/dir1file1' => 'dir2/dir3/dir1file1moved'
679 }, session_for(:active)
680 assert_response :success
682 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
683 assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefile.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
685 # now rename the image file 'dir1/dir1imagefile.png'
688 id: collection['uuid'],
690 'rename-file-path:dir1/dir1imagefile.png' => 'dir1/dir1imagefilerenamed.png'
693 }, session_for(:active)
694 assert_response :success
696 collection = Collection.select([:uuid, :manifest_text]).where(uuid: collection['uuid']).first
697 assert_match /. d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:file1renamed\n.\/dir1 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file2 0:0:dir1imagefilerenamed.png 0:0:file2\n.\/dir2\/dir3 d41d8cd98f00b204e9800998ecf8427e\+0\+A(.*) 0:0:dir1file1moved\n$/, collection['manifest_text']
700 test "renaming file with a duplicate name in same stream not allowed" do
703 # rename 'file2' as 'file1' and expect error
705 id: 'zzzzz-4zz18-pyw8yp9g3pr7irn',
707 'rename-file-path:file2' => 'file1'
710 }, session_for(:active)
712 assert_includes json_response['errors'], 'Duplicate file path'
715 test "renaming file with a duplicate name as another stream not allowed" do
718 # rename 'file1' as 'dir1/file1' and expect error
720 id: 'zzzzz-4zz18-pyw8yp9g3pr7irn',
722 'rename-file-path:file1' => 'dir1/file1'
725 }, session_for(:active)
727 assert_includes json_response['errors'], 'Duplicate file path'