aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-18 10:23:17 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-18 10:23:17 -0400
commitb3919d01554d31c5486d17332f4a4dde89a23239 (patch)
tree42a4bcacda5f7e88824487b269e2893a96422333 /test
parent88227658217ee82af7516d6a8013a6c04f037073 (diff)
downloadrails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.gz
rails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.bz2
rails-b3919d01554d31c5486d17332f4a4dde89a23239.zip
Don't require Postfix to send form data
Diffstat (limited to 'test')
-rw-r--r--test/controllers/ingresses/postfix/inbound_emails_controller_test.rb16
-rw-r--r--test/unit/inbound_email/message_id_test.rb4
2 files changed, 14 insertions, 6 deletions
diff --git a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
index bade5215d6..3fa0854576 100644
--- a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
+++ b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
@@ -5,8 +5,8 @@ ActionMailbox::Ingresses::Postfix::InboundEmailsController.password = "tbsy84uSV
class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
test "receiving an inbound email from Postfix" do
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
- post rails_postfix_inbound_emails_url, headers: { authorization: credentials },
- params: { message: fixture_file_upload("files/welcome.eml", "message/rfc822") }
+ post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" },
+ params: file_fixture("../files/welcome.eml").read
end
assert_response :no_content
@@ -18,12 +18,22 @@ class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDis
test "rejecting an unauthorized inbound email from Postfix" do
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
- post rails_postfix_inbound_emails_url, params: { message: fixture_file_upload("files/welcome.eml", "message/rfc822") }
+ post rails_postfix_inbound_emails_url, headers: { "Content-Type" => "message/rfc822" },
+ params: file_fixture("../files/welcome.eml").read
end
assert_response :unauthorized
end
+ test "rejecting an inbound email of an unsupported media type from Postfix" do
+ assert_no_difference -> { ActionMailbox::InboundEmail.count } do
+ post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "text/plain" },
+ params: file_fixture("../files/welcome.eml").read
+ end
+
+ assert_response :unsupported_media_type
+ end
+
private
delegate :username, :password, to: ActionMailbox::Ingresses::Postfix::InboundEmailsController
diff --git a/test/unit/inbound_email/message_id_test.rb b/test/unit/inbound_email/message_id_test.rb
index aa9ce90b4c..c744a5bf99 100644
--- a/test/unit/inbound_email/message_id_test.rb
+++ b/test/unit/inbound_email/message_id_test.rb
@@ -7,9 +7,7 @@ class ActionMailbox::InboundEmail::MessageIdTest < ActiveSupport::TestCase
end
test "message id is generated if its missing" do
- source_without_message_id = "Date: Fri, 28 Sep 2018 11:08:55 -0700\r\nTo: a@example.com\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello!"
- inbound_email = create_inbound_email Tempfile.new.tap { |raw_email| raw_email.write source_without_message_id }
-
+ inbound_email = create_inbound_email "Date: Fri, 28 Sep 2018 11:08:55 -0700\r\nTo: a@example.com\r\nMime-Version: 1.0\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: 7bit\r\n\r\nHello!"
assert_not_nil inbound_email.message_id
end
end