X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8ba91a5558a9fbb743c726a7e38f7e7dcd7bf8ee..7aaf9f22aa646077b4b7fd961d6b731185b88137:/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 817a1c9ef9..c807a7d6cb 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -609,6 +609,23 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase test "setup user with send notification param true and verify email" do authorize_with :admin + Rails.configuration.Users.UserSetupMailText = %{ +<% if not @user.full_name.empty? -%> +<%= @user.full_name %>, +<% else -%> +Hi there, +<% end -%> + +Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at + +<%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %> + +for connection instructions. + +Thanks, +The Arvados team. +} + post :setup, params: { send_notification_email: 'true', user: { @@ -660,7 +677,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase test "non-admin user gets only safe attributes from users#show" do g = act_as_system_user do - create :group + create :group, group_class: "role" end users = create_list :active_user, 2, join_groups: [g] token = create :token, user: users[0] @@ -672,7 +689,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase [2, 4].each do |limit| test "non-admin user can limit index to #{limit}" do g = act_as_system_user do - create :group + create :group, group_class: "role" end users = create_list :active_user, 4, join_groups: [g] token = create :token, user: users[0] @@ -783,27 +800,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase "user's writable_by should include its owner_uuid") end - [ - [:admin, true], - [:active, false], - ].each do |auth_user, expect_success| - test "update_uuid as #{auth_user}" do - authorize_with auth_user - orig_uuid = users(:active).uuid - post :update_uuid, params: { - id: orig_uuid, - new_uuid: 'zbbbb-tpzed-abcde12345abcde', - } - if expect_success - assert_response :success - assert_empty User.where(uuid: orig_uuid) - else - assert_response 403 - assert_not_empty User.where(uuid: orig_uuid) - end - end - end - test "merge with redirect_to_user_uuid=false" do authorize_with :project_viewer_trustedclient tok = api_client_authorizations(:project_viewer).api_token @@ -1039,9 +1035,12 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase test "batch update" do existinguuid = 'remot-tpzed-foobarbazwazqux' newuuid = 'remot-tpzed-newnarnazwazqux' + unchanginguuid = 'remot-tpzed-nochangingattrs' act_as_system_user do User.create!(uuid: existinguuid, email: 'root@existing.example.com') + User.create!(uuid: unchanginguuid, email: 'root@unchanging.example.com', prefs: {'foo' => {'bar' => 'baz'}}) end + assert_equal(1, Log.where(object_uuid: unchanginguuid).count) authorize_with(:admin) patch(:batch_update, @@ -1059,6 +1058,10 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase 'email' => 'root@remot.example.com', 'username' => '', }, + unchanginguuid => { + 'email' => 'root@unchanging.example.com', + 'prefs' => {'foo' => {'bar' => 'baz'}}, + }, }}) assert_response(:success) @@ -1070,6 +1073,8 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert_equal('noot', User.find_by_uuid(newuuid).first_name) assert_equal('root@remot.example.com', User.find_by_uuid(newuuid).email) + + assert_equal(1, Log.where(object_uuid: unchanginguuid).count) end NON_ADMIN_USER_DATA = ["uuid", "kind", "is_active", "email", "first_name",