external_credential.rb 2.1 KB

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