fix(backup): privately stage restore archive
This commit is contained in:
@@ -455,6 +455,37 @@ func TestPreflightStagesArchiveIntoImmutablePrivateBytes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStageArchiveCleansPrivateFileAfterStreamingFailure(t *testing.T) {
|
||||
installation := preflightTestInstallation(t)
|
||||
if err := os.MkdirAll(installation.ControlDirectory(), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archive := filepath.Join(t.TempDir(), "checked.zip")
|
||||
writePreflightArchive(t, archive, preflightArchiveSpec{
|
||||
entries: []preflightArchiveEntry{{path: "configuration/operator.env", body: []byte("before")}},
|
||||
})
|
||||
|
||||
result, err := Preflight(context.Background(), installation, PreflightRequest{Archive: archive, Confirm: true}, permissivePreflightDependencies())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer result.CloseArchive()
|
||||
result.freeBytes = func(string) (uint64, error) {
|
||||
result.archive.digest = "after-preflight-mismatch"
|
||||
return 1024, nil
|
||||
}
|
||||
if _, err := result.StageArchive(context.Background()); err == nil || !strings.Contains(err.Error(), "changed") {
|
||||
t.Fatalf("StageArchive() error = %v, want streaming size refusal", err)
|
||||
}
|
||||
entries, err := os.ReadDir(result.stagingRoot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(entries) != 0 {
|
||||
t.Fatalf("private staging leftovers = %v, want none", entries)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreflightStagingRejectsInPlaceArchiveHashMutation(t *testing.T) {
|
||||
installation := preflightTestInstallation(t)
|
||||
archive := filepath.Join(t.TempDir(), "checked.zip")
|
||||
|
||||
Reference in New Issue
Block a user