ldap_source.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. FactoryBot.define do
  3. factory :ldap_source do
  4. sequence(:name) { |n| "Source #{n}" }
  5. active { true }
  6. created_by_id { 1 }
  7. updated_by_id { 1 }
  8. prefs = {
  9. 'host' => ENV['IMPORT_LDAP_ENDPOINT'],
  10. 'ssl' => 'off',
  11. 'ssl_verify' => false,
  12. 'options' => { 'dc=foo,dc=example,dc=com'=>'dc=foo,dc=example,dc=com' },
  13. 'option' => 'dc=foo,dc=example,dc=com',
  14. 'base_dn' => 'dc=foo,dc=example,dc=com',
  15. 'bind_user' => ENV['IMPORT_LDAP_USER'],
  16. 'bind_pw' => ENV['IMPORT_LDAP_PASSWORD'],
  17. 'user_uid' => 'uid',
  18. 'user_filter' => '(objectClass=posixaccount)',
  19. 'group_uid' => 'dn',
  20. 'group_filter' => '(objectClass=posixgroup)',
  21. 'user_attributes' => { 'cn' => 'firstname', 'sn' => 'lastname', 'mail' => 'email', 'uid' => 'login', 'telephonenumber' => 'phone' },
  22. 'group_role_map' => { 'cn=admin,ou=groups,dc=foo,dc=example,dc=com' => ['1'], 'cn=1st level,ou=groups,dc=foo,dc=example,dc=com' => ['2'] },
  23. 'unassigned_users' => 'sigup_roles'
  24. }
  25. trait :with_config do
  26. preferences { prefs }
  27. end
  28. trait :with_ssl do
  29. preferences { prefs.merge('ssl' => 'ssl', 'ssl_verify' => false) }
  30. end
  31. trait :with_ssl_verified do
  32. preferences { prefs.merge('ssl' => 'ssl', 'ssl_verify' => true) }
  33. end
  34. trait :with_starttls do
  35. preferences { prefs.merge('ssl' => 'starttls', 'ssl_verify' => false) }
  36. end
  37. trait :with_starttls_verified do
  38. preferences { prefs.merge('ssl' => 'starttls', 'ssl_verify' => true) }
  39. end
  40. end
  41. end