[ARVADOS] updated: dc51a3a6a2915d66f1b8f82580637b5733bb49f5
git at public.curoverse.com
git at public.curoverse.com
Wed Apr 16 09:49:00 EDT 2014
Summary of changes:
.../app/controllers/arvados/v1/links_controller.rb | 16 ++++++----
.../functional/arvados/v1/links_controller_test.rb | 30 ++++++++++++++++++++
2 files changed, 40 insertions(+), 6 deletions(-)
via dc51a3a6a2915d66f1b8f82580637b5733bb49f5 (commit)
from ea7c6effed14cd80a444c6e4d5b89c8b99c17d59 (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 dc51a3a6a2915d66f1b8f82580637b5733bb49f5
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Apr 16 09:48:57 2014 -0400
Fixed error reporting when head/tail_uuid don't match head/tail_kind for links.
Added a couple more tests.
diff --git a/services/api/app/controllers/arvados/v1/links_controller.rb b/services/api/app/controllers/arvados/v1/links_controller.rb
index 563804e..188ecfc 100644
--- a/services/api/app/controllers/arvados/v1/links_controller.rb
+++ b/services/api/app/controllers/arvados/v1/links_controller.rb
@@ -1,13 +1,17 @@
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}'")
+ def check_uuid_kind uuid, kind
+ if kind and ArvadosModel::resource_class_for_uuid(uuid).andand.kind != kind
+ render :json => { errors: ["'#{kind}' does not match uuid '#{uuid}', expected '#{ArvadosModel::resource_class_for_uuid(uuid).andand.kind}'"] }.to_json, status: 422
+ nil
+ else
+ true
end
+ 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
+ def create
+ return if ! check_uuid_kind resource_attrs[:head_uuid], resource_attrs[:head_kind]
+ return if ! check_uuid_kind resource_attrs[:tail_uuid], resource_attrs[:tail_kind]
resource_attrs.delete :head_kind
resource_attrs.delete :tail_kind
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 f4d65c1..3372590 100644
--- a/services/api/test/functional/arvados/v1/links_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/links_controller_test.rb
@@ -203,4 +203,34 @@ class Arvados::V1::LinksControllerTest < ActionController::TestCase
assert_response 422
end
+ test "test with virtual_machine" do
+ link = {
+ tail_kind: "arvados#user",
+ tail_uuid: users(:active).uuid,
+ head_kind: "arvados#virtual_machine",
+ head_uuid: virtual_machines(:testvm).uuid,
+ link_class: "permission",
+ name: "can_login",
+ properties: {username: "repo_and_user_name"}
+ }
+ authorize_with :admin
+ post :create, link: link
+ assert_response 422
+ end
+
+ test "test with virtualMachine" do
+ link = {
+ tail_kind: "arvados#user",
+ tail_uuid: users(:active).uuid,
+ head_kind: "arvados#virtualMachine",
+ head_uuid: virtual_machines(:testvm).uuid,
+ link_class: "permission",
+ name: "can_login",
+ properties: {username: "repo_and_user_name"}
+ }
+ authorize_with :admin
+ post :create, link: link
+ assert_response :success
+ end
+
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list