Files
eminuxCRM/test/models/mail_identity_test.rb
T
eminuxandCursor 403fe80d37
CI / scan_js (push) Has been cancelled
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
Serializza gli invii SMTP su una coda unica per non far chiudere Aruba.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 12:06:23 +02:00

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