Use stable verified Notarius reference snapshots
This commit is contained in:
@@ -2,6 +2,7 @@ package artifacts
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -54,7 +55,6 @@ func TestSessionNotariusPathsForCampaign(t *testing.T) {
|
||||
{name: "extract directory", got: SessionRunExtractDirForCampaign(root, campaign, sessionID, runID), want: extractDir},
|
||||
{name: "receipt", got: SessionRunNotariusReceiptPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius.receipt.json")},
|
||||
{name: "stderr", got: SessionRunNotariusLogPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius.stderr.log")},
|
||||
{name: "references", got: SessionRunNotariusReferencesDirForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "references")},
|
||||
{name: "output root", got: SessionRunNotariusOutputRootForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius-output")},
|
||||
{name: "durable bundle", got: SessionNotariusBundleDirForCampaign(root, campaign, sessionID, runID), want: filepath.Join(root, "work", campaign, sessionID, "artifacts", "notarius", runID)},
|
||||
}
|
||||
@@ -67,6 +67,43 @@ func TestSessionNotariusPathsForCampaign(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionNotariusReferenceSnapshotPath(t *testing.T) {
|
||||
paths := buildSessionPaths("/tmp/workspace", "forsaken", "2026-04-19")
|
||||
checksum := strings.Repeat("a", 64)
|
||||
got, err := SessionNotariusReferenceSnapshotPath(paths, checksum, "party.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("SessionNotariusReferenceSnapshotPath() error = %v", err)
|
||||
}
|
||||
wantRoot := filepath.Join(paths.Root, "cache", "notarius", "references")
|
||||
if root := SessionNotariusReferenceCacheDir(paths); root != wantRoot {
|
||||
t.Fatalf("SessionNotariusReferenceCacheDir() = %q, want %q", root, wantRoot)
|
||||
}
|
||||
if want := filepath.Join(wantRoot, checksum, "party.yml"); got != want {
|
||||
t.Fatalf("SessionNotariusReferenceSnapshotPath() = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionNotariusReferenceSnapshotPathRejectsUnsafeIdentity(t *testing.T) {
|
||||
paths := buildSessionPaths("/tmp/workspace", "forsaken", "2026-04-19")
|
||||
validChecksum := strings.Repeat("a", 64)
|
||||
for _, test := range []struct {
|
||||
name, checksum, basename string
|
||||
}{
|
||||
{name: "short digest", checksum: "abc", basename: "party.yml"},
|
||||
{name: "uppercase digest", checksum: strings.Repeat("A", 64), basename: "party.yml"},
|
||||
{name: "nonhex digest", checksum: strings.Repeat("g", 64), basename: "party.yml"},
|
||||
{name: "empty basename", checksum: validChecksum},
|
||||
{name: "nested basename", checksum: validChecksum, basename: "nested/party.yml"},
|
||||
{name: "parent basename", checksum: validChecksum, basename: ".."},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got, err := SessionNotariusReferenceSnapshotPath(paths, test.checksum, test.basename); err == nil {
|
||||
t.Fatalf("SessionNotariusReferenceSnapshotPath() = %q, want error", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionPreviousPathsForCampaign(t *testing.T) {
|
||||
root := "/tmp/workspace"
|
||||
previousDir := SessionPreviousDirForCampaign(root, "forsaken", "2026-04-19")
|
||||
|
||||
Reference in New Issue
Block a user