added IMAP, LetsEncrypt, update layout

This commit is contained in:
2026-08-12 21:14:19 +01:00
parent 6e103959b0
commit 70fa1a5f2c
222 changed files with 42947 additions and 14038 deletions
+25 -3
View File
@@ -11,8 +11,10 @@ import (
"time"
"gopkg.in/ini.v1"
"mailgoserver/internal/acmecert"
"mailgoserver/internal/db"
"mailgoserver/internal/dkim"
"mailgoserver/internal/mailstore"
"mailgoserver/internal/toolbox"
)
@@ -72,6 +74,17 @@ func newTestApp(t *testing.T) *App {
t.Fatal(err)
}
mstore := mailstore.New(database, mailstore.GenerateDEK(), filepath.Join(dir, "mailstore"))
mdek := mailstore.GenerateDEK()
mwrapped, mnonce, err := mstore.WrapDEK(mdek)
if err != nil {
t.Fatal(err)
}
mboxID, err := database.CreateMailbox("inbox@example.com", hash, domainID, 5*1024*1024*1024, mwrapped, mnonce)
if err != nil {
t.Fatal(err)
}
cfg := ini.Empty()
serverSec, _ := cfg.NewSection("Server")
serverSec.NewKey("smtp_port", "4025")
@@ -96,17 +109,22 @@ func newTestApp(t *testing.T) *App {
dkimSec.NewKey("spf_server_ip", "192.168.1.1")
attSec, _ := cfg.NewSection("Attachments")
attSec.NewKey("attachments_path", filepath.Join(dir, "attachments"))
mailstoreSec, _ := cfg.NewSection("Mailstore")
mailstoreSec.NewKey("app_password_min_length", "25")
mailstoreSec.NewKey("spam_reject_score", "5")
configPath := filepath.Join(dir, "settings.ini")
cfg.SaveTo(configPath)
app, err := New(database, dkimMgr, cfg, configPath, toolbox.GetLogger("test"), func() bool { return true })
acmeMgr := acmecert.New(cfg, filepath.Join(dir, "server.crt"), filepath.Join(dir, "server.key"), filepath.Join(dir, "acme"), nil, toolbox.GetLogger("test"))
app, err := New(database, dkimMgr, mstore, acmeMgr, cfg, configPath, toolbox.GetLogger("test"), func() bool { return true })
if err != nil {
t.Fatalf("New: %v", err)
}
_ = senderID
_ = key
_ = mboxID
return app
}
@@ -136,11 +154,12 @@ func TestAllPagesRender(t *testing.T) {
domains, _ := app.DB.ListDomains()
senders, _ := app.DB.ListSenders()
mailboxes, _ := app.DB.ListMailboxes()
ips, _ := app.DB.ListWhitelistedIPs()
keys, _ := app.DB.ListActiveDKIMKeysWithDomain()
logs, _ := app.DB.ListEmailLogsPage(0, 10)
if len(domains) == 0 || len(senders) == 0 || len(ips) == 0 || len(keys) == 0 || len(logs) == 0 {
t.Fatalf("seed data missing: domains=%d senders=%d ips=%d keys=%d logs=%d", len(domains), len(senders), len(ips), len(keys), len(logs))
if len(domains) == 0 || len(senders) == 0 || len(mailboxes) == 0 || len(ips) == 0 || len(keys) == 0 || len(logs) == 0 {
t.Fatalf("seed data missing: domains=%d senders=%d mailboxes=%d ips=%d keys=%d logs=%d", len(domains), len(senders), len(mailboxes), len(ips), len(keys), len(logs))
}
pagesToCheck := []string{
@@ -148,10 +167,13 @@ func TestAllPagesRender(t *testing.T) {
"/account",
"/domains", "/domains/add", "/domains/" + itoa(domains[0].ID) + "/edit",
"/senders", "/senders/add", "/senders/" + itoa(senders[0].ID) + "/edit",
"/mailboxes", "/mailboxes/add", "/mailboxes/" + itoa(mailboxes[0].ID) + "/edit", "/mailboxes/" + itoa(mailboxes[0].ID) + "/apppasswords", "/mailboxes/" + itoa(mailboxes[0].ID) + "/aliases",
"/mailboxes/" + itoa(mailboxes[0].ID) + "/lists", "/mailboxes/" + itoa(mailboxes[0].ID) + "/rules",
"/ips", "/ips/add", "/ips/" + itoa(ips[0].ID) + "/edit",
"/dkim", "/dkim/" + itoa(keys[0].ID) + "/edit",
"/logs", "/logs?type=emails", "/logs?type=auth",
"/settings",
"/letsencrypt",
"/msg/content/" + itoa(logs[0].ID),
"/admins", "/admins/add",
}