mirror of
https://github.com/discourse/discourse.git
synced 2025-09-12 21:10:47 +08:00
Merge pull request #2701 from riking/email-pr-ssl
Rename POP3 settings, fix multisite SSL state leak
This commit is contained in:
commit
c07d76677d
6 changed files with 57 additions and 36 deletions
|
@ -7,18 +7,18 @@ describe Jobs::PollMailbox do
|
|||
|
||||
describe ".execute" do
|
||||
|
||||
it "does no polling if pop3s_polling_enabled is false" do
|
||||
SiteSetting.expects(:pop3s_polling_enabled?).returns(false)
|
||||
poller.expects(:poll_pop3s).never
|
||||
it "does no polling if pop3_polling_enabled is false" do
|
||||
SiteSetting.expects(:pop3_polling_enabled?).returns(false)
|
||||
poller.expects(:poll_pop3).never
|
||||
|
||||
poller.execute({})
|
||||
end
|
||||
|
||||
describe "with pop3s_polling_enabled" do
|
||||
describe "with pop3_polling_enabled" do
|
||||
|
||||
it "calls poll_pop3s" do
|
||||
SiteSetting.expects(:pop3s_polling_enabled?).returns(true)
|
||||
poller.expects(:poll_pop3s).once
|
||||
it "calls poll_pop3" do
|
||||
SiteSetting.expects(:pop3_polling_enabled?).returns(true)
|
||||
poller.expects(:poll_pop3).once
|
||||
|
||||
poller.execute({})
|
||||
end
|
||||
|
@ -26,19 +26,34 @@ describe Jobs::PollMailbox do
|
|||
|
||||
end
|
||||
|
||||
describe ".poll_pop3s" do
|
||||
describe ".poll_pop3" do
|
||||
|
||||
it "logs an error on pop authentication error" do
|
||||
error = Net::POPAuthenticationError.new
|
||||
data = { limit_once_per: 1.hour, message_params: { error: error }}
|
||||
|
||||
Net::POP3.expects(:start).raises(error)
|
||||
Net::POP3.any_instance.expects(:start).raises(error)
|
||||
|
||||
Discourse.expects(:handle_exception)
|
||||
|
||||
poller.poll_pop3s
|
||||
poller.poll_pop3
|
||||
end
|
||||
|
||||
it "calls enable_ssl when the setting is enabled" do
|
||||
SiteSetting.pop3_polling_ssl = true
|
||||
Net::POP3.any_instance.stubs(:start)
|
||||
Net::POP3.any_instance.expects(:enable_ssl)
|
||||
|
||||
poller.poll_pop3
|
||||
end
|
||||
|
||||
it "does not call enable_ssl when the setting is off" do
|
||||
SiteSetting.pop3_polling_ssl = false
|
||||
Net::POP3.any_instance.stubs(:start)
|
||||
Net::POP3.any_instance.expects(:enable_ssl).never
|
||||
|
||||
poller.poll_pop3
|
||||
end
|
||||
end
|
||||
|
||||
# Testing mock for the email objects that you get
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue