From 97fb3cb6344c7a9e9cba90a875f3b471d82f316a Mon Sep 17 00:00:00 2001 From: Tom Freudenberg Date: Tue, 21 Jan 2020 01:11:59 +0100 Subject: [PATCH] add: test to get exception if certificate CN or SAN does not match the expected OpenSSL hostname --- .../invalid_certificate_name_test.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/integration/invalid_certificate_name_test.rb diff --git a/test/integration/invalid_certificate_name_test.rb b/test/integration/invalid_certificate_name_test.rb new file mode 100644 index 0000000..c5efaf9 --- /dev/null +++ b/test/integration/invalid_certificate_name_test.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Unit test to check commands without TCP +class InvalidCertificateNameIntegrationTest < BaseIntegrationTest + + # initialize before tests + def setup + # create some message vars and sources + super + # create service instance + @smtpd = MidiSmtpServerTest.new( + '5555', + '127.0.0.1', + 1, + do_dns_reverse_lookup: false, + auth_mode: :AUTH_OPTIONAL, + tls_mode: :TLS_REQUIRED, + tls_cert_cn: 'invalid.hostname', + pipelining_extension: false, + internationalization_extensions: true + ) + # start the daemon to run real life integration tests + @smtpd.start + end + + ### TEST SUITE + + def test_net_smtp_auth_login_and_simple_send_1_mail_with_ssl + assert_raises(OpenSSL::SSL::SSLError) { net_smtp_send_mail @envelope_mail_from, @envelope_rcpt_to, @doc_simple_mail, 'administrator', 'password', :login, true } + end + +end