权限整改:完成 DNS 账户项目归属与凭据使用隔离
为 DNS 配置和账户补充项目归属,接入 DNS 凭据使用与项目管理权限校验,并补充配置和接口回归测试。
This commit is contained in:
1 parent
92c2d19ce3
commit
b8fd536dbd
8 files changed
+131
-2
No files matched your search
@@ -90,6 +90,7 @@ type ACMEConfig struct {
|
||||
}
|
||||
|
||||
type DNSConfig struct {
|
||||
ProjectID string `json:"project_id,omitempty"`
|
||||
OwnerUserID string `json:"owner_user_id,omitempty"`
|
||||
Provider string `json:"provider"`
|
||||
CredentialRef string `json:"credential_ref"`
|
||||
@@ -149,7 +150,7 @@ func Default(baseDir string) Config {
|
||||
PropagationTimeoutSecs: 300,
|
||||
PropagationPollingIntervalSecs: 5,
|
||||
},
|
||||
DNS: DNSConfig{VerificationState: "not_configured"},
|
||||
DNS: DNSConfig{ProjectID: "default", VerificationState: "not_configured"},
|
||||
Notification: NotificationConfig{
|
||||
HTTPHeaders: map[string]string{},
|
||||
HTTPPath: "/api/email/send",
|
||||
@@ -343,6 +344,9 @@ func (c *Config) Normalize() {
|
||||
if c.DNS.VerificationState == "" {
|
||||
c.DNS.VerificationState = "not_configured"
|
||||
}
|
||||
if strings.TrimSpace(c.DNS.ProjectID) == "" {
|
||||
c.DNS.ProjectID = "default"
|
||||
}
|
||||
if c.ACME.PropagationTimeoutSecs == 0 {
|
||||
c.ACME.PropagationTimeoutSecs = 300
|
||||
}
|
||||
|
||||
@@ -223,6 +223,15 @@ func TestNormalizeRestoresMissingRenewalPolicy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeRestoresDNSProjectScope(t *testing.T) {
|
||||
cfg := Default(t.TempDir())
|
||||
cfg.DNS.ProjectID = ""
|
||||
cfg.Normalize()
|
||||
if cfg.DNS.ProjectID != "default" {
|
||||
t.Fatalf("旧配置的 DNS 项目归属未补齐:%q", cfg.DNS.ProjectID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateRejectsInvalidRenewalPolicy(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user