[ARVADOS] updated: 031ad8460650129f8bed088e801fb0762d4d29b3

git at public.curoverse.com git at public.curoverse.com
Tue Mar 25 14:29:08 EDT 2014


Summary of changes:
 .../app/controllers/arvados/v1/users_controller.rb |   15 +++++++--
 services/api/app/models/user.rb                    |    4 +-
 .../functional/arvados/v1/users_controller_test.rb |   32 ++++++++++++++-----
 3 files changed, 37 insertions(+), 14 deletions(-)

       via  031ad8460650129f8bed088e801fb0762d4d29b3 (commit)
      from  ee21f45e958de5ef39970981ead6416e3790cd1a (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 031ad8460650129f8bed088e801fb0762d4d29b3
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Tue Mar 25 14:09:44 2014 -0400

    The controller invokes the create links method from the model when working on an existing user.

diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 8a42bfb..a10f680 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -91,17 +91,22 @@ class Arvados::V1::UsersController < ApplicationController
   # create user object and all the needed links
   def setup
     @object = nil
+    #object_found = false
     if params[:uuid]
       @object = User.find_by_uuid params[:uuid]
       if !@object
         return render_404_if_no_object
       end
+      object_found = true
     else
       if !params[:user]
         raise ArgumentError.new "Required uuid or user"
       else
         if params[:user]['uuid']
           @object = User.find_by_uuid params[:user]['uuid']
+          if @object
+            object_found = true
+          end
         end
 
         if !@object
@@ -118,9 +123,13 @@ class Arvados::V1::UsersController < ApplicationController
       end
     end
 
-    @response = User.setup @object, params[:openid_prefix],
-                params[:repo_name], params[:vm_uuid]
-   
+    if object_found
+      @response = @object.setup_repo_vm_links params[:repo_name], params[:vm_uuid]
+    else
+      @response = User.setup @object, params[:openid_prefix],
+                    params[:repo_name], params[:vm_uuid]
+    end
+
     render json: { kind: "arvados#HashList", items: @response }
   end
 
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 87f7e03..563bb07 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -133,7 +133,7 @@ class User < ArvadosModel
       oid_login_perm = oid_login_perms.first
     end
 
-    return [user, oid_login_perm] + user.setup_repo_vm_links(repo_name, vm_uuid)
+    return [oid_login_perm] + user.setup_repo_vm_links(repo_name, vm_uuid)
   end 
 
   # create links
@@ -142,7 +142,7 @@ class User < ArvadosModel
     vm_login_perm = create_vm_login_permission_link vm_uuid, repo_name
     group_perm = create_user_group_link
 
-    return [repo_perm, vm_login_perm, group_perm].compact
+    return [repo_perm, vm_login_perm, group_perm, self].compact
   end 
 
   protected
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 daf19a9..ce83201 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -74,6 +74,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     }
     assert_response :success
     response_items = JSON.parse(@response.body)['items']
+
     created = find_obj_in_resp response_items, 'User', nil
     assert_equal 'in_create_test_first_name', created['first_name']
     assert_not_nil created['uuid'], 'expected non-null uuid for the new user'
@@ -81,12 +82,28 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_not_nil created['email'], 'expected non-nil email'
     assert_nil created['identity_url'], 'expected no identity_url' 
 
+    # arvados#user, repo link and link add user to 'All users' group
+    verify_num_links @all_links_at_start, 3
+
+    verify_link response_items, 'arvados#user', true, 'permission', 'can_login',
+        created['uuid'], created['email'], 'arvados#user', false, 'User'
+
+    verify_link response_items, 'arvados#repository', true, 'permission', 'can_write',
+        repo_name, created['uuid'], 'arvados#repository', true, 'Repository'
+
+    verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+        'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+    verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login',
+        nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
     # invoke setup again with the same data
     post :setup, {
       repo_name: repo_name,
+      vm_uuid: @vm_uuid,
       openid_prefix: 'https://www.google.com/accounts/o8/id',
       user: {
-        uuid: "this_is_agreeable",        
+        uuid: "this_is_agreeable",
         first_name: "in_create_test_first_name",
         last_name: "test_last_name",
         email: "test at abc.com"
@@ -94,19 +111,16 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     }
 
     response_items = JSON.parse(@response.body)['items']
+
     created = find_obj_in_resp response_items, 'User', nil
     assert_equal 'in_create_test_first_name', created['first_name']
     assert_not_nil created['uuid'], 'expected non-null uuid for the new user'
     assert_equal 'this_is_agreeable', created['uuid']
     assert_not_nil created['email'], 'expected non-nil email'
-    assert_nil created['identity_url'], 'expected no identity_url' 
+    assert_nil created['identity_url'], 'expected no identity_url'
 
-    # since no such vm exists, expect only three new links: 
     # arvados#user, repo link and link add user to 'All users' group
-    verify_num_links @all_links_at_start, 3
-
-    verify_link response_items, 'arvados#user', true, 'permission', 'can_login',
-        created['uuid'], created['email'], 'arvados#user', false, 'User'
+    verify_num_links @all_links_at_start, 4
 
     verify_link response_items, 'arvados#repository', true, 'permission', 'can_write',
         repo_name, created['uuid'], 'arvados#repository', true, 'Repository'
@@ -114,8 +128,8 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
         'All users', created['uuid'], 'arvados#group', true, 'Group'
 
-    verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login',
-        nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+    verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login',
+        @vm_uuid, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
   end
 
   test "setup user with bogus uuid and expect error" do

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list