收敛Smail系统通知SMTP通道并更新验收清单

完成Smail系统通知SMTP路由、验证码发送约束和相关回归测试,更新Linux生产测试记录、整改主清单及任务执行清单。
This commit is contained in:
xuans committed 2026-10-01 05:57:07 +08:00
1 parent 37b2ae016b
commit 07229adadc
9 files changed
+110 -1

No files matched your search

@@ -12,6 +12,8 @@ import (
"io"
"math/big"
"net"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
@@ -313,6 +315,35 @@ func TestSmailSystemSenderUsesSameEnvelopeAndHeader(t *testing.T) {
}
}
func TestSmailSystemNotificationUsesSMTPOnly(t *testing.T) {
server := newSMTPTestServer(t, true, false)
host, port := server.address()
calls := 0
endpoint := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
w.WriteHeader(http.StatusBadGateway)
}))
defer endpoint.Close()
cfg := smtpTestConfig(host, port, "implicit_tls")
cfg.SMTPUsername = "notify:scert@example.test"
cfg.HTTPEnabled = true
cfg.Endpoint = endpoint.URL
cfg.HTTPPath = "/api/email/send"
service := New(cfg, credentialReaderStub{values: map[string]string{"password": "test-only-notification-credential"}})
service.smtpTLSConfig = server.clientTLSConfig
if err := service.Send(context.Background(), Event{Type: "certificate_issue", Status: "success", Domain: "example.test"}); err != nil {
t.Fatal(err)
}
if calls != 0 {
t.Fatalf("Smail 系统通知不应调用 HTTP 通道,调用次数:%d", calls)
}
server.mu.Lock()
defer server.mu.Unlock()
if len(server.messages) != 1 {
t.Fatalf("SMTP 系统通知数量错误:%d", len(server.messages))
}
}
func TestSMTPStartTLS(t *testing.T) {
server := newSMTPTestServer(t, false, true)
host, port := server.address()