Validate published output declarations
This commit is contained in:
@@ -77,6 +77,24 @@ func TestParseImmutableRunObjectKeyRejectsUnsafeOrMutableKeys(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePublishedOutputObjectKeyRequiresPublishedNamespace(t *testing.T) {
|
||||
prefix := testCurrentSessionPrefix()
|
||||
runID := "20260519T010203Z-a1b2c3d4"
|
||||
key := S3RunRelativeDestinationKey(S3RunPrefix(prefix, runID), "published/artifacts/recap.md")
|
||||
identity, err := ParsePublishedOutputObjectKey(prefix, key)
|
||||
if err != nil {
|
||||
t.Fatalf("ParsePublishedOutputObjectKey() error = %v", err)
|
||||
}
|
||||
if identity.RunID != runID || identity.Destination != "artifacts/recap.md" {
|
||||
t.Fatalf("ParsePublishedOutputObjectKey() = %#v", identity)
|
||||
}
|
||||
|
||||
outside := S3RunRelativeDestinationKey(S3RunPrefix(prefix, runID), "artifacts/recap.md")
|
||||
if _, err := ParsePublishedOutputObjectKey(prefix, outside); err == nil {
|
||||
t.Fatal("ParsePublishedOutputObjectKey() outside published namespace error = nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteCommitAllowsPublishedOutputFromEarlierSameSessionRunOnly(t *testing.T) {
|
||||
commit := testRemoteCommit(t, "20260519T010203Z-a1b2c3d4")
|
||||
prefix := testCurrentSessionPrefix()
|
||||
@@ -99,6 +117,18 @@ func TestRemoteCommitAllowsPublishedOutputFromEarlierSameSessionRunOnly(t *testi
|
||||
if err := commit.ValidateForSessionPrefix(prefix); err == nil {
|
||||
t.Fatal("ValidateForSessionPrefix() earlier non-published object error = nil")
|
||||
}
|
||||
|
||||
commit.Artifacts[1] = published
|
||||
commit.Artifacts[1].DestinationKey = S3RunRelativeDestinationKey(S3RunPrefix(prefix, commit.RunID), "artifacts/recap.md")
|
||||
if err := commit.ValidateForSessionPrefix(prefix); err == nil {
|
||||
t.Fatal("ValidateForSessionPrefix() published output outside published namespace error = nil")
|
||||
}
|
||||
|
||||
commit.Artifacts[1] = published
|
||||
commit.Artifacts[1].Source = "run:artifacts/recap.md"
|
||||
if err := commit.ValidateForSessionPrefix(prefix); err == nil {
|
||||
t.Fatal("ValidateForSessionPrefix() invalid published source error = nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteCommitRejectsEffectivePublishedDestinationCollisionAcrossRuns(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user