microsoft365_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Microsoft365 XOAUTH2', integration: true, required_envs: %w[MICROSOFT365_REFRESH_TOKEN MICROSOFT365_CLIENT_ID MICROSOFT365_CLIENT_SECRET MICROSOFT365_CLIENT_TENANT MICROSOFT365_USER], retry: 5, retry_wait: 30.seconds do # rubocop:disable RSpec/DescribeClass
  4. let(:channel) do
  5. create(:microsoft365_channel).tap(&:refresh_xoauth2!)
  6. end
  7. context 'when probing inbound' do
  8. before do
  9. options = channel.options[:inbound][:options]
  10. options[:port] = 993
  11. imap_delete_old_mails(options)
  12. end
  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