[ARVADOS] updated: 4b57d5f64a980777888fa49657d6fe0617514218

git at public.curoverse.com git at public.curoverse.com
Mon Mar 17 17:22:05 EDT 2014


Summary of changes:
 .../app/controllers/arvados/v1/users_controller.rb |    6 +-
 .../functional/arvados/v1/users_controller_test.rb |  146 +++++++++++++++++++-
 2 files changed, 147 insertions(+), 5 deletions(-)

       via  4b57d5f64a980777888fa49657d6fe0617514218 (commit)
      from  851f7d9cc9d3f6e4843a8fbd507338b1cc0e9f2c (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 4b57d5f64a980777888fa49657d6fe0617514218
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Mon Mar 17 17:21:36 2014 -0400

    Added functional tests for controller updates

diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 0d22b86..5b89918 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -119,8 +119,10 @@ class Arvados::V1::UsersController < ApplicationController
 		end
 
 		# if just probing, return any object found	
-		if just_probe 	
-			show; return
+		if just_probe 
+			@object[:email] = nil	
+			show
+		  return
 		end
 
 		# create if need be, and then create or update the links as needed 
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 4e04363..5e22a99 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -38,7 +38,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_equal true, me['is_active']
   end
 
-  test "create new user" do
+  test "create new user with user as input" do
     authorize_with :admin
     post :create, user: {
       first_name: "test_first_name",
@@ -53,14 +53,154 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
     assert_nil created['identity_url'], 'even though email is provided, expected no identity_url since users_controller only creates user at this time'
   end
 
-	test "create user with vm and repo" do
+	test "create user with user, vm and repo as input" do
+    authorize_with :admin
+
+    post :create, {
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {
+		    uuid: "is_this_correct",		    
+				first_name: "in_create_test_first_name",
+		    last_name: "test_last_name",
+				email: "test at abc.com"
+      }
+    }
+    assert_response :success
+    created = JSON.parse(@response.body)
+    assert_equal 'in_create_test_first_name', created['first_name']
+    assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
+		assert_equal 'is_this_correct', created['uuid']
+    assert_not_nil created['email'], 'since email was given, expected non-nil email'
+    assert_nil created['identity_url'], 'even though email is provided, expected no identity_url since users_controller only creates user' 
+	end
+
+	test "create user with user_param, vm and repo as input" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'not_an_existing_uuid_and_not_email_format',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {}
+    }
+
+    response_body = JSON.parse(@response.body)
+    response_errors = response_body['errors']
+		assert_not_nil response_errors, 'Expected error in response'
+		incorrectly_formatted = response_errors.first.include?('ArgumentError: User param is not of valid email format')
+		assert incorrectly_formatted, 'Expected not valid email format error'
+	end
+
+	test "create user with existing uuid user_param, vm and repo as input" do
+		authorize_with :inactive
+    get :current
+    assert_response :success
+    inactive_user = JSON.parse(@response.body)
+		
+    authorize_with :admin
+
+		# it would be desirable to use inactive_user['uuid'] instead of hard coding user_param
+    post :create, {
+      user_param: 'zzzzz-tpzed-x9kqpd79egh49c7',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {}
+    }
+
+    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 inactive_user['uuid'], response_object['uuid']
+    assert_equal inactive_user['email'], response_object['email'], 'expecting inactive user email'
+	end
+
+	test "create user with valid email user_param, vm and repo as input" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'abc at xyz.com',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {}
+    }
+
+    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'
+	end
+
+	test "create user with valid email user_param, no vm and repo as input" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'abc at xyz.com',
+      user: {}
+    }
+
+    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'
+	end
+
+	test "create user with valid email user_param, vm and repo as input with opt.n" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'abc at xyz.com',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+			just_probe: 'true',
+      user: {}
+    }
+
+    assert_response :success
+    response_object = JSON.parse(@response.body)
+    assert_nil response_object['uuid'], 'expected null uuid since no object created due to just probe'
+    assert_nil response_object['email'], 'expecting null email'
+	end
+
+	# in progress
+	test "create user twice and check links are not recreated" do
+    authorize_with :admin
+
+    post :create, {
+      user_param: 'abc at xyz.com',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {}
+    }
+
+    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'
+
+		# create again
+    post :create, {
+      user_param: 'abc at xyz.com',
+      repo_name: 'test_repo',
+			vm_uuid: 'abcdefg',
+      user: {}
+    }
+
+    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'
+
+		# check links are not recreated
+	end
+
+	test "create user with openid_prefix" do
     authorize_with :admin
 
     post :create, {
       repo_name: 'test_repo',
 			vm_uuid: 'abcdefg',
       user: {
-		    uuid: "shouldnotbeused",		    
 				first_name: "in_create_test_first_name",
 		    last_name: "test_last_name",
 				email: "test at abc.com"

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list