microsoft365_spec.rb 972 B

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe 'Microsoft365 XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass
  3. let(:channel) do
  4. create(:microsoft365_channel).tap(&:refresh_xoauth2!)
  5. end
  6. before do
  7. required_envs = %w[MICROSOFT365_REFRESH_TOKEN MICROSOFT365_CLIENT_ID MICROSOFT365_CLIENT_SECRET MICROSOFT365_USER]
  8. required_envs.each do |key|
  9. skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
  10. end
  11. end
  12. context 'when probing inbound' do
  13. it 'succeeds' do
  14. result = EmailHelper::Probe.inbound(channel.options[:inbound])
  15. expect(result[:result]).to eq('ok')
  16. end
  17. end
  18. context 'when probing outbound' do
  19. it 'succeeds' do
  20. result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['MICROSOFT365_USER'], "test microsoft365 oauth unittest #{Random.new_seed}")
  21. expect(result[:result]).to eq('ok')
  22. end
  23. end
  24. end