[ARVADOS] updated: 5991a5bb4a4ccf74b763570941458dfee640f6d1
git at public.curoverse.com
git at public.curoverse.com
Mon Mar 24 23:20:44 EDT 2014
Summary of changes:
.../app/controllers/arvados/v1/users_controller.rb | 2 +-
services/api/app/models/user.rb | 22 +-----
services/api/test/unit/user_test.rb | 73 ++++++++++++--------
3 files changed, 50 insertions(+), 47 deletions(-)
via 5991a5bb4a4ccf74b763570941458dfee640f6d1 (commit)
from 31bb970d362490abc5238e895e04ab41d828e64c (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 5991a5bb4a4ccf74b763570941458dfee640f6d1
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 24 23:20:05 2014 -0400
Update user model to return a List instead of HashList
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 3d6e61c..65b7ddc 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -107,7 +107,7 @@ class Arvados::V1::UsersController < ApplicationController
@response = User.setup @object, params[:openid_prefix],
params[:repo_name], params[:vm_uuid]
- render json: { kind: "arvados#HashList", items: @response }
+ render json: { kind: "List", items: @response }
end
end
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index ae3f31a..fc7bc4f 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -148,30 +148,16 @@ class User < ArvadosModel
end
end
- # create repo, vm, and group links
- response = {user: user, oid_login_perm: oid_login_perm}
-
- user.setup_repo_vm_links(repo_name, vm_uuid, response)
-
- return response
+ return [user, oid_login_perm] + user.setup_repo_vm_links(repo_name, vm_uuid)
end
# create links
- def setup_repo_vm_links(repo_name, vm_uuid, response)
+ def setup_repo_vm_links(repo_name, vm_uuid)
repo_perm = create_user_repo_link repo_name
- if repo_perm
- response[:repo_perm] = repo_perm
- end
-
vm_login_perm = create_vm_login_permission_link vm_uuid, repo_name
- if vm_login_perm
- response[:vm_login_perm] = vm_login_perm
- end
-
group_perm = create_user_group_link
- if group_perm
- response[:group_perm] = group_perm
- end
+
+ return [repo_perm, vm_login_perm, group_perm].compact
end
protected
diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index 2b67864..0fbf981 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -206,23 +206,23 @@ class UserTest < ActiveSupport::TestCase
response = User.setup user, openid_prefix, 'test_repo', vm.uuid
- resp_user = response[:user]
+ resp_user = find_obj_in_resp response, 'User'
verify_user resp_user, email
- oid_login_perm = response[:oid_login_perm]
+ oid_login_perm = find_obj_in_resp response, 'Link', 'arvados#user'
verify_link oid_login_perm, 'permission', 'can_login', resp_user[:email],
resp_user[:uuid]
assert_equal openid_prefix, oid_login_perm[:properties][:identity_url_prefix],
'expected identity_url_prefix not found for oid_login_perm'
- verify_link response[:group_perm], 'permission', 'can_read',
- resp_user[:uuid], nil
+ group_perm = find_obj_in_resp response, 'Link', 'arvados#group'
+ verify_link group_perm, 'permission', 'can_read', resp_user[:uuid], nil
- verify_link response[:repo_perm], 'permission', 'can_write',
- resp_user[:uuid], nil
+ repo_perm = find_obj_in_resp response, 'Link', 'arvados#repository'
+ verify_link repo_perm, 'permission', 'can_write', resp_user[:uuid], nil
- verify_link response[:vm_login_perm], 'permission', 'can_login',
- resp_user[:uuid], vm.uuid
+ vm_perm = find_obj_in_resp response, 'Link', 'arvados#virtualMachine'
+ verify_link vm_perm, 'permission', 'can_login', resp_user[:uuid], vm.uuid
end
test "setup new user in multiple steps" do
@@ -236,57 +236,74 @@ class UserTest < ActiveSupport::TestCase
response = User.setup user, openid_prefix
- resp_user = response[:user]
+ resp_user = find_obj_in_resp response, 'User'
verify_user resp_user, email
- oid_login_perm = response[:oid_login_perm]
+ oid_login_perm = find_obj_in_resp response, 'Link', 'arvados#user'
verify_link oid_login_perm, 'permission', 'can_login', resp_user[:email],
resp_user[:uuid]
assert_equal openid_prefix, oid_login_perm[:properties][:identity_url_prefix],
'expected identity_url_prefix not found for oid_login_perm'
- verify_link response[:group_perm], 'permission', 'can_read',
- resp_user[:uuid], nil
+ group_perm = find_obj_in_resp response, 'Link', 'arvados#group'
+ verify_link group_perm, 'permission', 'can_read', resp_user[:uuid], nil
# invoke setup again with repo_name
user = User.new
user.uuid = resp_user[:uuid]
response = User.setup user, openid_prefix, 'test_repo'
-
- resp_user = response[:user]
+ resp_user = find_obj_in_resp response, 'User', nil
verify_user resp_user, email
assert_equal user.uuid, resp_user[:uuid], 'expected uuid not found'
- verify_link response[:group_perm], 'permission', 'can_read',
- resp_user[:uuid], nil
+ group_perm = find_obj_in_resp response, 'Link', 'arvados#group'
+ verify_link group_perm, 'permission', 'can_read', resp_user[:uuid], nil
- verify_link response[:repo_perm], 'permission', 'can_write',
- resp_user[:uuid], nil
+ repo_perm = find_obj_in_resp response, 'Link', 'arvados#repository'
+ verify_link repo_perm, 'permission', 'can_write', resp_user[:uuid], nil
# invoke setup again with a vm_uuid
vm = VirtualMachine.create
response = User.setup user, openid_prefix, 'test_repo', vm.uuid
- resp_user = response[:user]
+ resp_user = find_obj_in_resp response, 'User', nil
verify_user resp_user, email
assert_equal user.uuid, resp_user[:uuid], 'expected uuid not found'
- verify_link response[:group_perm], 'permission', 'can_read',
- resp_user[:uuid], nil
+ group_perm = find_obj_in_resp response, 'Link', 'arvados#group'
+ verify_link group_perm, 'permission', 'can_read', resp_user[:uuid], nil
+
+ repo_perm = find_obj_in_resp response, 'Link', 'arvados#repository'
+ verify_link repo_perm, 'permission', 'can_write', resp_user[:uuid], nil
- verify_link response[:repo_perm], 'permission', 'can_write',
- resp_user[:uuid], nil
+ vm_perm = find_obj_in_resp response, 'Link', 'arvados#virtualMachine'
+ verify_link vm_perm, 'permission', 'can_login', resp_user[:uuid], vm.uuid
+ end
- verify_link response[:vm_login_perm], 'permission', 'can_login',
- resp_user[:uuid], vm.uuid
+ def find_obj_in_resp (response, object_type, head_kind=nil)
+ return_obj = nil
+ response.each { |x|
+ if x.class.name == object_type
+ if head_kind
+ if x.head_kind == head_kind
+ return_obj = x
+ break
+ end
+ else
+ return_obj = x
+ break
+ end
+ end
+ }
+ return return_obj
end
- def verify_user resp_user, email
+ def verify_user (resp_user, email)
assert_not_nil resp_user, 'expected user object'
- assert_not_nil resp_user[:uuid], 'expected user object'
- assert_equal email, resp_user[:email], 'expected email not found'
+ assert_not_nil resp_user['uuid'], 'expected user object'
+ assert_equal email, resp_user['email'], 'expected email not found'
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list