Scert/backend/internal/app/certificate_authorization_test.go
xuans 3cc8fb6470 完成部署后校验失败恢复整改并更新实机进度
延后事务提交,校验失败时恢复目标文件、配置和服务状态;新增恢复边界回归、前端提示及生产测试记录。
2026-09-30 23:14:42 +08:00

45 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package app
import (
"context"
"errors"
"testing"
"git.pcux.cn/xuans/Scert/backend/internal/certificate"
"git.pcux.cn/xuans/Scert/backend/internal/deployment"
)
type deniedWorkflowCertificateService struct {
workflowCertificateService
}
func (*deniedWorkflowCertificateService) Issue(context.Context, string) (certificate.IssueResult, error) {
return certificate.IssueResult{}, errors.New("DNS 凭据无权操作域名:Forbidden.NoPermission")
}
type forbiddenDeployer struct {
t *testing.T
}
func (d forbiddenDeployer) DeploySaved(context.Context, []deployment.Target, deployment.SavedFiles) (deployment.Report, error) {
d.t.Fatal("权限检查失败后不得发起 SSH/SFTP 部署")
return deployment.Report{}, nil
}
func (d forbiddenDeployer) DeploySavedVerified(context.Context, []deployment.Target, deployment.SavedFiles, deployment.Verification) (deployment.Report, error) {
d.t.Fatal("权限检查失败后不得发起事务部署")
return deployment.Report{}, nil
}
func TestWorkflowDoesNotDeployAfterDNSPermissionDenied(t *testing.T) {
workflow := &CertificateWorkflow{
Certificates: &deniedWorkflowCertificateService{},
Domains: &workflowDomainState{},
Servers: workflowServerLister{servers: []deployment.Server{{ID: "target"}}},
Deployment: forbiddenDeployer{t: t},
}
if _, err := workflow.IssueWithReport(t.Context(), "domain"); err == nil {
t.Fatal("权限失败不得报告工作流成功")
}
}