ldap_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe MigrateLdapSamaccountnameToUidJob::Ldap, type: :job do
  4. it 'performs no changes if uid attributes equals' do
  5. ldap_user = double
  6. allow(ldap_user).to receive(:uid_attribute).and_return('samaccountname')
  7. allow(Ldap::User).to receive(:new).and_return(ldap_user)
  8. allow(Ldap).to receive(:new)
  9. described_class.new(create(:ldap_source, preferences: { 'user_uid' => 'samaccountname' })).perform
  10. expect(ldap_user).to have_received(:uid_attribute)
  11. expect(Ldap::User).to have_received(:new)
  12. end
  13. it 'performs Setting change if uid attribute differ' do
  14. ldap_user = double
  15. allow(ldap_user).to receive(:uid_attribute).and_return('objectguid')
  16. allow(Ldap::User).to receive(:new).and_return(ldap_user)
  17. ldap_source = create(:ldap_source, preferences: { 'user_uid' => 'samaccountname' })
  18. allow(Ldap).to receive(:new)
  19. described_class.new(ldap_source).perform
  20. expect(ldap_user).to have_received(:uid_attribute)
  21. expect(ldap_source.preferences['user_uid']).to eq('objectguid')
  22. end
  23. end