setup-new-user script using the setup method.
authorradhika chippada <radhika@radhika.curoverse>
Fri, 21 Mar 2014 00:49:14 +0000 (20:49 -0400)
committerradhika chippada <radhika@radhika.curoverse>
Fri, 21 Mar 2014 00:49:14 +0000 (20:49 -0400)
services/api/app/controllers/arvados/v1/users_controller.rb
services/api/script/setup-new-user.rb
services/api/test/functional/arvados/v1/users_controller_test.rb

index 92b84f46acd46541711f04fb30ac2f479794f0dd..adad309fda9e0ca27b6edff3aa59b567ecbfce47 100644 (file)
@@ -153,14 +153,6 @@ class Arvados::V1::UsersController < ApplicationController
       if !@object[:email]
         return
       end
-=begin  
-        if found_objects.size > 1
-          logger.warn ("Found #{found_objects.size} users with email #{user_email}. Stop.")
-          raise ArgumentError.new "Found #{found_objects.size} users with email #{user_email}. Stop."
-        elsif found_objects.size == 1
-          found_object = found_objects.first
-        end
-=end
 
       found_objects = User.where('email=?', @object[:email])  
       found_object = found_objects.first
index fbdb0b0547c49f428b057e9a0395c2586be5135b..bc0fd4b8aa757599c0504a94229f3f3ae21bde1f 100755 (executable)
@@ -15,10 +15,6 @@ opts = Trollop::options do
   banner ''
   opt :debug, <<-eos
 Show debug messages.
-  eos
-  opt :create, <<-eos
-Create a new user with the given email address if an existing user \
-is not found.
   eos
   opt :openid_prefix, <<-eos, default: 'https://www.google.com/accounts/o8/id'
 If creating a new user record, require authentication from an OpenID \
@@ -58,9 +54,9 @@ rescue Arvados::TransactionFailedError
              "with uuid or email #{user_arg.inspect}. Stop."
   else
     user = found.first
-    # Found user. Update ther user links
-    user = arv.user.setup(repo_name: user_repo_name, vm_uuid: vm_uuid, 
-        user: {email: user[:uuid]})
+    # 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)
   end
 
   puts "USER = #{user.inspect}"
index d4e25ddbdbf841a58128f5a7e42a39181b95bdd9..319f515721e1ba7cb45fbb8ba85980a4169c6b2a 100644 (file)
@@ -101,9 +101,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     authorize_with :admin
 
     post :setup, {
+      user: {uuid: 'not_an_existing_uuid_and_not_email_format'},
       repo_name: 'test_repo',
-      vm_uuid: 'no_such_vm',
-      user: {uuid: 'not_an_existing_uuid_and_not_email_format'}
+      vm_uuid: 'no_such_vm'
     }
     response_body = JSON.parse(@response.body)
     response_errors = response_body['errors']
@@ -121,9 +121,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     authorize_with :admin
 
     post :setup, {
+      user: {uuid: inactive_user['uuid']},
       repo_name: 'test_repo',
-      vm_uuid: 'no_such_vm',
-      user: {uuid: inactive_user['uuid']}
+      vm_uuid: 'no_such_vm'
     }
 
     assert_response :success
@@ -184,9 +184,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     authorize_with :admin
 
     post :setup, {
-      repo_name: 'test_repo',
+      user: {email: 'abc@xyz.com'},
       vm_uuid: 'no_such_vm',
-      user: {email: 'abc@xyz.com'}
+      repo_name: 'test_repo'
     }
 
     assert_response :success
@@ -197,10 +197,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
 
     # create again
     post :setup, {
-      user_param: 'abc@xyz.com',
       repo_name: 'test_repo',
       vm_uuid: 'no_such_vm',
-      user: {}
+      user: {email: 'abc@xyz.com'}
     }
 
     assert_response :success
@@ -279,13 +278,13 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     authorize_with :admin
 
     post :setup, {
-      repo_name: 'test_repo',
-      vm_uuid: @vm_uuid,
       user: {
         first_name: "in_create_test_first_name",
         last_name: "test_last_name",
         email: "test@abc.com"
-      }
+      },
+      repo_name: 'test_repo',
+      vm_uuid: @vm_uuid
     }
     assert_response :success
     created = JSON.parse(@response.body)