Files
eminuxCRM/test/models/mail_identity_test.rb
T
eminuxandCursor 765ee51eeb
CI / scan_ruby (push) Failing after 14m26s
CI / lint (push) Has been cancelled
CI / scan_js (push) Has been cancelled
Impedisce combinazioni SMTP errate tra porta e crittografia.
Evita l'errore SSL wrong version number quando SSL/TLS è impostato sulla porta 587 invece che sulla 465.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 00:09:25 +02:00

53 lines
1.4 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]
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