X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4ad6191d53207a8b2d4c0c8a30b18119daaa5fbc..7f81518fcc602c7b8ec4e54ee73a43e56894138b:/services/api/test/integration/user_sessions_test.rb diff --git a/services/api/test/integration/user_sessions_test.rb b/services/api/test/integration/user_sessions_test.rb index eb49cf832e..2b37454218 100644 --- a/services/api/test/integration/user_sessions_test.rb +++ b/services/api/test/integration/user_sessions_test.rb @@ -87,22 +87,20 @@ class UserSessionsApiTest < ActionDispatch::IntegrationTest # Test various combinations of auto_setup configuration and email # address provided during a new user's first session setup. - [{result: :nope, email: nil, cfg: {auto: true, repo: true, vm: true}}, + [{result: :nope, email: nil, cfg: {auto: true, vm: true}}, {result: :yup, email: nil, cfg: {auto: true}}, - {result: :nope, email: '@example.com', cfg: {auto: true, repo: true, vm: true}}, + {result: :nope, email: '@example.com', cfg: {auto: true, vm: true}}, {result: :yup, email: '@example.com', cfg: {auto: true}}, - {result: :nope, email: 'root@', cfg: {auto: true, repo: true, vm: true}}, - {result: :nope, email: 'root@', cfg: {auto: true, repo: true}}, {result: :nope, email: 'root@', cfg: {auto: true, vm: true}}, - {result: :yup, email: 'root@', cfg: {auto: true}}, - {result: :nope, email: 'gitolite@', cfg: {auto: true, repo: true}}, + {result: :nope, email: 'root@', cfg: {auto: true}}, + {result: :nope, email: 'gitolite@', cfg: {auto: true}}, {result: :nope, email: '*_*@', cfg: {auto: true, vm: true}}, {result: :yup, email: 'toor@', cfg: {auto: true, vm: true, repo: true}}, {result: :yup, email: 'foo@', cfg: {auto: true, vm: true}, uniqprefix: 'foo'}, - {result: :yup, email: 'foo@', cfg: {auto: true, repo: true}, + {result: :yup, email: 'foo@', cfg: {auto: true}, uniqprefix: 'foo'}, - {result: :yup, email: 'auto_setup_vm_login@', cfg: {auto: true, repo: true}, + {result: :yup, email: 'auto_setup_vm_login@', cfg: {auto: true}, uniqprefix: 'auto_setup_vm_login'}, ].each do |testcase| test "user auto-activate #{testcase.inspect}" do @@ -111,23 +109,16 @@ class UserSessionsApiTest < ActionDispatch::IntegrationTest Rails.configuration.Users.AutoSetupNewUsers = testcase[:cfg][:auto] Rails.configuration.Users.AutoSetupNewUsersWithVmUUID = (testcase[:cfg][:vm] ? virtual_machines(:testvm).uuid : "") - Rails.configuration.Users.AutoSetupNewUsersWithRepository = - testcase[:cfg][:repo] mock_auth_with(email: testcase[:email]) u = assigns(:user) vm_links = Link.where('link_class=? and tail_uuid=? and head_uuid like ?', 'permission', u.uuid, '%-' + VirtualMachine.uuid_prefix + '-%') - repo_links = Link.where('link_class=? and tail_uuid=? and head_uuid like ?', - 'permission', u.uuid, - '%-' + Repository.uuid_prefix + '-%') - repos = Repository.where('uuid in (?)', repo_links.collect(&:head_uuid)) case u[:result] when :nope assert_equal false, u.is_invited, "should not have been set up" assert_empty vm_links, "should not have VM login permission" - assert_empty repo_links, "should not have repo permission" when :yup assert_equal true, u.is_invited if testcase[:cfg][:vm] @@ -135,21 +126,11 @@ class UserSessionsApiTest < ActionDispatch::IntegrationTest else assert_empty vm_links, "should not have VM login permission" end - if testcase[:cfg][:repo] - assert_equal 1, repo_links.count, "wrong number of repo perm links" - assert_equal 1, repos.count, "wrong number of repos" - assert_equal 'can_manage', repo_links.first.name, "wrong perm type" - else - assert_empty repo_links, "should not have repo permission" - end end if (prefix = testcase[:uniqprefix]) # This email address conflicts with a test fixture. Make sure - # every VM login and repository name got digits added to make - # it unique. - (repos.collect(&:name) + - vm_links.collect { |link| link.properties['username'] } - ).each do |name| + # every VM login got digits added to make it unique. + vm_links.collect { |link| link.properties['username'] }.each do |name| r = name.match(/^(.{#{prefix.length}})(\d+)$/) assert_not_nil r, "#{name.inspect} does not match {prefix}\\d+" assert_equal(prefix, r[1],