2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2020-10-02 12:46:19 +00:00
|
|
|
require 'rails_helper'
|
2020-11-23 13:13:16 +00:00
|
|
|
RSpec.describe 'Microsoft365 XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass
|
2020-11-20 10:54:09 +00:00
|
|
|
let(:channel) do
|
|
|
|
create(:microsoft365_channel).tap(&:refresh_xoauth2!)
|
|
|
|
end
|
2020-10-02 12:46:19 +00:00
|
|
|
|
|
|
|
before do
|
2020-10-27 14:05:10 +00:00
|
|
|
required_envs = %w[MICROSOFT365_REFRESH_TOKEN MICROSOFT365_CLIENT_ID MICROSOFT365_CLIENT_SECRET MICROSOFT365_USER]
|
2020-10-02 12:46:19 +00:00
|
|
|
required_envs.each do |key|
|
|
|
|
skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-23 13:13:16 +00:00
|
|
|
context 'when probing inbound' do
|
2020-10-02 12:46:19 +00:00
|
|
|
it 'succeeds' do
|
|
|
|
result = EmailHelper::Probe.inbound(channel.options[:inbound])
|
|
|
|
expect(result[:result]).to eq('ok')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-23 13:13:16 +00:00
|
|
|
context 'when probing outbound' do
|
2020-10-02 12:46:19 +00:00
|
|
|
it 'succeeds' do
|
2020-10-27 14:05:10 +00:00
|
|
|
result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['MICROSOFT365_USER'], "test microsoft365 oauth unittest #{Random.new_seed}")
|
2020-10-02 12:46:19 +00:00
|
|
|
expect(result[:result]).to eq('ok')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|