完成证书历史版本恢复核心实现

补充历史证书版本读取、稳定标识、完整证书链恢复、恢复回滚保护及接口安全输出,并同步更新整改任务进度。
This commit is contained in:
xuans committed 2026-10-03 01:14:12 +08:00
1 parent 3c59ac5e80
commit 3f6a05d2b9
11 files changed
+864 -102

No files matched your search

@@ -65,7 +65,7 @@ func TestFileStoreUsesSingleDatedCurrentVersion(t *testing.T) {
if err != nil {
t.Fatalf("读取当前证书版本失败:%v", err)
}
if len(versions) != 1 || versions[0].Version != second.Version {
if len(versions) != 2 || versions[0].Version != second.Version || !versions[0].Current || versions[1].Version != first.Version || versions[1].Current {
t.Fatalf("当前证书版本列表错误:%+v", versions)
}
metadata, loaded, err := store.LoadCurrent(context.Background(), "example.com", "single")
@@ -147,10 +147,10 @@ func TestRollbackSavedResourceClearsNewCertificateFiles(t *testing.T) {
}
}
func TestFileStoreDoesNotRestoreHistoricalVersion(t *testing.T) {
func TestFileStoreRejectsMissingHistoricalVersion(t *testing.T) {
store := FileStore{Root: t.TempDir()}
if _, err := store.RestoreVersion(context.Background(), "example.com", "single", "20260830-V1.0"); err == nil {
t.Fatal("仅保留当前版本时不应支持历史版本恢复")
t.Fatal("不存在的历史证书版本不应恢复成功")
}
}
@@ -187,7 +187,7 @@ func TestFileStoreUsesStableSANIdentifierAndRemovesPreviousIdentifier(t *testing
if second.CertificateIdentifier == first.CertificateIdentifier {
t.Fatal("different SAN sets should use different identifiers")
}
if second.Version != "20260830-V1.0" {
if second.Version != "20260830-V1.1" {
t.Fatalf("unexpected second SAN version: %s", second.Version)
}
if _, err := os.Stat(first.Directory); !errors.Is(err, os.ErrNotExist) {