55 lines
1.5 KiB
Ruby
55 lines
1.5 KiB
Ruby
require "test_helper"
|
|
|
|
class MailIdentityTest < ActiveSupport::TestCase
|
|
test "smtp settings use starttls on port 587" do
|
|
identity = MailIdentity.new(
|
|
name: "Test",
|
|
from_name: "Test",
|
|
from_email: "hello@example.com",
|
|
smtp_host: "smtp.example.com",
|
|
smtp_port: 587,
|
|
encryption: "starttls",
|
|
smtp_authentication: "plain",
|
|
active: true
|
|
)
|
|
assert identity.valid?
|
|
settings = identity.smtp_settings
|
|
assert settings[:enable_starttls_auto]
|
|
assert_not settings[:ssl]
|
|
end
|
|
|
|
test "smtp settings use ssl on port 465" do
|
|
identity = MailIdentity.new(
|
|
name: "Test",
|
|
from_name: "Test",
|
|
from_email: "hello@example.com",
|
|
smtp_host: "smtps.example.com",
|
|
smtp_port: 465,
|
|
encryption: "tls",
|
|
smtp_authentication: "plain",
|
|
active: true
|
|
)
|
|
assert identity.valid?
|
|
settings = identity.smtp_settings
|
|
assert settings[:ssl]
|
|
assert_not settings[:enable_starttls_auto]
|
|
assert_equal 15, settings[:open_timeout]
|
|
assert_equal 60, settings[:read_timeout]
|
|
end
|
|
|
|
test "rejects ssl encryption on port 587" do
|
|
identity = MailIdentity.new(
|
|
name: "Test",
|
|
from_name: "Test",
|
|
from_email: "hello@example.com",
|
|
smtp_host: "smtps.example.com",
|
|
smtp_port: 587,
|
|
encryption: "tls",
|
|
smtp_authentication: "plain",
|
|
active: true
|
|
)
|
|
assert_not identity.valid?
|
|
assert_includes identity.errors[:smtp_port], "con SSL/TLS va usata la porta 465 (es. smtps.aruba.it)"
|
|
end
|
|
end
|