feat: apply sealed installation plans without interactive setup
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package preflight
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/config"
|
||||
"github.com/aritmolab/thothii/tools/tht/internal/safeio"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -8,6 +11,32 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExecutionPlanAcceptsOnlyExactReleaseOwnedMaterialization(t *testing.T) {
|
||||
root, _ := filepath.EvalSymlinks(t.TempDir())
|
||||
_ = os.Chmod(root, 0o700)
|
||||
_ = os.Mkdir(filepath.Join(root, "deploy"), 0o700)
|
||||
input := filepath.Join(root, "input")
|
||||
_ = os.WriteFile(input, []byte("prepared"), 0o600)
|
||||
overlay := filepath.Join(root, "deploy", "compose.git-https.yaml")
|
||||
data := []byte("services: {}\n")
|
||||
plan := Plan{SchemaVersion: 1, ValidatorProtocol: Protocol, Installation: config.Installation{ProjectDirectory: root}, Inputs: []string{input}, AbsentInputs: []string{overlay}, Report: NewReport(), Release: Manifest{Files: map[string]string{"deploy/compose.git-https.yaml": fmt.Sprintf("%x", sha256.Sum256(data))}}}
|
||||
path := filepath.Join(root, "plan.json")
|
||||
if err := WritePlan(path, &plan); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = os.WriteFile(overlay, data, 0o600)
|
||||
if _, err := ReadExecutionPlan(path); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if VerifyPlanInputs(path) == nil {
|
||||
t.Fatal("ordinary validation must still detect new files")
|
||||
}
|
||||
_ = os.WriteFile(overlay, []byte("changed"), 0o600)
|
||||
if _, err := ReadExecutionPlan(path); err == nil {
|
||||
t.Fatal("modified materialization accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlanBindsInputsAndDetectsCredentialRotationWithoutPublicSecretHashes(t *testing.T) {
|
||||
root, _ := filepath.EvalSymlinks(t.TempDir())
|
||||
if err := safeio.ProtectPrivateDirectory(root); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user