[ARVADOS] updated: 065620721d198894d80f5d3ed409a1d158f0f41b
git at public.curoverse.com
git at public.curoverse.com
Mon Apr 14 11:22:46 EDT 2014
Summary of changes:
.../app/controllers/arvados/v1/links_controller.rb | 8 ++++++
.../functional/arvados/v1/links_controller_test.rb | 27 ++++++++++++++++++++
2 files changed, 35 insertions(+), 0 deletions(-)
via 065620721d198894d80f5d3ed409a1d158f0f41b (commit)
from 6a210c4771acb18751e48f7e7c0841eb68469d90 (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 065620721d198894d80f5d3ed409a1d158f0f41b
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Apr 14 11:22:41 2014 -0400
Links controller checks that head/tail_kind matches head/tail_uuid.
Added test.
diff --git a/services/api/app/controllers/arvados/v1/links_controller.rb b/services/api/app/controllers/arvados/v1/links_controller.rb
index 1b5bf78..563804e 100644
--- a/services/api/app/controllers/arvados/v1/links_controller.rb
+++ b/services/api/app/controllers/arvados/v1/links_controller.rb
@@ -1,6 +1,14 @@
class Arvados::V1::LinksController < ApplicationController
def create
+ if resource_attrs[:head_kind] and ArvadosModel::resource_class_for_uuid(resource_attrs[:head_uuid]).kind != resource_attrs[:head_kind]
+ errors.add(attr, "'#{resource_attrs[:head_kind]}' does not match '#{head_uuid}'")
+ end
+
+ if resource_attrs[:tail_kind] and ArvadosModel::resource_class_for_uuid(resource_attrs[:tail_uuid]).kind != resource_attrs[:tail_kind]
+ errors.add(attr, "'#{resource_attrs[:tail_kind]}' does not match '#{tail_uuid}'")
+ end
+
resource_attrs.delete :head_kind
resource_attrs.delete :tail_kind
super
diff --git a/services/api/test/functional/arvados/v1/links_controller_test.rb b/services/api/test/functional/arvados/v1/links_controller_test.rb
index 09dd162..f4d65c1 100644
--- a/services/api/test/functional/arvados/v1/links_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/links_controller_test.rb
@@ -175,5 +175,32 @@ class Arvados::V1::LinksControllerTest < ActionController::TestCase
assert_equal found.count, (found.select { |f| f.head_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count
end
+ test "head_kind matches head_uuid" do
+ link = {
+ link_class: 'test',
+ name: 'stuff',
+ head_uuid: groups(:public).uuid,
+ head_kind: "arvados#user",
+ tail_uuid: users(:spectator).uuid,
+ tail_kind: "arvados#user",
+ }
+ authorize_with :admin
+ post :create, link: link
+ assert_response 422
+ end
+
+ test "tail_kind matches tail_uuid" do
+ link = {
+ link_class: 'test',
+ name: 'stuff',
+ head_uuid: users(:active).uuid,
+ head_kind: "arvados#user",
+ tail_uuid: groups(:public).uuid,
+ tail_kind: "arvados#user",
+ }
+ authorize_with :admin
+ post :create, link: link
+ assert_response 422
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list