diff options
author | George Claghorn <george@basecamp.com> | 2018-10-29 13:45:24 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-10-29 13:45:24 -0400 |
commit | be0a8bec8701c7df2667dbf1569429218ea30370 (patch) | |
tree | 9dbf39394a938caa14411febca02db043d379b92 /test/controllers/ingresses/postfix/inbound_emails_controller_test.rb | |
parent | 02fcfec0c682cb3ff175927155a37e934ee1d0fe (diff) | |
download | rails-be0a8bec8701c7df2667dbf1569429218ea30370.tar.gz rails-be0a8bec8701c7df2667dbf1569429218ea30370.tar.bz2 rails-be0a8bec8701c7df2667dbf1569429218ea30370.zip |
Raise when required config is missing
Diffstat (limited to 'test/controllers/ingresses/postfix/inbound_emails_controller_test.rb')
-rw-r--r-- | test/controllers/ingresses/postfix/inbound_emails_controller_test.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb index 3fa0854576..a9588791b9 100644 --- a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb +++ b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb @@ -34,10 +34,35 @@ class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDis assert_response :unsupported_media_type end + test "raising when the configured password is nil" do + switch_password_to nil do + assert_raises ArgumentError do + post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" }, + params: file_fixture("../files/welcome.eml").read + end + end + end + + test "raising when the configured password is blank" do + switch_password_to "" do + assert_raises ArgumentError do + post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" }, + params: file_fixture("../files/welcome.eml").read + end + end + end + private - delegate :username, :password, to: ActionMailbox::Ingresses::Postfix::InboundEmailsController + delegate :username, :password, :password=, to: ActionMailbox::Ingresses::Postfix::InboundEmailsController def credentials ActionController::HttpAuthentication::Basic.encode_credentials username, password end + + def switch_password_to(new_password) + previous_password, self.password = password, new_password + yield + ensure + self.password = previous_password + end end |