microsoft365_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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. # TODO: Remove this once we have a better way for testing M365.
  8. before do
  9. skip 'This test example requires a valid account for M365.'
  10. end
  11. context 'when probing inbound' do
  12. before do
  13. options = channel.options[:inbound][:options]
  14. options[:port] = 993
  15. imap_delete_old_mails(options)
  16. end
  17. it 'succeeds' do
  18. result = EmailHelper::Probe.inbound(channel.options[:inbound])
  19. expect(result[:result]).to eq('ok')
  20. end
  21. end
  22. context 'when probing outbound' do
  23. it 'succeeds' do
  24. result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['MICROSOFT365_USER'], "test microsoft365 oauth unittest #{Random.new_seed}")
  25. expect(result[:result]).to eq('ok')
  26. end
  27. end
  28. end