修复全新部署反代模式证书初始化失败

This commit is contained in:
xuans committed 2026-10-01 20:59:47 +08:00
1 parent 034059b034
commit 29dbe325be
4 files changed
+57 -4

No files matched your search

+25
View File
@@ -38,6 +38,31 @@ func TestSSLPolicyFollowsManagement(t *testing.T) {
}
}
func TestSSLPolicyFollowsRuntimeTLSOverride(t *testing.T) {
for _, test := range []struct {
name string
stored string
override string
wantProxy bool
}{
{name: "bootstrap_proxy", override: HTTPSTLSModeProxy, wantProxy: true},
{name: "direct_to_proxy", stored: HTTPSTLSModeDirect, override: " PROXY ", wantProxy: true},
{name: "proxy_to_direct", stored: HTTPSTLSModeProxy, override: HTTPSTLSModeDirect},
{name: "invalid_override", stored: HTTPSTLSModeProxy, override: "invalid", wantProxy: true},
} {
t.Run(test.name, func(t *testing.T) {
t.Setenv("SMAIL_HTTP_TLS_MODE_OVERRIDE", test.override)
cfg := &Config{TLSMode: test.stored, SSLType: SSLTypeAutoHTTP}
if got := cfg.UsesProxyHTTPS(); got != test.wantProxy {
t.Fatalf("proxy policy = %t, want %t", got, test.wantProxy)
}
if cfg.AutomaticSSLEnabled() == test.wantProxy {
t.Fatal("certificate policy disagrees with effective TLS mode")
}
})
}
}
func TestExternalCertificateReloadIgnoresLegacyDNSMode(t *testing.T) {
previousRoot := ROOT_PATH
ROOT_PATH = t.TempDir()