运行时配置清理阶段检查点

This commit is contained in:
xuans committed 2026-10-05 01:31:34 +08:00
1 parent 2851a7a3ff
commit 7d86d01318
80 files changed
+422 -368

No files matched your search

+6 -6
View File
@@ -99,13 +99,13 @@ func TestResolveIdentifierFallbackToConfiguredDomainUser(t *testing.T) {
config.Instance = &config.Config{
DbType: config.DBTypeSQLite,
DbDSN: filepath.Join(t.TempDir(), "domain_fallback.db"),
Domain: "solit.cn",
Domains: []string{"solit.cn"},
Domain: "example.com",
Domains: []string{"example.com"},
}
if err := db.Init(""); err != nil {
t.Fatal(err)
}
if got, err := NormalizeProtocolIdentifier(" Bob@Solit.cn "); err != nil || got != "bob@solit.cn" {
if got, err := NormalizeProtocolIdentifier(" Bob@Example.com "); err != nil || got != "bob@example.com" {
t.Fatalf("normalized protocol identifier = %q, err = %v", got, err)
}
for _, identifier := range []string{"bob", "bob@other.com"} {
@@ -129,11 +129,11 @@ func TestResolveIdentifierFallbackToConfiguredDomainUser(t *testing.T) {
t.Fatal(err)
}
identity, err := ResolveIdentifier(" Bob@Solit.cn ")
identity, err := ResolveIdentifier(" Bob@Example.com ")
if err != nil {
t.Fatalf("resolve configured domain user failed: %v", err)
}
if identity.Kind != IdentifierEmail || identity.UserID != user.ID || identity.Account != "bob" || identity.LoginAddress != "bob@solit.cn" {
if identity.Kind != IdentifierEmail || identity.UserID != user.ID || identity.Account != "bob" || identity.LoginAddress != "bob@example.com" {
t.Fatalf("unexpected resolved identity: %+v", identity)
}
@@ -141,7 +141,7 @@ func TestResolveIdentifierFallbackToConfiguredDomainUser(t *testing.T) {
if _, err := db.Instance.Insert(&disabledUser); err != nil {
t.Fatal(err)
}
if _, err := ResolveIdentifier("charlie@solit.cn"); err == nil {
if _, err := ResolveIdentifier("charlie@example.com"); err == nil {
t.Fatal("disabled domain user must not be resolved")
}
+12 -12
View File
@@ -15,13 +15,13 @@ func TestWildcardCertificateDomains(t *testing.T) {
}{
{
name: "configured domain",
config: &config.Config{Domain: "xuans.com", WebDomain: "web.xuans.com", Domains: []string{"xuans.com", "other.example"}},
want: []string{"xuans.com", "*.xuans.com"},
config: &config.Config{Domain: "example.com", WebDomain: "web.example.com", Domains: []string{"example.com", "other.example"}},
want: []string{"example.com", "*.example.com"},
},
{
name: "trimmed wildcard domain",
config: &config.Config{Domain: " *.xuans.com. "},
want: []string{"xuans.com", "*.xuans.com"},
config: &config.Config{Domain: " *.example.com. "},
want: []string{"example.com", "*.example.com"},
},
{
name: "case normalized domain",
@@ -57,9 +57,9 @@ func TestWildcardCertificateDomains(t *testing.T) {
func TestCertificateDomainsFollowChallengeMode(t *testing.T) {
cfg := &config.Config{
Domain: "xuans.com",
WebDomain: "web.xuans.com",
Domains: []string{"xuans.com"},
Domain: "example.com",
WebDomain: "web.example.com",
Domains: []string{"example.com"},
}
cfg.SSLType = config.SSLTypeAutoHTTP
@@ -67,13 +67,13 @@ func TestCertificateDomainsFollowChallengeMode(t *testing.T) {
if len(httpDomains) != 5 {
t.Fatalf("got %d HTTP domains, want 5: %v", len(httpDomains), httpDomains)
}
if httpDomains[0] != "web.xuans.com" || httpDomains[1] != "xuans.com" || httpDomains[2] != "smtp.xuans.com" {
if httpDomains[0] != "web.example.com" || httpDomains[1] != "example.com" || httpDomains[2] != "smtp.example.com" {
t.Fatalf("unexpected HTTP domains: %v", httpDomains)
}
cfg.SSLType = config.SSLTypeAutoDNS
dnsDomains := certificateDomains(cfg)
if len(dnsDomains) != 2 || dnsDomains[0] != "xuans.com" || dnsDomains[1] != "*.xuans.com" {
if len(dnsDomains) != 2 || dnsDomains[0] != "example.com" || dnsDomains[1] != "*.example.com" {
t.Fatalf("unexpected DNS domains: %v", dnsDomains)
}
}
@@ -145,7 +145,7 @@ func TestDNSWildcardIgnoresLegacyAdminRecoveryDomain(t *testing.T) {
func TestDNSChallengeWildcardProducesSingleRecord(t *testing.T) {
challenge := &DNSChallenge{authInfo: map[string]*authInfo{}}
if err := challenge.Present("*.xuans.com", "token", "key-auth"); err != nil {
if err := challenge.Present("*.example.com", "token", "key-auth"); err != nil {
t.Fatalf("Present returned an error: %v", err)
}
@@ -156,8 +156,8 @@ func TestDNSChallengeWildcardProducesSingleRecord(t *testing.T) {
if records[0].Type != "TXT" {
t.Fatalf("got record type %q, want TXT", records[0].Type)
}
if strings.TrimSuffix(records[0].Host, ".") != "_acme-challenge.xuans.com" {
t.Fatalf("got record host %q, want _acme-challenge.xuans.com", records[0].Host)
if strings.TrimSuffix(records[0].Host, ".") != "_acme-challenge.example.com" {
t.Fatalf("got record host %q, want _acme-challenge.example.com", records[0].Host)
}
if records[0].Value == "" {
t.Fatal("DNS record value must not be empty")