From b3919d01554d31c5486d17332f4a4dde89a23239 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Thu, 18 Oct 2018 10:23:17 -0400 Subject: Don't require Postfix to send form data --- .../ingresses/postfix/inbound_emails_controller_test.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test/controllers/ingresses/postfix') 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 -- cgit v1.2.3