Skip to content

Commit

Permalink
fix: align testing code with now finished ruby/net-smtp gem
Browse files Browse the repository at this point in the history
  • Loading branch information
TomFreudenberg committed Jun 11, 2021
1 parent bf003aa commit a93dfb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ end
group :testing do
gem 'openssl'
gem 'minitest'
gem 'net-smtp', github: 'TomFreudenberg/net-smtp', branch: 'master'
gem 'net-smtp', github: 'ruby/net-smtp', branch: 'master'
gem 'mail'
end
7 changes: 5 additions & 2 deletions test/construct/base_integration_test_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def net_smtp_send_mail(envelope_mail_from, envelope_rcpt_to, message_data, authe
@smtpd.ssl_context.extra_chain_cert&.each { |c| store.add_cert(c) }
end

if Net::SMTP.const_defined?('VERSION') && (Net::SMTP::VERSION > '0.2.1')
if Net::SMTP.const_defined?('VERSION') && (Net::SMTP::VERSION >= '0.2.1')
smtp.start('Integration Test client', authentication_id, password, auth_type, ssl_context_params: { cert_store: store, verify_mode: OpenSSL::SSL::VERIFY_PEER }) do
# when sending mails, send one additional crlf to safe the original linebreaks
smtp.send_message("#{message_data}\r\n", envelope_mail_from, envelope_rcpt_to)
Expand All @@ -51,7 +51,10 @@ def mikel_mail_send_mail(_envelope_mail_from, _envelope_rcpt_to, message_data, a
m = Mail.read_from_string("#{message_data}\r\n")

store = OpenSSL::X509::Store.new
store.add_cert(@smtpd.ssl_context.cert) if @smtpd.ssl_context
if @smtpd.ssl_context
store.add_cert(@smtpd.ssl_context.cert)
@smtpd.ssl_context.extra_chain_cert&.each { |c| store.add_cert(c) }
end

m.delivery_method \
:smtp,
Expand Down
2 changes: 1 addition & 1 deletion test/construct/mail_smtp_class_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Mail
class SMTP

def start_smtp_session(&block)
if Net::SMTP.const_defined?('VERSION') && (Net::SMTP::VERSION > '0.2.1')
if Net::SMTP.const_defined?('VERSION') && (Net::SMTP::VERSION >= '0.2.1')
build_smtp_session.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication], ssl_context_params: settings[:ssl_context_params], &block)
else
build_smtp_session.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication], &block)
Expand Down

0 comments on commit a93dfb4

Please sign in to comment.