17119: add second test, simplify code by switching to the generic
authorWard Vandewege <ward@curii.com>
Wed, 3 Mar 2021 01:07:23 +0000 (20:07 -0500)
committerWard Vandewege <ward@curii.com>
Wed, 3 Mar 2021 18:30:49 +0000 (13:30 -0500)
       /groups/content endpoint.

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/controller/rpc/conn.go
sdk/go/arvados/fs_project_test.go
sdk/go/arvados/fs_site_test.go
services/api/app/controllers/arvados/v1/groups_controller.rb
services/api/lib/fix_roles_projects.rb
services/api/test/fixtures/groups.yml

index 6941e1487cfbd9f8e09243450d00dbbba1cb5311..b61dbd1b3234dcc9c4ba3fbc1207f23e37a4491c 100644 (file)
@@ -483,6 +483,8 @@ func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupConten
                                options.Filters = append(options.Filters, filter)
                        }
                }
+               // Use the generic /groups/contents endpoint for filter groups
+               options.UUID = ""
        }
 
        ep := arvados.EndpointGroupContents
index 56a2bb8264dad719a2e2853605786027e9ba88ef..9d77c31d857cacf4c8c6e5acd95a52d030324985 100644 (file)
@@ -39,10 +39,9 @@ func (sc *spyingClient) RequestAndDecode(dst interface{}, method, path string, b
        return sc.Client.RequestAndDecode(dst, method, path, body, params)
 }
 
-// TestFilterGroup is a very basic filter group test. It makes sure that a
-// collection and group that match the filter are present, and that a group
-// that does not match the filter is not present.
 func (s *SiteFSSuite) TestFilterGroup(c *check.C) {
+       // Make sure that a collection and group that match the filter are present,
+       // and that a group that does not match the filter is not present.
        s.fs.MountProject("fg", fixtureThisFilterGroupUUID)
 
        _, err := s.fs.OpenFile("/fg/baz_file", 0, 0)
@@ -53,6 +52,18 @@ func (s *SiteFSSuite) TestFilterGroup(c *check.C) {
 
        _, err = s.fs.OpenFile("/fg/A Project", 0, 0)
        c.Assert(err, check.Not(check.IsNil))
+
+       // An empty filter means everything that is visible should be returned.
+       s.fs.MountProject("fg2", fixtureAFilterGroupTwoUUID)
+
+       _, err = s.fs.OpenFile("/fg2/baz_file", 0, 0)
+       c.Assert(err, check.IsNil)
+
+       _, err = s.fs.OpenFile("/fg2/A Subproject", 0, 0)
+       c.Assert(err, check.IsNil)
+
+       _, err = s.fs.OpenFile("/fg2/A Project", 0, 0)
+       c.Assert(err, check.IsNil)
 }
 
 func (s *SiteFSSuite) TestCurrentUserHome(c *check.C) {
index 9245023babb532bffa891d579c00b3b6719d148f..02f21ded56c1e1e9edf13c01055e189e5e38b6f7 100644 (file)
@@ -19,6 +19,7 @@ const (
        fixtureActiveToken             = "3kg6k6lzmp9kj5cpkcoxie963cmvjahbt2fod9zru30k1jqdmi"
        fixtureAProjectUUID            = "zzzzz-j7d0g-v955i6s2oi1cbso"
        fixtureThisFilterGroupUUID     = "zzzzz-j7d0g-thisfiltergroup"
+       fixtureAFilterGroupTwoUUID     = "zzzzz-j7d0g-afiltergrouptwo"
        fixtureFooAndBarFilesInDirUUID = "zzzzz-4zz18-foonbarfilesdir"
        fixtureFooCollectionName       = "zzzzz-4zz18-fy296fx3hot09f7 added sometime"
        fixtureFooCollectionPDH        = "1f4b0bc7583c2a7f9102c395f4ffc5e3+45"
index 79d7b2fb546a7912b6a3f6caed4567f0feb57e7d..394b5603b7918e745140942af58ef3bfc393a8cd 100644 (file)
@@ -227,30 +227,12 @@ class Arvados::V1::GroupsController < ApplicationController
       end
     end
 
-    # filter groups need to be limited to those classes mentioned in the filters
-    # @object can also be a User object (virtual home project)
-    if @object and @object.is_a?(Group) and @object.group_class == "filter"
-      if request_filters.length() == 0
-        raise ArgumentError.new("Filter group needs to have filters defined")
-      end
-      request_filters.each do |col, op, val|
-        if col.index('.')
-          col = col.split('.')[0]
-          col = col.capitalize.sub(/s$/,'')
-          wanted_klasses << col
-        end
-      end
-    end
-
     filter_by_owner = {}
     if @object
-      # filter groups should not have an owner_uuid filter applied
-      if ! @object.is_a?(Group) or (@object.is_a?(Group) and @object.group_class != "filter")
-        if params['recursive']
-          filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
-        else
-          filter_by_owner[:owner_uuid] = @object.uuid
-        end
+      if params['recursive']
+        filter_by_owner[:owner_uuid] = [@object.uuid] + @object.descendant_project_uuids
+      else
+        filter_by_owner[:owner_uuid] = @object.uuid
       end
 
       if params['exclude_home_project']
index 5bb013c9add7a1f241d4779768cef462ac9956b2..79fea459018b604a8b20515591067320f1a540d2 100644 (file)
@@ -13,8 +13,8 @@ def fix_roles_projects
     # shouldn't be anything to do at all.
     act_as_system_user do
       ActiveRecord::Base.transaction do
-        Group.where("group_class != 'project' or group_class is null").each do |g|
-          # 1) any group not group_class != project becomes a 'role' (both empty and invalid groups)
+        Group.where("(group_class != 'project' and group_class != 'filter') or group_class is null").each do |g|
+          # 1) any group not group_class != project and != filter becomes a 'role' (both empty and invalid groups)
           old_owner = g.owner_uuid
           g.owner_uuid = system_user_uuid
           g.group_class = 'role'
index bf0641891e7987df392b42128db3d5ce998bd82c..da20f8be9e6218c0df6f9fda6399d6f1ccb404b4 100644 (file)
@@ -120,6 +120,19 @@ afiltergroup:
   properties:
     filters: [[ "collections.name", "like", "baz%" ], [ "groups.name", "=", "A Subproject" ]]
 
+afiltergroup2:
+  uuid: zzzzz-j7d0g-afiltergrouptwo
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-04-21 15:37:48 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  modified_at: 2014-04-21 15:37:48 -0400
+  updated_at: 2014-04-21 15:37:48 -0400
+  name: A filter group without filters
+  group_class: filter
+  properties:
+    filters: []
+
 future_project_viewing_group:
   uuid: zzzzz-j7d0g-futrprojviewgrp
   owner_uuid: zzzzz-tpzed-000000000000000