X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6a18fc0d6f3f9859e905d4762796d813a157605b..de10e681e82e0cb987ffb95109a6c09a13f49944:/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 ee158d1e71..c364613060 100644 --- a/services/api/test/functional/arvados/v1/users_controller_test.rb +++ b/services/api/test/functional/arvados/v1/users_controller_test.rb @@ -64,7 +64,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase post :setup, { repo_name: repo_name, - vm_uuid: 'no_such_vm', + openid_prefix: 'https://www.google.com/accounts/o8/id', user: { uuid: "this_is_agreeable", first_name: "in_create_test_first_name", @@ -100,13 +100,14 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine' end - test "create user with bogus uuid, vm and repo as input" do + test "setup user with bogus uuid and expect error" do authorize_with :admin post :setup, { - uuid: 'not_an_existing_uuid_and_not_email_format', + uuid: 'bogus_uuid', repo_name: 'test_repo', - vm_uuid: 'no_such_vm' + vm_uuid: @vm_uuid, + openid_prefix: 'https://www.google.com/accounts/o8/id' } response_body = JSON.parse(@response.body) response_errors = response_body['errors'] @@ -114,6 +115,54 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase assert (response_errors.first.include? 'Path not found'), 'Expected 404' end + test "setup user with bogus uuid in user and expect error" do + authorize_with :admin + + post :setup, { + user: {uuid: 'bogus_uuid'}, + repo_name: 'test_repo', + vm_uuid: @vm_uuid, + openid_prefix: 'https://www.google.com/accounts/o8/id' + } + 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? 'RuntimeError: No email found'), + 'Expected RuntimeError' + end + + test "setup user with no uuid and user, expect error" do + authorize_with :admin + + post :setup, { + #uuid: 'not_an_existing_uuid_and_not_email_format', + repo_name: 'test_repo', + vm_uuid: @vm_uuid, + openid_prefix: 'https://www.google.com/accounts/o8/id' + } + 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? 'Required uuid or email'), + 'Expected ArgumentError' + end + + test "setup user with no uuid and email, expect error" do + authorize_with :admin + + post :setup, { + user: {}, + repo_name: 'test_repo', + vm_uuid: @vm_uuid, + openid_prefix: 'https://www.google.com/accounts/o8/id' + } + 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? '