X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b7ec820ac297bc316ef9ffa36242e7928acbc0b4..41a378b99c8c4411a66c19e878b7535c67de2ba3:/services/api/test/integration/users_test.rb diff --git a/services/api/test/integration/users_test.rb b/services/api/test/integration/users_test.rb index 81168e15b7..3660d35bad 100644 --- a/services/api/test/integration/users_test.rb +++ b/services/api/test/integration/users_test.rb @@ -434,20 +434,26 @@ class UsersTest < ActionDispatch::IntegrationTest params: {}, headers: {"HTTP_AUTHORIZATION" => "Bearer #{token}"}) assert_response(:success) - user = json_response - assert_equal true, user['is_active'] + userJSON = json_response + assert_equal true, userJSON['is_active'] post("/arvados/v1/users/#{user['uuid']}/unsetup", params: {}, headers: auth(:admin)) assert_response :success + # Need to get a new token, the old one was invalidated by the unsetup call + act_as_system_user do + ap = ApiClientAuthorization.create!(user: user, api_client_id: 0) + token = ap.api_token + end + get("/arvados/v1/users/#{user['uuid']}", params: {}, headers: {"HTTP_AUTHORIZATION" => "Bearer #{token}"}) assert_response(:success) - user = json_response - assert_equal false, user['is_active'] + userJSON = json_response + assert_equal false, userJSON['is_active'] post("/arvados/v1/users/#{user['uuid']}/activate", params: {}, @@ -474,4 +480,17 @@ class UsersTest < ActionDispatch::IntegrationTest assert_response 403 end + test "disabling system root user not permitted" do + put("/arvados/v1/users/#{users(:system_user).uuid}", + params: { + user: {is_admin: false} + }, + headers: auth(:admin)) + assert_response 422 + + post("/arvados/v1/users/#{users(:system_user).uuid}/unsetup", + params: {}, + headers: auth(:admin)) + assert_response 422 + end end