external_credential.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. FactoryBot.define do
  3. factory :external_credential do
  4. factory :facebook_credential do
  5. name { 'facebook' }
  6. credentials { { application_id: 123, application_secret: 123 } }
  7. end
  8. factory :twitter_credential do
  9. name { 'twitter' }
  10. credentials do
  11. {
  12. consumer_key: consumer_key,
  13. consumer_secret: consumer_secret,
  14. oauth_token: oauth_token,
  15. oauth_token_secret: oauth_token_secret,
  16. env: 'zammad',
  17. controller: 'external_credentials',
  18. action: 'app_verify',
  19. provider: 'twitter',
  20. webhook_id: Faker::Number.unique.number(digits: 19),
  21. }
  22. end
  23. # When recording a new VCR cassette,
  24. # Twitter API tests need valid credentials--
  25. # but storing them in this file is a security no-no.
  26. #
  27. # Instead, store your twitter API credentials in env vars to utilize this factory.
  28. # (Try https://github.com/direnv/direnv to set env vars automatically.)
  29. transient do
  30. consumer_key { ENV.fetch('TWITTER_CONSUMER_KEY') { 'REDACTED' } }
  31. consumer_secret { ENV.fetch('TWITTER_CONSUMER_SECRET') { 'REDACTED' } }
  32. oauth_token { ENV.fetch('TWITTER_OAUTH_TOKEN') { 'REDACTED' } }
  33. oauth_token_secret { ENV.fetch('TWITTER_OAUTH_TOKEN_SECRET') { 'REDACTED' } }
  34. end
  35. trait :invalid do
  36. # If these credentials are fake/invalid,
  37. # why don't we use Faker to generate them dynamically?
  38. #
  39. # Our Twitter API tests use VCR to cache HTTP traffic.
  40. # If the values change each time you run the test,
  41. # VCR gets confused and raises errors.
  42. transient do
  43. consumer_key { 'q7K8GEkhyCHs9jHLtkmD9Kod4' }
  44. consumer_secret { 'LIDrpO6lRukO0PSicv00x9n8qMPvqvMq9mNInsby5sIkwN2J81' }
  45. oauth_token { '7783712304-H9s75r2d532diPmJYK6JrvUWxu9gTDZ6ocjfToL' }
  46. oauth_token_secret { 'XFhmXR1J17zaI3bEikHKG5zNUVHVnjpzPuQc0vNmb4z2y' }
  47. end
  48. end
  49. end
  50. factory :sms_message_bird_credential do
  51. name { 'message_bird' }
  52. credentials { { token: Faker::Alphanumeric.alphanumeric(number: 25) } }
  53. end
  54. factory :telegram_credential do
  55. name { 'telegram' }
  56. credentials { { api_token: "#{Faker::Alphanumeric.alphanumeric(number: 7)}-#{Faker::Alphanumeric.alphanumeric(number: 13)}_#{Faker::Alphanumeric.alphanumeric(number: 7)}_#{Faker::Alphanumeric.alphanumeric(number: 5)}" } }
  57. end
  58. end
  59. end