[ARVADOS] updated: 6a18fc0d6f3f9859e905d4762796d813a157605b
git at public.curoverse.com
git at public.curoverse.com
Sun Mar 23 16:39:01 EDT 2014
Summary of changes:
services/api/app/models/user.rb | 40 ++++++++++---------
.../functional/arvados/v1/users_controller_test.rb | 24 +++++++----
2 files changed, 36 insertions(+), 28 deletions(-)
via 6a18fc0d6f3f9859e905d4762796d813a157605b (commit)
from 35e245f09cfc5ace6259a671a1f12fd508750b13 (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 6a18fc0d6f3f9859e905d4762796d813a157605b
Author: radhika chippada <radhika at radhika.curoverse>
Date: Sun Mar 23 16:37:56 2014 -0400
Make sure oid_login_perm exists when setup is executed for an existing user
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 218f1da..672dd19 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -120,31 +120,33 @@ class User < ArvadosModel
raise "No email found in the input. Aborting user creation."
end
- if user.save
- oid_login_perm = Link.where(tail_uuid: user[:email],
- head_kind: 'arvados#user',
- link_class: 'permission',
- name: 'can_login')
-
- if !oid_login_perm.any?
- # create openid login permission
- oid_login_perm = Link.create(link_class: 'permission',
- name: 'can_login',
- tail_kind: 'email',
- tail_uuid: user[:email],
- head_kind: 'arvados#user',
- head_uuid: user[:uuid],
- properties: login_perm_props
- )
- logger.info { "openid login permission: " + oid_login_perm[:uuid] }
- end
- else
+ if !user.save
raise "Save failed"
end
else
user = found
end
+ # Check opd_login_perm
+ oid_login_perm = Link.where(tail_uuid: user[:email],
+ head_kind: 'arvados#user',
+ link_class: 'permission',
+ name: 'can_login')
+
+ if !oid_login_perm.any?
+ # create openid login permission
+ oid_login_perm = Link.create(link_class: 'permission',
+ name: 'can_login',
+ tail_kind: 'email',
+ tail_uuid: user[:email],
+ head_kind: 'arvados#user',
+ head_uuid: user[:uuid],
+ properties: login_perm_props
+ )
+ logger.info { "openid login permission: " + oid_login_perm[:uuid] }
+ end
+
+ # create repo, vm, and group links
response = {user: user, oid_login_perm: oid_login_perm}
user.setup_links(repo_name, vm_uuid, openid_prefix, response)
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index cd23989..ee158d1 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -114,7 +114,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert (response_errors.first.include? 'Path not found'), 'Expected 404'
end
- test "create user with existing uuid, vm and repo and verify links" do
+ test "invoke setup with existing uuid, vm and repo and verify links" do
authorize_with :inactive
get :current
assert_response :success
@@ -129,14 +129,21 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
}
assert_response :success
- response_object = JSON.parse(@response.body)['items']['user']
- assert_not_nil response_object['uuid'], 'expected uuid for the new user'
- assert_equal inactive_user['uuid'], response_object['uuid']
- assert_equal inactive_user['email'], response_object['email'],
+
+ response_items = JSON.parse(@response.body)['items']
+ resp_obj = response_items['user']
+
+ assert_not_nil resp_obj['uuid'], 'expected uuid for the new user'
+ assert_equal inactive_user['uuid'], resp_obj['uuid']
+ assert_equal inactive_user['email'], resp_obj['email'],
'expecting inactive user email'
- # since it is an existing user, expect only 2 new links: repo and vm
- verify_num_links @all_links_at_start, 2
+ # expect repo and vm links
+ verify_link response_items, 'repo_perm', true, 'permission', 'can_write',
+ 'test_repo', resp_obj['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'vm_login_perm', true, 'permission', 'can_login',
+ @vm_uuid, resp_obj['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
end
test "create user with valid email, vm and repo as input" do
@@ -264,7 +271,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
verify_link response_items, 'group_perm', true, 'permission', 'can_read',
'All users', created['uuid'], 'arvados#group', true, 'Group'
- verify_link response_items, 'vm_login_perm', false, 'permission', 'can_read',
+ verify_link response_items, 'vm_login_perm', false, 'permission', 'can_login',
nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
end
@@ -343,7 +350,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
def verify_link(response_items, link_object_name, expect_link, link_class,
link_name, head_uuid, tail_uuid, head_kind, fetch_object, class_name)
-
link = response_items[link_object_name]
if !expect_link
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list