Почта: поле «Проверочное письмо — кому» вернулось — по умолчанию администратор системы, можно указать свой адрес

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
zuevav
2026-10-06 22:51:29 +03:00
parent 4593a72cec
commit c4fb0d9bfc
4 changed files with 55 additions and 12 deletions
+21
View File
@@ -1,6 +1,8 @@
package lkgateway
import (
"net/http"
"net/http/httptest"
"path/filepath"
"strings"
"testing"
@@ -136,3 +138,22 @@ func TestSMBLocation(t *testing.T) {
t.Error("smbShareOK/smbWin")
}
}
// Поле «Проверочное письмо — кому»: адрес администратора по умолчанию не дублируется, свой — запоминается.
func TestSMTPTestTo(t *testing.T) {
s := SMTPSettings{To: "it@example.ru", TestTo: "old@example.ru"}
req := func(body string) *http.Request {
r := httptest.NewRequest(http.MethodPost, "/admin/setup/alerts-smtp-test", strings.NewReader(body))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
return r
}
if got := smtpTestTo(req("test_to=me%40example.ru"), s); got != "me@example.ru" {
t.Errorf("свой адрес: %q", got)
}
if got := smtpTestTo(req("test_to=it%40example.ru"), s); got != "" {
t.Errorf("адрес администратора не хранится отдельно: %q", got)
}
if got := smtpTestTo(req("host=x"), s); got != "old@example.ru" {
t.Errorf("без поля — прежний: %q", got)
}
}