Compare commits

..

No commits in common. "857fb0e632f682fd6bffe4c63c37c394f71be7be" and "79e0e42bf9f3280d56ae486db1004711747fa6c6" have entirely different histories.

3 changed files with 8 additions and 22 deletions

View File

@ -49,17 +49,16 @@ func TestRecoveryPreflightOverPasswordSFTP(t *testing.T) {
delete(r.Evidence.TemporaryFiles, r.TemporaryPaths[2])
}
for path, file := range memory.files {
localPath := localSFTPPath(root, path)
if strings.HasSuffix(path, ".scert-lock") {
if err := os.MkdirAll(localPath, 0o700); err != nil {
if err := os.MkdirAll(path, 0o700); err != nil {
t.Fatal(err)
}
continue
}
if err := os.MkdirAll(filepath.Dir(localPath), 0o700); err != nil {
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(localPath, file.data, 0o600); err != nil {
if err := os.WriteFile(path, file.data, 0o600); err != nil {
t.Fatal(err)
}
}
@ -79,7 +78,7 @@ func TestRecoveryPreflightOverPasswordSFTP(t *testing.T) {
t.Fatal("真实 SFTP 恢复未完成")
}
for _, target := range r.Paths {
data, err := os.ReadFile(localSFTPPath(root, target))
data, err := os.ReadFile(target)
if err != nil || string(data) != "old" {
t.Fatalf("真实文件恢复错误:%s %v", target, err)
}
@ -102,16 +101,6 @@ func TestRecoveryPreflightOverPasswordSFTP(t *testing.T) {
}
}
func localSFTPPath(root, remotePath string) string {
if volume := filepath.ToSlash(filepath.VolumeName(root)); volume != "" {
remoteVolume := "/" + volume
if strings.HasPrefix(remotePath, remoteVolume) {
return filepath.FromSlash(strings.TrimPrefix(remotePath, "/"))
}
}
return filepath.FromSlash(remotePath)
}
func snapshotRecoveryDirectory(t *testing.T, root string) map[string]string {
t.Helper()
result := map[string]string{}

View File

@ -4,7 +4,6 @@ import (
"context"
"errors"
"maps"
"path"
"path/filepath"
"reflect"
"testing"
@ -13,10 +12,9 @@ import (
func recoveryPreflightFixture(roots ...string) (Server, *memoryClient, TransactionRecord) {
server := testServer("preflight").Normalize()
if len(roots) == 1 {
remoteRoot := "/" + filepath.ToSlash(roots[0])
server.CertificatePath = path.Join(remoteRoot, "cert.pem")
server.CertificateChainPath = path.Join(remoteRoot, "fullchain.pem")
server.PrivateKeyPath = path.Join(remoteRoot, "key.pem")
server.CertificatePath = filepath.ToSlash(filepath.Join(roots[0], "cert.pem"))
server.CertificateChainPath = filepath.ToSlash(filepath.Join(roots[0], "fullchain.pem"))
server.PrivateKeyPath = filepath.ToSlash(filepath.Join(roots[0], "key.pem"))
}
client := newMemoryClient()
r := TransactionRecord{

View File

@ -10,7 +10,6 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"strings"
"sync/atomic"
"testing"
@ -61,7 +60,7 @@ func TestAsyncImportUploadLifecycle(t *testing.T) {
t.Errorf("上传文件被提前回收或内容变化:%v", err)
}
info, err := os.Stat(path)
if err != nil || (runtime.GOOS != "windows" && info.Mode().Perm() != 0600) {
if err != nil || info.Mode().Perm() != 0600 {
t.Errorf("上传文件权限错误:%v", err)
}
}