@@ -8,6 +8,9 @@ class Test::Proxy::Envoy::TestSmtpProxy < Minitest::Test
8
8
def setup
9
9
super
10
10
setup_server
11
+ @ssl_context_params = {
12
+ ca_file : File . join ( API_UMBRELLA_SRC_ROOT , "test/config/ssl_test.crt" ) ,
13
+ }
11
14
end
12
15
13
16
def test_disabled_by_default
@@ -17,7 +20,7 @@ def test_disabled_by_default
17
20
end
18
21
19
22
def test_direct_smtp_sanity_check
20
- smtp = Net ::SMTP . new ( "in-v3.mailjet.com " , 80 , starttls : :always )
23
+ smtp = Net ::SMTP . new ( "127.0.0.1 " , $config [ "mailpit" ] [ "smtp_port" ] , starttls : :always , ssl_context_params : @ssl_context_params , tls_hostname : "ssltest.example.com" )
21
24
smtp . open_timeout = 5
22
25
smtp . start
23
26
assert_equal ( true , smtp . esmtp? )
@@ -31,8 +34,8 @@ def test_only_connects_to_single_target
31
34
"smtp_proxy" => {
32
35
"enabled" => true ,
33
36
"endpoint" => {
34
- "host" => "in-v3.mailjet.com " ,
35
- "port" => 80 ,
37
+ "host" => "127.0.0.1 " ,
38
+ "port" => $config [ "mailpit" ] [ "smtp_port" ] ,
36
39
} ,
37
40
} ,
38
41
} ,
@@ -41,15 +44,15 @@ def test_only_connects_to_single_target
41
44
assert_equal ( true , open )
42
45
43
46
# Verify that without an explict TLS host, we get a certificate error.
44
- smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always )
47
+ smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always , ssl_context_params : @ssl_context_params )
45
48
smtp . open_timeout = 5
46
49
error = assert_raises OpenSSL ::SSL ::SSLError do
47
50
smtp . start
48
51
end
49
52
assert_match ( "certificate verify failed (hostname mismatch)" , error . message )
50
53
51
54
# Verify normal connection to the expected underlying host.
52
- smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always , tls_hostname : "in-v3.mailjet .com" )
55
+ smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always , ssl_context_params : @ssl_context_params , tls_hostname : "ssltest.example .com" )
53
56
smtp . open_timeout = 5
54
57
smtp . start
55
58
assert_equal ( true , smtp . esmtp? )
@@ -58,7 +61,7 @@ def test_only_connects_to_single_target
58
61
59
62
# Verify that trying a different TLS host also results in a certificate
60
63
# error.
61
- smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always , tls_hostname : "email.us-east-1.amazonaws.com" )
64
+ smtp = Net ::SMTP . new ( "127.0.0.1" , 13003 , starttls : :always , ssl_context_params : @ssl_context_params , tls_hostname : "email.us-east-1.amazonaws.com" )
62
65
smtp . open_timeout = 5
63
66
error = assert_raises OpenSSL ::SSL ::SSLError do
64
67
smtp . start
@@ -73,8 +76,8 @@ def test_web_app_uses_proxy
73
76
"smtp_proxy" => {
74
77
"enabled" => true ,
75
78
"endpoint" => {
76
- "host" => "in-v3.mailjet.com " ,
77
- "port" => 80 ,
79
+ "host" => "127.0.0.1 " ,
80
+ "port" => $config [ "mailpit" ] [ "smtp_port" ] ,
78
81
} ,
79
82
} ,
80
83
} ,
0 commit comments