local_user = User.find_by_username(needupdate[:username])
# A cached user record from the LoginCluster is stale, reset its username
# and retry the update operation.
- if local_user.andand.uuid[0..4] == loginCluster && local_user.uuid != u.uuid
- new_username = "#{needupdate[:username]}conflict#{rand(99999999)}"
+ if local_user.uuid != u.uuid
+ new_username = "#{needupdate[:username]}#{rand(99999999)}"
Rails.logger.warn("cached username '#{needupdate[:username]}' collision with user '#{local_user.uuid}' - renaming to '#{new_username}' before retrying")
local_user.update!({username: new_username})
retry
existinguuid = 'remot-tpzed-foobarbazwazqux'
newuuid = 'remot-tpzed-newnarnazwazqux'
unchanginguuid = 'remot-tpzed-nochangingattrs'
+ conflictinguuid1 = 'remot-tpzed-conflictingname'
+ conflictinguuid2 = 'remot-tpzed-conflictingname'
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: {
'email' => 'root@unchanging.example.com',
'prefs' => {'foo' => {'bar' => 'baz'}},
},
+ conflictinguuid1 => {
+ 'email' => 'root@conflictingname1.example.com',
+ 'username' => 'active'
+ },
+ conflictinguuid1 => {
+ 'email' => 'root@conflictingname2.example.com',
+ 'username' => 'federatedactive'
+ },
}})
assert_response(:success)