[ARVADOS] updated: 994fa8b63a19f2253b6027d64f7ea72c43ea1192

git at public.curoverse.com git at public.curoverse.com
Fri Mar 21 09:43:41 EDT 2014


Summary of changes:
 sdk/cli/bin/arv-run-pipeline-instance              |    4 +-
 .../app/controllers/arvados/v1/jobs_controller.rb  |    3 +-
 .../app/controllers/arvados/v1/users_controller.rb |   30 +--
 services/api/app/models/job.rb                     |    7 +-
 services/api/script/crunch-dispatch.rb             |   12 +-
 services/api/script/setup-new-user.rb              |    8 +-
 .../functional/arvados/v1/users_controller_test.rb |   55 ++---
 services/api/test/integration/permissions_test.rb  |  244 ++++++++++++++++++++
 8 files changed, 291 insertions(+), 72 deletions(-)
 create mode 100644 services/api/test/integration/permissions_test.rb

       via  994fa8b63a19f2253b6027d64f7ea72c43ea1192 (commit)
       via  3e130a782321de2a0343fcec8a3365442ecde431 (commit)
       via  d65964ad6063b6cd5420004a5cbdc58fe2d0b194 (commit)
       via  061dc0bcb7ced7ad196c6cc71dd25aab59948e46 (commit)
       via  8e603cbbfd5541cecf78967dc809c1676a607a09 (commit)
       via  aa19561b8139abbd27cea7bb88ec600b3df16de1 (commit)
       via  bdb71f7762196e179e495bda28f4375e5c69af31 (commit)
       via  ed8493bae19f584ef04952a81db195b57320189f (commit)
       via  29ad4d318197a0e58ba0aa070723f19ee219364d (commit)
      from  c09ec8260b02c4767c82bcb5b346899193329828 (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 994fa8b63a19f2253b6027d64f7ea72c43ea1192
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Fri Mar 21 09:15:01 2014 -0400

    All tests passing

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 48c8c98..048cb43 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -112,7 +112,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert incorrectly_formatted, 'Expected not valid email format error'
   end
 
-  test "create user with existing uuid, vm and repo as input" do
+  test "create user with existing uuid, vm and repo as input and verify links" do
     authorize_with :inactive
     get :current
     assert_response :success
@@ -131,6 +131,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
     assert_equal inactive_user['uuid'], response_object['uuid']
     assert_equal inactive_user['email'], response_object['email'], 'expecting inactive user email'
+
+    # one extra link for repo
+    verify_num_links @all_links_at_start, 1
   end
 
   test "create user with valid email, vm and repo as input" do
@@ -146,6 +149,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     response_object = JSON.parse(@response.body)
     assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
     assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
+
+    # three extra links; login link, group link and repo link
+    verify_num_links @all_links_at_start, 3
   end
 
   test "create user with valid email, no vm and repo as input" do
@@ -159,6 +165,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     response_object = JSON.parse(@response.body)
     assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
     assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
+
+    # two extra links; login link and group link
+    verify_num_links @all_links_at_start, 2
   end
 
   test "create user with email, first name, repo name and vm uuid" do
@@ -166,7 +175,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
 
     post :setup, {
       repo_name: 'test_repo',
-      vm_uuid: 'no_such_vm',
+      vm_uuid: @vm_uuid,
       user: {
         first_name: 'test_first_name',
         email: 'abc at xyz.com'
@@ -178,36 +187,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
     assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
     assert_equal 'test_first_name', response_object['first_name'], 'expecting first name'
-  end
-
-  test "create user twice and check links are not recreated" do
-    authorize_with :admin
-
-    post :setup, {
-      user: {email: 'abc at xyz.com'},
-      vm_uuid: 'no_such_vm',
-      repo_name: 'test_repo'
-    }
-
-    assert_response :success
-    response_object = JSON.parse(@response.body)
-    assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
-    assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
-    verify_num_links @all_links_at_start, 3   # openid, group, and repo links. no vm link
-
-    # create again
-    post :setup, {
-      repo_name: 'test_repo',
-      vm_uuid: 'no_such_vm',
-      user: {uuid: response_object['uuid']}
-    }
 
-    assert_response :success
-    response_object2 = JSON.parse(@response.body)
-    assert_equal response_object['uuid'], response_object2['uuid'], 
-        'expected same uuid as first create operation'
-    assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
-    verify_num_links @all_links_at_start, 3   # openid, group, and repo links. no vm link
+    # four extra links; login link, group link, repo link and vm link
+    verify_num_links @all_links_at_start, 4
   end
 
   test "create user twice with user email as input and check two different objects created" do
@@ -236,7 +218,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_not_equal response_object['uuid'], response_object2['uuid'], 
         'expected same uuid as first create operation'
     assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
-#    verify_num_links @all_links_at_start, 6   # openid, group, and repo links. no vm link
+
+    # extra login link only
+    verify_num_links @all_links_at_start, 4
   end
 
   test "create user with openid prefix" do
@@ -260,8 +244,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_nil created['identity_url'], 'expected no identity_url' 
 
     # verify links
-    # expect 3 new links: oid_login_perm, repo link, and link add user to 'All users' group. 
-    # No vm link since the vm_uuid passed in is not in system
+    # 3 new links: oid_login_perm, repo link, and link add user to 'All users' group. 
     verify_num_links @all_links_at_start, 3
 
     verify_link_exists_for_type 'User', 'permission', 'can_login', created['uuid'], 

commit 3e130a782321de2a0343fcec8a3365442ecde431
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Thu Mar 20 23:32:22 2014 -0400

    testing setup method implementation

diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index adad309..88c8538 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -99,15 +99,15 @@ class Arvados::V1::UsersController < ApplicationController
     login_perm_props = {identity_url_prefix: openid_prefix}
 
     @object = model_class.new resource_attrs
-
     # Lookup for user. If exists, only create any missing links
-    @object_found = find_user_from_input 
+    if @object[:uuid]
+      @object_found = User.find_by_uuid @object[:uuid]
+    end
 
     if !@object_found
-      if !@object[:email]
+      if !@object['email']
         raise "No email found in the input. Aborting user creation."
       end
-
       if @object.save
         oid_login_perm = Link.where(tail_uuid: @object[:email],
                                     head_kind: 'arvados#user',
@@ -134,8 +134,8 @@ class Arvados::V1::UsersController < ApplicationController
     end
     
     # create links
-    create_user_repo_link params[:repo_name]
-    create_vm_login_permission_link params[:vm_uuid], params[:repo_name]
+    create_user_repo_link params['repo_name']
+    create_vm_login_permission_link params['vm_uuid'], params['repo_name']
     create_user_group_link 
 
     show  
@@ -143,24 +143,6 @@ class Arvados::V1::UsersController < ApplicationController
 
   protected 
 
-  # find the user from the given user parameters
-  def find_user_from_input
-    if @object[:uuid]
-      found_object = User.find_by_uuid @object[:uuid]
-    end
-
-    if !found_object
-      if !@object[:email]
-        return
-      end
-
-      found_objects = User.where('email=?', @object[:email])  
-      found_object = found_objects.first
-    end
-
-    return found_object
-  end
-  
   # link the repo_name passed
   def create_user_repo_link(repo_name)
     if not repo_name
diff --git a/services/api/script/setup-new-user.rb b/services/api/script/setup-new-user.rb
index bc0fd4b..b1367f3 100755
--- a/services/api/script/setup-new-user.rb
+++ b/services/api/script/setup-new-user.rb
@@ -39,7 +39,7 @@ begin
   user = arv.user.get(uuid: user_arg)
 rescue Arvados::TransactionFailedError
   found = arv.user.list(where: {email: ARGV[0]})[:items]
-         
+    
   if found.count == 0 
     if !user_arg.match(/\w\@\w+\.\w+/)
       abort "About to create new user, but #{user_arg.inspect} " +
@@ -47,7 +47,7 @@ rescue Arvados::TransactionFailedError
     end
            
     user = arv.user.setup(repo_name: user_repo_name, vm_uuid: vm_uuid, 
-        user: {email: user_arg})
+        openid_prefix: opts.openid_prefix, user: {email: user_arg})
     log.info { "created user: " + user[:uuid] }
   elsif found.count != 1
     abort "Found #{found.count} users " +
@@ -55,8 +55,8 @@ rescue Arvados::TransactionFailedError
   else
     user = found.first
     # Found user. Update the user links
-    user = arv.user.setup(user: {email: user[:uuid]}, repo_name: user_repo_name,
-        vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix)
+    user = arv.user.setup(repo_name: user_repo_name, vm_uuid: vm_uuid, 
+        openid_prefix: opts.openid_prefix, user: {uuid: user[:uuid]})
   end
 
   puts "USER = #{user.inspect}"
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 319f515..48c8c98 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -180,7 +180,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_equal 'test_first_name', response_object['first_name'], 'expecting first name'
   end
 
-  test "create user twice with user param and check links are not recreated" do
+  test "create user twice and check links are not recreated" do
     authorize_with :admin
 
     post :setup, {
@@ -199,7 +199,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     post :setup, {
       repo_name: 'test_repo',
       vm_uuid: 'no_such_vm',
-      user: {email: 'abc at xyz.com'}
+      user: {uuid: response_object['uuid']}
     }
 
     assert_response :success
@@ -210,7 +210,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     verify_num_links @all_links_at_start, 3   # openid, group, and repo links. no vm link
   end
 
-  test "create user twice with user object as input and check links are not recreated" do
+  test "create user twice with user email as input and check two different objects created" do
     authorize_with :admin
 
     post :setup, {
@@ -233,10 +233,10 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
 
     assert_response :success
     response_object2 = JSON.parse(@response.body)
-    assert_equal response_object['uuid'], response_object2['uuid'], 
+    assert_not_equal response_object['uuid'], response_object2['uuid'], 
         'expected same uuid as first create operation'
     assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
-    verify_num_links @all_links_at_start, 3   # openid, group, and repo links. no vm link
+#    verify_num_links @all_links_at_start, 6   # openid, group, and repo links. no vm link
   end
 
   test "create user with openid prefix" do

commit d65964ad6063b6cd5420004a5cbdc58fe2d0b194
Merge: c09ec82 061dc0b
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Thu Mar 20 20:51:07 2014 -0400

    Merge branch 'master' into 2187-enhance-user-setup


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


hooks/post-receive
-- 




More information about the arvados-commits mailing list