Clarify when preparation sources cannot be verified
This commit is contained in:
@@ -60,7 +60,7 @@ audio discovery changes, and other audit findings remain separate work.
|
|||||||
|
|
||||||
## Stage 1: Distinguish unverifiable preparation sources from changed sources
|
## Stage 1: Distinguish unverifiable preparation sources from changed sources
|
||||||
|
|
||||||
Status: Pending
|
Status: Complete
|
||||||
|
|
||||||
Read `internal/stage/prepare_resume.go` and its focused tests, especially
|
Read `internal/stage/prepare_resume.go` and its focused tests, especially
|
||||||
`TestPrepareResumeValidatesCurrentS3ObjectIdentity`. Review the existing
|
`TestPrepareResumeValidatesCurrentS3ObjectIdentity`. Review the existing
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func (prepareStage) ValidateResume(ctx context.Context, env *Env, m *manifest.Ma
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return ResumeValidation{}, ctxErr
|
return ResumeValidation{}, ctxErr
|
||||||
}
|
}
|
||||||
return NonResumable(prepareResumeChangedReason), nil
|
return NonResumable(fmt.Sprintf("prepared sources could not be verified; rerun prepare: %v", err)), nil
|
||||||
}
|
}
|
||||||
paths := sessionPathsForEnv(env, m.SessionID)
|
paths := sessionPathsForEnv(env, m.SessionID)
|
||||||
for _, source := range []string{artifactpolicy.SourceInputGlossaryParty, artifactpolicy.SourceInputGlossaryCampaign, artifactpolicy.SourceInputGlossarySetting, artifactpolicy.SourceInputGlossarySpells, artifactpolicy.SourceInputGlossaryCombined} {
|
for _, source := range []string{artifactpolicy.SourceInputGlossaryParty, artifactpolicy.SourceInputGlossaryCampaign, artifactpolicy.SourceInputGlossarySetting, artifactpolicy.SourceInputGlossarySpells, artifactpolicy.SourceInputGlossaryCombined} {
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package stage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||||
@@ -331,8 +333,24 @@ func TestPrepareResumeValidatesCurrentS3ObjectIdentity(t *testing.T) {
|
|||||||
t.Fatalf("prepare.Run() error = %v", err)
|
t.Fatalf("prepare.Run() error = %v", err)
|
||||||
}
|
}
|
||||||
assertPrepareResume(t, env, m, true)
|
assertPrepareResume(t, env, m, true)
|
||||||
|
fake.ListErr = errors.New("listing unavailable")
|
||||||
|
validation, err := (prepareStage{}).ValidateResume(context.Background(), env, m)
|
||||||
|
if err != nil || validation.Resumable || !strings.Contains(validation.Reason, "could not be verified") || !strings.Contains(validation.Reason, "listing unavailable") {
|
||||||
|
t.Fatalf("unavailable listing: validation = %#v, error = %v", validation, err)
|
||||||
|
}
|
||||||
|
fake.ListErr = nil
|
||||||
|
object := fake.Objects[key]
|
||||||
|
object.ETag = ""
|
||||||
|
fake.Objects[key] = object
|
||||||
|
validation, err = (prepareStage{}).ValidateResume(context.Background(), env, m)
|
||||||
|
if err != nil || validation.Resumable || !strings.Contains(validation.Reason, "could not be verified") || !strings.Contains(validation.Reason, "entity tag") {
|
||||||
|
t.Fatalf("missing identity: validation = %#v, error = %v", validation, err)
|
||||||
|
}
|
||||||
fake.SeedObject(storage.FakeObject{Key: key, Data: []byte("changed")})
|
fake.SeedObject(storage.FakeObject{Key: key, Data: []byte("changed")})
|
||||||
assertPrepareResume(t, env, m, false)
|
validation, err = (prepareStage{}).ValidateResume(context.Background(), env, m)
|
||||||
|
if err != nil || validation.Resumable || !strings.Contains(validation.Reason, "changed") {
|
||||||
|
t.Fatalf("changed identity: validation = %#v, error = %v", validation, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareResumeLocalFixture(t *testing.T) (*Env, *manifest.Manifest, string) {
|
func prepareResumeLocalFixture(t *testing.T) (*Env, *manifest.Manifest, string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user