Merge branch '8784-dir-listings'
authorTom Clegg <tom@curoverse.com>
Wed, 5 Jul 2017 15:39:13 +0000 (11:39 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 5 Jul 2017 15:39:13 +0000 (11:39 -0400)
refs #8784

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curoverse.com>

apps/workbench/app/controllers/collections_controller.rb
apps/workbench/test/integration/collection_upload_test.rb
apps/workbench/test/integration/download_test.rb
sdk/python/tests/run_test_server.py

index 99065947b870d4be7cae6f33b16fffb82ddecb6f..f8fcf5108f025659bf5058f2861ef42d2e1b5781 100644 (file)
@@ -115,6 +115,10 @@ class CollectionsController < ApplicationController
   end
 
   def show_file_links
+    if Rails.configuration.keep_web_url || Rails.configuration.keep_web_download_url
+      # show_file will redirect to keep-web's directory listing
+      return show_file
+    end
     Thread.current[:reader_tokens] = [params[:reader_token]]
     return if false.equal?(find_object_by_uuid)
     render layout: false
@@ -283,7 +287,12 @@ class CollectionsController < ApplicationController
   helper_method :download_link
 
   def download_link
-    collections_url + "/download/#{@object.uuid}/#{@search_sharing.first.api_token}/"
+    token = @search_sharing.first.api_token
+    if Rails.configuration.keep_web_url || Rails.configuration.keep_web_download_url
+      keep_web_url(@object.uuid, nil, {path_token: token})
+    else
+      collections_url + "/download/#{@object.uuid}/#{token}/"
+    end
   end
 
   def share
@@ -444,7 +453,7 @@ class CollectionsController < ApplicationController
       uri.path += 't=' + opts[:path_token] + '/'
     end
     uri.path += '_/'
-    uri.path += URI.escape(file)
+    uri.path += URI.escape(file) if file
 
     query = Hash[URI.decode_www_form(uri.query || '')]
     { query_token: 'api_token',
index e54a5c21853429d143142309a933fb41cf34c2e7..608cd521de25b5ebd36751993a33455b3719093e 100644 (file)
@@ -96,11 +96,11 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest
   test "Report network error" do
     need_selenium "to make file uploads work"
     use_token :admin do
-      # Even if you somehow do port>2^16, surely nx.example.net won't
+      # Even if port 0 is a thing, surely nx.example.net won't
       # respond
       KeepService.where(service_type: 'proxy').first.
         update_attributes(service_host: 'nx.example.net',
-                          service_port: 99999)
+                          service_port: 0)
     end
     visit page_with_token 'active', sandbox_path
 
index 37faef9c3d780f81834ab053d354a4391fea968e..407458b62bd4c3557e8c21e20b4bde201cfda1e3 100644 (file)
@@ -8,6 +8,8 @@ require 'helpers/download_helper'
 class DownloadTest < ActionDispatch::IntegrationTest
   include KeepWebConfig
 
+  @@wrote_test_data = false
+
   setup do
     use_keep_web_config
 
@@ -17,10 +19,13 @@ class DownloadTest < ActionDispatch::IntegrationTest
 
     # Keep data isn't populated by fixtures, so we have to write any
     # data we expect to read.
-    ['foo', 'w a z', "Hello world\n"].each do |data|
-      md5 = `echo -n #{data.shellescape} | arv-put --no-progress --raw -`
-      assert_match /^#{Digest::MD5.hexdigest(data)}/, md5
-      assert $?.success?, $?
+    if !@@wrote_test_data
+      ['foo', 'w a z', "Hello world\n"].each do |data|
+        md5 = `echo -n #{data.shellescape} | arv-put --no-progress --raw -`
+        assert_match /^#{Digest::MD5.hexdigest(data)}/, md5
+        assert $?.success?, $?
+      end
+      @@wrote_test_data = true
     end
   end
 
@@ -29,7 +34,7 @@ class DownloadTest < ActionDispatch::IntegrationTest
       uuid_or_pdh = api_fixture('collections')['foo_file'][id_type]
       token = api_fixture('api_client_authorizations')['active_all_collections']['api_token']
       visit "/collections/download/#{uuid_or_pdh}/#{token}/"
-      within "#collection_files" do
+      within 'ul' do
         click_link 'foo'
       end
       assert_no_selector 'a'
index f571bdbfdd2d00c9cdb698da9fbe75b6c41b563f..57efb97c4851ef3b5b678b906bddefb2b05abc83 100644 (file)
@@ -497,14 +497,15 @@ def run_keep(blob_signing_key=None, enforce_permissions=False, num_servers=2):
             'keep_disk': {'keep_service_uuid': svc['uuid'] }
         }).execute()
 
-    # If keepproxy is running, send SIGHUP to make it discover the new
-    # keepstore services.
-    proxypidfile = _pidfile('keepproxy')
-    if os.path.exists(proxypidfile):
-        try:
-            os.kill(int(open(proxypidfile).read()), signal.SIGHUP)
-        except OSError:
-            os.remove(proxypidfile)
+    # If keepproxy and/or keep-web is running, send SIGHUP to make
+    # them discover the new keepstore services.
+    for svc in ('keepproxy', 'keep-web'):
+        pidfile = _pidfile('keepproxy')
+        if os.path.exists(pidfile):
+            try:
+                os.kill(int(open(pidfile).read()), signal.SIGHUP)
+            except OSError:
+                os.remove(pidfile)
 
 def _stop_keep(n):
     kill_server_pid(_pidfile('keep{}'.format(n)))