X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ff8d14acd42952a21f5428e96d86e4a54c41be9a..0e1f8c8b47ddecbb3b6db360c8fda2fa612590ee:/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 98643a9e74..b75479ff8d 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' require 'helpers/users_test_helper' @@ -8,6 +12,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase setup do @initial_link_count = Link.count @vm_uuid = virtual_machines(:testvm).uuid + ActionMailer::Base.deliveries = [] end test "activate a user after signing UA" do @@ -213,26 +218,6 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase @vm_uuid, resp_obj['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine' end - test "invoke setup with existing uuid in user, verify response" do - authorize_with :admin - inactive_user = users(:inactive) - - post :setup, { - user: {uuid: inactive_user['uuid']}, - openid_prefix: 'https://www.google.com/accounts/o8/id' - } - - assert_response :success - - response_items = JSON.parse(@response.body)['items'] - resp_obj = find_obj_in_resp response_items, 'User', nil - - assert_not_nil resp_obj['uuid'], 'expected uuid for the new user' - assert_equal inactive_user['uuid'], resp_obj['uuid'] - assert_equal inactive_user['email'], resp_obj['email'], - 'expecting inactive user email' - end - test "invoke setup with existing uuid but different email, expect original email" do authorize_with :admin inactive_user = users(:inactive) @@ -659,6 +644,24 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert (setup_email.body.to_s.include? "#{Rails.configuration.workbench_address}users/#{created['uuid']}/virtual_machines"), 'Expected virtual machines url in email body' end + test "setup inactive user by changing is_active to true" do + authorize_with :admin + active_user = users(:active) + + # invoke setup with a repository + put :update, { + id: active_user['uuid'], + user: { + is_active: true, + } + } + assert_response :success + assert_equal active_user['uuid'], json_response['uuid'] + updated = User.where(uuid: active_user['uuid']).first + assert_equal(true, updated.is_active) + assert_equal({read: true}, updated.group_permissions[all_users_group_uuid]) + end + test "non-admin user can get basic information about readable users" do authorize_with :spectator get(:index)