X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/397191893819083925600a61e2f355a3b6513354..65121f8db54a1ed15207d050e1f48c5fc26d646b:/services/api/test/unit/user_test.rb diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb index b96645ce26..3bd6ed4003 100644 --- a/services/api/test/unit/user_test.rb +++ b/services/api/test/unit/user_test.rb @@ -93,6 +93,16 @@ class UserTest < ActiveSupport::TestCase test "new username set with deduplication" do name = users(:active).username check_new_username_setting(name, "#{name}2") + check_new_username_setting(name, "#{name}3") + # Insert some out-of-order conflicts, to ensure our "sort by + # username, stop when we see a hole" strategy doesn't depend on + # insert order. + check_new_username_setting("#{name}13", "#{name}13") + check_new_username_setting("#{name}5", "#{name}5") + check_new_username_setting(name, "#{name}4") + 6.upto(12).each do |n| + check_new_username_setting(name, "#{name}#{n}") + end end test "new username set avoiding blacklist" do @@ -126,7 +136,6 @@ class UserTest < ActiveSupport::TestCase test "admin can't clear username when user owns repositories" do set_user_from_auth :admin user = users(:active) - start_username = user.username user.username = nil assert_not_allowed { user.save } refute_empty(user.errors[:username]) @@ -267,10 +276,12 @@ class UserTest < ActiveSupport::TestCase assert @uninvited_user.can? :write=>"#{@uninvited_user.uuid}" assert @uninvited_user.can? :manage=>"#{@uninvited_user.uuid}" - assert @uninvited_user.groups_i_can(:read).size == 1, "inactive and uninvited user can only read anonymous user group" - assert @uninvited_user.groups_i_can(:read).first.ends_with? 'anonymouspublic' , "inactive and uninvited user can only read anonymous user group" - assert @uninvited_user.groups_i_can(:write).size == 0, "inactive and uninvited user should not be able write to any groups" - assert @uninvited_user.groups_i_can(:manage).size == 0, "inactive and uninvited user should not be able manage any groups" + assert_equal(@uninvited_user.groups_i_can(:read).sort, + [@uninvited_user.uuid, groups(:anonymous_group).uuid].sort) + assert_equal(@uninvited_user.groups_i_can(:write), + [@uninvited_user.uuid]) + assert_equal(@uninvited_user.groups_i_can(:manage), + [@uninvited_user.uuid]) end test "find user method checks" do