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>

1  2 
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,625a6a8f61792fd5f6f92fb0ffb8c3293dce0ec7..f8fcf5108f025659bf5058f2861ef42d2e1b5781
@@@ -1,7 -1,3 +1,7 @@@
 +# Copyright (C) The Arvados Authors. All rights reserved.
 +#
 +# SPDX-License-Identifier: AGPL-3.0
 +
  require "arvados/keep"
  require "arvados/collection"
  require "uri"
@@@ -24,7 -20,7 +24,7 @@@ class CollectionsController < Applicati
    RELATION_LIMIT = 5
  
    def show_pane_list
 -    panes = %w(Files Upload Provenance_graph Used_by Advanced)
 +    panes = %w(Files Upload Tags Provenance_graph Used_by Advanced)
      panes = panes - %w(Upload) unless (@object.editable? rescue false)
      panes
    end
    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
    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
      end
    end
  
 +  def tags
 +    render
 +  end
 +
 +  def save_tags
 +    tags_param = params['tag_data']
 +    if tags_param
 +      if tags_param.is_a?(String) && tags_param == "empty"
 +        tags = {}
 +      else
 +        tags = tags_param
 +      end
 +    end
 +
 +    if tags
 +      if @object.update_attributes properties: tags
 +        @saved_tags = true
 +        render
 +      else
 +        self.render_error status: 422
 +      end
 +    end
 +  end
 +
    protected
  
    def find_usable_token(token_list)
        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,f2a638f3164bb4fc2b5b47b39df5ea307a065e8a..608cd521de25b5ebd36751993a33455b3719093e
@@@ -1,7 -1,3 +1,7 @@@
 +# Copyright (C) The Arvados Authors. All rights reserved.
 +#
 +# SPDX-License-Identifier: AGPL-3.0
 +
  require 'integration_helper'
  
  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,1098240c964abc3c626e29fbf3d31b89ccb9a424..407458b62bd4c3557e8c21e20b4bde201cfda1e3
@@@ -1,13 -1,11 +1,15 @@@
 +# Copyright (C) The Arvados Authors. All rights reserved.
 +#
 +# SPDX-License-Identifier: AGPL-3.0
 +
  require 'integration_helper'
  require 'helpers/download_helper'
  
  class DownloadTest < ActionDispatch::IntegrationTest
    include KeepWebConfig
  
+   @@wrote_test_data = false
    setup do
      use_keep_web_config
  
  
      # 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 -30,7 +34,7 @@@
        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,8a8f7ad57717ba3d9ddbb81097b430349b25dd47..57efb97c4851ef3b5b678b906bddefb2b05abc83
@@@ -1,7 -1,3 +1,7 @@@
 +# Copyright (C) The Arvados Authors. All rights reserved.
 +#
 +# SPDX-License-Identifier: Apache-2.0
 +
  from __future__ import print_function
  from __future__ import division
  from builtins import str
@@@ -497,14 -493,15 +497,15 @@@ def run_keep(blob_signing_key=None, enf
              '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)))