X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5338c3fe0abbc6599aa290085be13eecfb0044e9..1f82ade9be8494e114156210d600a9624262ddba:/services/api/test/functional/arvados/v1/users_controller_test.rb 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 e3763c389e..817a1c9ef9 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -88,13 +88,44 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert_nil created['identity_url'], 'expected no identity_url' end + test "create new user with empty username" do + authorize_with :admin + post :create, params: { + user: { + first_name: "test_first_name", + last_name: "test_last_name", + username: "" + } + } + assert_response :success + created = JSON.parse(@response.body) + assert_equal 'test_first_name', created['first_name'] + assert_not_nil created['uuid'], 'expected uuid for the newly created user' + assert_nil created['email'], 'expected no email' + assert_nil created['username'], 'expected no username' + end + + test "update user with empty username" do + authorize_with :admin + user = users('spectator') + assert_not_nil user['username'] + put :update, params: { + id: users('spectator')['uuid'], + user: { + username: "" + } + } + assert_response :success + updated = JSON.parse(@response.body) + assert_nil updated['username'], 'expected no username' + end + test "create user with user, vm and repo as input" do authorize_with :admin repo_name = 'usertestrepo' post :setup, params: { repo_name: repo_name, - openid_prefix: 'https://www.google.com/accounts/o8/id', user: { uuid: 'zzzzz-tpzed-abcdefghijklmno', first_name: "in_create_test_first_name", @@ -149,7 +180,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase user: {uuid: 'bogus_uuid'}, repo_name: 'usertestrepo', vm_uuid: @vm_uuid, - openid_prefix: 'https://www.google.com/accounts/o8/id' } response_body = JSON.parse(@response.body) response_errors = response_body['errors'] @@ -164,7 +194,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, params: { repo_name: 'usertestrepo', vm_uuid: @vm_uuid, - openid_prefix: 'https://www.google.com/accounts/o8/id' } response_body = JSON.parse(@response.body) response_errors = response_body['errors'] @@ -180,7 +209,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase user: {}, repo_name: 'usertestrepo', vm_uuid: @vm_uuid, - openid_prefix: 'https://www.google.com/accounts/o8/id' } response_body = JSON.parse(@response.body) response_errors = response_body['errors'] @@ -243,7 +271,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, params: { repo_name: 'usertestrepo', user: {email: 'foo@example.com'}, - openid_prefix: 'https://www.google.com/accounts/o8/id' } assert_response :success @@ -263,7 +290,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase repo_name: 'usertestrepo', vm_uuid: 'no_such_vm', user: {email: 'foo@example.com'}, - openid_prefix: 'https://www.google.com/accounts/o8/id' } response_body = JSON.parse(@response.body) @@ -278,7 +304,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, params: { repo_name: 'usertestrepo', - openid_prefix: 'https://www.google.com/accounts/o8/id', vm_uuid: @vm_uuid, user: {email: 'foo@example.com'} } @@ -298,7 +323,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, params: { user: {email: 'foo@example.com'}, - openid_prefix: 'https://www.google.com/accounts/o8/id' } assert_response :success @@ -324,7 +348,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase authorize_with :admin post :setup, params: { - openid_prefix: 'https://www.google.com/accounts/o8/id', repo_name: 'usertestrepo', vm_uuid: @vm_uuid, user: { @@ -350,7 +373,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase inactive_user = users(:inactive) post :setup, params: { - openid_prefix: 'https://www.google.com/accounts/o8/id', repo_name: 'usertestrepo', user: { email: inactive_user['email'] @@ -373,7 +395,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, params: { repo_name: 'usertestrepo', - openid_prefix: 'http://www.example.com/account', user: { first_name: "in_create_test_first_name", last_name: "test_last_name", @@ -405,25 +426,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine' end - test "invoke setup with no openid prefix, expect error" do - authorize_with :admin - - post :setup, params: { - repo_name: 'usertestrepo', - user: { - first_name: "in_create_test_first_name", - last_name: "test_last_name", - email: "foo@example.com" - } - } - - response_body = JSON.parse(@response.body) - response_errors = response_body['errors'] - assert_not_nil response_errors, 'Expected error in response' - assert (response_errors.first.include? 'openid_prefix parameter is missing'), - 'Expected ArgumentError' - end - test "setup user with user, vm and repo and verify links" do authorize_with :admin @@ -435,7 +437,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase }, vm_uuid: @vm_uuid, repo_name: 'usertestrepo', - openid_prefix: 'https://www.google.com/accounts/o8/id' } assert_response :success @@ -481,7 +482,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase authorize_with :active post :setup, params: { - openid_prefix: 'https://www.google.com/accounts/o8/id', user: {email: 'foo@example.com'} } @@ -590,7 +590,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase authorize_with :admin post :setup, params: { - openid_prefix: 'http://www.example.com/account', send_notification_email: 'false', user: { email: "foo@example.com" @@ -611,7 +610,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase authorize_with :admin post :setup, params: { - openid_prefix: 'http://www.example.com/account', send_notification_email: 'true', user: { email: "foo@example.com" @@ -629,7 +627,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert_equal Rails.configuration.Users.UserNotifierEmailFrom, setup_email.from[0] assert_equal 'foo@example.com', setup_email.to[0] - assert_equal 'Welcome to Arvados - shell account enabled', setup_email.subject + assert_equal 'Welcome to Arvados - account enabled', setup_email.subject assert (setup_email.body.to_s.include? 'Your Arvados shell account has been set up'), 'Expected Your Arvados shell account has been set up in email body' assert (setup_email.body.to_s.include? "#{Rails.configuration.Services.Workbench1.ExternalURL}users/#{created['uuid']}/virtual_machines"), 'Expected virtual machines url in email body' @@ -1059,6 +1057,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase newuuid => { 'first_name' => 'noot', 'email' => 'root@remot.example.com', + 'username' => '', }, }}) assert_response(:success)