1 require 'integration_helper'
2 require 'helpers/download_helper'
4 class DownloadTest < ActionDispatch::IntegrationTest
6 portfile = File.expand_path '../../../../../tmp/keep-web-ssl.port', __FILE__
7 @kwport = File.read portfile
8 Rails.configuration.keep_web_url = "https://localhost:#{@kwport}/c=%{uuid_or_pdh}"
9 CollectionsController.any_instance.expects(:file_enumerator).never
11 # Make sure Capybara can download files.
12 need_selenium 'for downloading', :selenium_with_download
15 # Keep data isn't populated by fixtures, so we have to write any
16 # data we expect to read.
17 unless /^acbd/ =~ `echo -n foo | arv-put --no-progress --raw -` && $?.success?
22 test "download from keep-web with a reader token" do
23 uuid = api_fixture('collections')['foo_file']['uuid']
24 token = api_fixture('api_client_authorizations')['active_all_collections']['api_token']
25 visit "/collections/download/#{uuid}/#{token}/"
26 within "#collection_files" do
34 data = File.read(DownloadHelper.path.join 'foo') rescue nil
36 assert_equal 'foo', data
39 # TODO(TC): test "view pages hosted by keep-web, using session
40 # token". We might persuade selenium to send
41 # "collection-uuid.dl.example" requests to localhost by configuring
42 # our test nginx server to work as its forward proxy. Until then,
43 # we're relying on the "Redirect to keep_web_url via #{id_type}"
44 # test in CollectionsControllerTest (and keep-web's tests).