2659: Token fail during download is 404 when anon token is enabled, 302 otherwise.
authorTom Clegg <tom@curoverse.com>
Wed, 4 Feb 2015 00:24:33 +0000 (19:24 -0500)
committerTom Clegg <tom@curoverse.com>
Wed, 4 Feb 2015 00:24:58 +0000 (19:24 -0500)
apps/workbench/test/controllers/collections_controller_test.rb

index b92fa429dedc39f34d24538f2d8f072fd2134f90..95c0a57db1fdf72d6ffbd98a75ca9aab06db6d98 100644 (file)
@@ -176,13 +176,20 @@ class CollectionsControllerTest < ActionController::TestCase
 
   [false, api_fixture('api_client_authorizations')['anonymous']['api_token']].
     each do |anon_conf|
-    test "trying to get from Keep with an unscoped reader token prompts login (anon_configured=#{anon_conf})" do
+    test "download a file using a reader token with insufficient scope (anon_conf=#{!!anon_conf})" do
       Rails.configuration.anonymous_user_token = anon_conf
       params = collection_params(:foo_file, 'foo')
       params[:reader_token] =
         api_fixture('api_client_authorizations')['active_noscope']['api_token']
       get(:show_file, params)
-      assert_response :redirect
+      if anon_conf
+        # Some files can be shown without a valid token, but not this one.
+        assert_response 404
+      else
+        # No files will ever be shown without a valid token. You
+        # should log in and try again.
+        assert_response :redirect
+      end
     end
   end