[ARVADOS] updated: b9f14b6879bf41c023e60867db17c25437f3653b

Git user git at public.curoverse.com
Fri Jul 1 10:30:00 EDT 2016


Summary of changes:
 .../controllers/arvados/v1/groups_controller.rb    | 16 ++++++++++++---
 services/api/test/integration/groups_test.rb       | 24 +++++++++++++++-------
 2 files changed, 30 insertions(+), 10 deletions(-)

       via  b9f14b6879bf41c023e60867db17c25437f3653b (commit)
      from  cf705d5577d32332bc7b9b97dde6c75edcf68ae6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b9f14b6879bf41c023e60867db17c25437f3653b
Author: radhika <radhika at curoverse.com>
Date:   Fri Jul 1 10:28:55 2016 -0400

    9498: improve <type_name.field_name> filter check and raise errors when invalid.

diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb
index dc824ca..453feda 100644
--- a/services/api/app/controllers/arvados/v1/groups_controller.rb
+++ b/services/api/app/controllers/arvados/v1/groups_controller.rb
@@ -86,10 +86,20 @@ class Arvados::V1::GroupsController < ApplicationController
       @filters = request_filters.map do |col, op, val|
         if !col.index('.')
           [col, op, val]
-        elsif (col = col.split('.', 2))[0] == klass.table_name
-          [col[1], op, val]
         else
-          nil
+          cs = col.split('.')
+          if cs.size != 2 || cs[0] == "" || cs[1] == ""
+            raise ArgumentError.new("Invalid attribute '#{col}' in filter")
+          elsif cs[0] == klass.table_name
+            [cs[1], op, val]
+          else
+            begin
+              cs[0].classify.constantize
+              nil
+            rescue
+              raise ArgumentError.new("Invalid attribute '#{col}' in filter")
+            end
+          end
         end
       end.compact
 
diff --git a/services/api/test/integration/groups_test.rb b/services/api/test/integration/groups_test.rb
index 77f503f..a60b1b1 100644
--- a/services/api/test/integration/groups_test.rb
+++ b/services/api/test/integration/groups_test.rb
@@ -93,18 +93,28 @@ class GroupsTest < ActionDispatch::IntegrationTest
   end
 
   [
-    [['owner_uuid', '!=', 'zzzzz-tpzed-xurymjxw79nv3jz'], 200],
-    [['no_such_table.uuid', '!=', 'zzzzz-tpzed-xurymjxw79nv3jz'], 200], # all other supported klass objects are returned
-    [["pipeline_instances.state", "not in", ["Complete", "Failed"]], 200],
-    [['container_requests.requesting_container_uuid', '=', nil], 200],
+    [['owner_uuid', '!=', 'zzzzz-tpzed-xurymjxw79nv3jz'], 200,
+        'zzzzz-d1hrv-subprojpipeline', 'zzzzz-d1hrv-1xfj6xkicf2muk2'],
+    [["pipeline_instances.state", "not in", ["Complete", "Failed"]], 200,
+        'zzzzz-d1hrv-1xfj6xkicf2muk2', 'zzzzz-d1hrv-i3e77t9z5y8j9cc'],
+    [['container_requests.requesting_container_uuid', '=', nil], 200,
+        'zzzzz-xvhdp-cr4queuedcontnr', 'zzzzz-xvhdp-cr4requestercn2'],
     [['container_requests.no_such_column', '=', nil], 422],
-  ].each do |filter, resp|
+    [['container_requests.', '=', nil], 422],
+    [['.requesting_container_uuid', '=', nil], 422],
+    [['no_such_table.uuid', '!=', 'zzzzz-tpzed-xurymjxw79nv3jz'], 422],
+  ].each do |filter, expect_code, expect_uuid, not_expect_uuid|
     test "get contents with '#{filter}' filter" do
       get "/arvados/v1/groups/contents", {
         :filters => [filter].to_json
       }, auth(:active)
-      assert_response resp
-      assert_not_empty json_response['items'] if resp == 200
+      assert_response expect_code
+      if expect_code == 200
+        assert_not_empty json_response['items']
+        item_uuids = json_response['items'].collect {|item| item['uuid']}
+        assert_includes(item_uuids, expect_uuid)
+        assert_not_includes(item_uuids, not_expect_uuid)
+      end
     end
   end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list