X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5e4b8ac7997c68ffa45471b9879789c96068885d..4658a55dc90567b87f484578c91f4f04db9623ab:/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 ae7b21dec8..07e0b71d86 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -68,7 +68,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase test "respond 401 if given token exists but user record is missing" do authorize_with :valid_token_deleted_user - get :current, {format: :json} + get :current, format: :json assert_response 401 end @@ -151,7 +151,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage', "foo/#{repo_name}", created['uuid'], 'arvados#repository', true, 'Repository' - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', created['uuid'], 'arvados#group', true, 'Group' verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login', @@ -335,7 +335,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase # two extra links; system_group, and group verify_links_added 2 - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', response_object['uuid'], 'arvados#group', true, 'Group' verify_link response_items, 'arvados#repository', false, 'permission', 'can_manage', @@ -420,7 +420,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage', 'foo/usertestrepo', created['uuid'], 'arvados#repository', true, 'Repository' - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', created['uuid'], 'arvados#group', true, 'Group' verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login', @@ -458,7 +458,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage', 'foo/usertestrepo', created['uuid'], 'arvados#repository', true, 'Repository' - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', created['uuid'], 'arvados#group', true, 'Group' verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login', @@ -511,7 +511,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert_equal active_user[:email], created['email'], 'expected input email' # verify links - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', created['uuid'], 'arvados#group', true, 'Group' verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage', @@ -545,7 +545,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert_equal active_user['email'], created['email'], 'expected original email' # verify links - verify_link response_items, 'arvados#group', true, 'permission', 'can_read', + verify_link response_items, 'arvados#group', true, 'permission', 'can_write', 'All users', created['uuid'], 'arvados#group', true, 'Group' assert_equal(repos_count, repos_query.count) @@ -666,7 +666,7 @@ The Arvados team. 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]) + assert_equal({read: true, write: true}, updated.group_permissions[all_users_group_uuid]) end test "non-admin user can get basic information about readable users" do @@ -674,6 +674,12 @@ The Arvados team. get(:index) check_non_admin_index check_readable_users_index [:spectator], [:inactive, :active] + json_response["items"].each do |u| + if u["uuid"] == users(:spectator).uuid + assert_equal true, u["can_write"] + assert_equal true, u["can_manage"] + end + end end test "non-admin user gets only safe attributes from users#show" do @@ -883,7 +889,7 @@ The Arvados team. ['dst', :project_viewer_trustedclient]].each do |which_scoped, auth| test "refuse to merge with scoped #{which_scoped} token" do act_as_system_user do - api_client_authorizations(auth).update_attributes(scopes: ["GET /", "POST /", "PUT /"]) + api_client_authorizations(auth).update(scopes: ["GET /", "POST /", "PUT /"]) end authorize_with(:active_trustedclient) post(:merge, params: { @@ -1037,12 +1043,16 @@ The Arvados team. existinguuid = 'remot-tpzed-foobarbazwazqux' newuuid = 'remot-tpzed-newnarnazwazqux' unchanginguuid = 'remot-tpzed-nochangingattrs' + conflictinguuid1 = 'remot-tpzed-conflictingnam1' + conflictinguuid2 = 'remot-tpzed-conflictingnam2' 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) + Rails.configuration.Login.LoginCluster = 'remot' + authorize_with(:admin) patch(:batch_update, params: { @@ -1053,15 +1063,28 @@ The Arvados team. 'is_active' => true, 'is_admin' => true, 'prefs' => {'foo' => 'bar'}, + 'is_invited' => true }, newuuid => { 'first_name' => 'noot', 'email' => 'root@remot.example.com', 'username' => '', + 'is_invited' => true }, unchanginguuid => { 'email' => 'root@unchanging.example.com', 'prefs' => {'foo' => {'bar' => 'baz'}}, + 'is_invited' => true + }, + conflictinguuid1 => { + 'email' => 'root@conflictingname1.example.com', + 'username' => 'active', + 'is_invited' => true + }, + conflictinguuid2 => { + 'email' => 'root@conflictingname2.example.com', + 'username' => 'federatedactive', + 'is_invited' => true }, }}) assert_response(:success) @@ -1078,8 +1101,8 @@ The Arvados team. assert_equal(1, Log.where(object_uuid: unchanginguuid).count) end - NON_ADMIN_USER_DATA = ["uuid", "kind", "is_active", "email", "first_name", - "last_name", "username"].sort + NON_ADMIN_USER_DATA = ["uuid", "kind", "is_active", "is_admin", "is_invited", "email", "first_name", + "last_name", "username", "can_write", "can_manage"].sort def check_non_admin_index assert_response :success