15306: Adds more test cases confirming the issue is encoding independent.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 4 Jun 2019 23:32:13 +0000 (20:32 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 4 Jun 2019 23:32:13 +0000 (20:32 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/api/test/functional/arvados/v1/collections_controller_test.rb
services/api/test/integration/collections_api_test.rb

index 4e8b0559aabf519ac9b598e385f1a5432a9a9f85..d8017881d5dd151029485066833ff7ab651eea0c 100644 (file)
@@ -1128,14 +1128,20 @@ EOS
     end
   end
 
-  test 'get trashed collection with include_trash' do
-    uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih' # expired_collection
-    authorize_with :active
-    get :show, params: {
-      id: uuid,
-      include_trash: true,
-    }
-    assert_response 200
+  [true, false].each do |include_trash|
+    test "get trashed collection with include_trash=#{include_trash}" do
+      uuid = 'zzzzz-4zz18-mto52zx1s7sn3ih' # expired_collection
+      authorize_with :active
+      get :show, params: {
+        id: uuid,
+        include_trash: include_trash,
+      }
+      if include_trash
+        assert_response 200
+      else
+        assert_response 404
+      end
+    end
   end
 
   [:admin, :active].each do |user|
index 49c3cb425f53b28462d59f2c4526b7044709702b..7bbae6e350d1febb29149d089f2e247d6243a48c 100644 (file)
@@ -275,6 +275,40 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     end
   end
 
+  [
+    ["false", false],
+    ["0", false],
+    ["true", true],
+    ["1", true]
+  ].each do |param, truthiness|
+    test "include_trash=#{param.inspect} param JSON-encoded should be interpreted as include_trash=#{truthiness}" do
+      expired_col = collections(:expired_collection)
+      assert expired_col.is_trashed
+      # Try #index first
+      get "/arvados/v1/collections",
+          params: {
+            :include_trash => param,
+            :filters => [['uuid', '=', expired_col.uuid]].to_json
+          },
+          headers: auth(:active)
+      assert_response :success
+      assert_not_nil json_response['items']
+      assert_equal truthiness, json_response['items'].collect {|c| c['uuid']}.include?(expired_col.uuid)
+      # Try #show next
+      get "/arvados/v1/collections/#{expired_col.uuid}",
+        params: {
+          :format => :json,
+          :include_trash => param,
+        },
+        headers: auth(:active)
+      if truthiness
+        assert_response :success
+      else
+        assert_response 404
+      end
+    end
+  end
+
   [
     ["false", false],
     ["0", false],
@@ -324,7 +358,7 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
       assert_not_nil json_response['items']
       assert_equal truthiness, json_response['items'].collect {|c| c['uuid']}.include?(expired_col.uuid)
       # Try #show next
-      get "/arvados/v1/collections",
+      get "/arvados/v1/collections/#{expired_col.uuid}",
         params: URI.encode_www_form([['include_trash', param]]),
         headers: {
           "Content-type" => "application/x-www-form-urlencoded"