[ARVADOS] updated: 2.1.0-448-g7a3215a77

Git user git at public.arvados.org
Thu Mar 4 14:18:14 UTC 2021


Summary of changes:
 sdk/go/arvados/fs_project_test.go     |  9 +++++++++
 sdk/go/arvados/fs_site_test.go        |  1 +
 services/api/app/models/group.rb      | 35 +++++++++++++++++++++++++++++++++++
 services/api/test/fixtures/groups.yml | 13 +++++++++++++
 4 files changed, 58 insertions(+)

       via  7a3215a77922f308857881f108cfabc3b85d2378 (commit)
      from  35d5c737656b1ab7c2bdda27de3f67332be831c0 (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 7a3215a77922f308857881f108cfabc3b85d2378
Author: Ward Vandewege <ward at curii.com>
Date:   Wed Mar 3 16:04:54 2021 -0500

    17119: add filter validation for filter groups. Add a test for the
           'is_a' filter.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/sdk/go/arvados/fs_project_test.go b/sdk/go/arvados/fs_project_test.go
index 9d77c31d8..0564e2fae 100644
--- a/sdk/go/arvados/fs_project_test.go
+++ b/sdk/go/arvados/fs_project_test.go
@@ -64,6 +64,15 @@ func (s *SiteFSSuite) TestFilterGroup(c *check.C) {
 
 	_, err = s.fs.OpenFile("/fg2/A Project", 0, 0)
 	c.Assert(err, check.IsNil)
+
+	// An 'is_a' 'arvados#collection' filter means only collections should be returned.
+	s.fs.MountProject("fg3", fixtureAFilterGroupThreeUUID)
+
+	_, err = s.fs.OpenFile("/fg3/baz_file", 0, 0)
+	c.Assert(err, check.IsNil)
+
+	_, err = s.fs.OpenFile("/fg3/A Subproject", 0, 0)
+	c.Assert(err, check.Not(check.IsNil))
 }
 
 func (s *SiteFSSuite) TestCurrentUserHome(c *check.C) {
diff --git a/sdk/go/arvados/fs_site_test.go b/sdk/go/arvados/fs_site_test.go
index 02f21ded5..b1c627f89 100644
--- a/sdk/go/arvados/fs_site_test.go
+++ b/sdk/go/arvados/fs_site_test.go
@@ -20,6 +20,7 @@ const (
 	fixtureAProjectUUID            = "zzzzz-j7d0g-v955i6s2oi1cbso"
 	fixtureThisFilterGroupUUID     = "zzzzz-j7d0g-thisfiltergroup"
 	fixtureAFilterGroupTwoUUID     = "zzzzz-j7d0g-afiltergrouptwo"
+	fixtureAFilterGroupThreeUUID   = "zzzzz-j7d0g-filtergroupthre"
 	fixtureFooAndBarFilesInDirUUID = "zzzzz-4zz18-foonbarfilesdir"
 	fixtureFooCollectionName       = "zzzzz-4zz18-fy296fx3hot09f7 added sometime"
 	fixtureFooCollectionPDH        = "1f4b0bc7583c2a7f9102c395f4ffc5e3+45"
diff --git a/services/api/app/models/group.rb b/services/api/app/models/group.rb
index 870e0d0c4..afe288e9d 100644
--- a/services/api/app/models/group.rb
+++ b/services/api/app/models/group.rb
@@ -18,6 +18,7 @@ class Group < ArvadosModel
 
   validate :ensure_filesystem_compatible_name
   validate :check_group_class
+  validate :check_filter_group_filters
   before_create :assign_name
   after_create :after_ownership_change
   after_create :update_trash
@@ -56,6 +57,40 @@ class Group < ArvadosModel
     end
   end
 
+  def check_filter_group_filters
+    if group_class == 'filter'
+      if !self.properties.key?("filters")
+        return
+      end
+      if !self.properties["filters"].is_a?(Array)
+        errors.add :properties, "filters property must be an array of arrays, each with 3 elements"
+        return
+      end
+      self.properties["filters"].each do |filter|
+        if !filter.is_a?(Array)
+          errors.add :properties, "filters property must be an array of arrays, each with 3 elements"
+          return
+        end
+        if filter.length() != 3
+          errors.add :properties, "filters property must be an array of arrays, each with 3 elements"
+          return
+        end
+        if !filter[0].include?(".") and filter[0] != "uuid"
+          errors.add :properties, "filter attribute must be 'uuid' or contain a dot (e.g. groups.name)"
+          return
+        end
+        if (filter[0] == "uuid" and filter[1] != "is_a") or (filter[0] != "uuid" and filter[1] == "is_a")
+          errors.add :properties, "filter operator must be 'is_a' when attribute is 'uuid'"
+          return
+        end
+        if ! ["=","<","<=",">",">=","!=","like","ilike","is_a"].include?(filter[1])
+          errors.add :properties, "filter operator is not valid (must be =,<,<=,>,>=,!=,like,ilike,is_a)"
+          return
+        end
+      end
+    end
+  end
+
   def update_trash
     if saved_change_to_trash_at? or saved_change_to_owner_uuid?
       # The group was added or removed from the trash.
diff --git a/services/api/test/fixtures/groups.yml b/services/api/test/fixtures/groups.yml
index da20f8be9..48925a270 100644
--- a/services/api/test/fixtures/groups.yml
+++ b/services/api/test/fixtures/groups.yml
@@ -133,6 +133,19 @@ afiltergroup2:
   properties:
     filters: []
 
+afiltergroup3:
+  uuid: zzzzz-j7d0g-filtergroupthre
+  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 with an is_a collection filter
+  group_class: filter
+  properties:
+    filters: [["uuid", "is_a", "arvados#collection"]]
+
 future_project_viewing_group:
   uuid: zzzzz-j7d0g-futrprojviewgrp
   owner_uuid: zzzzz-tpzed-000000000000000

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list