diff --git a/internal/infrastructure/workflowsteps/workflowsteps_test.go b/internal/infrastructure/workflowsteps/workflowsteps_test.go index f80da9889..a9fc1fe7e 100644 --- a/internal/infrastructure/workflowsteps/workflowsteps_test.go +++ b/internal/infrastructure/workflowsteps/workflowsteps_test.go @@ -2,6 +2,7 @@ package workflowsteps import ( "slices" + "strings" "testing" "github.com/samcharles93/archie-core/internal/domain/workflow" @@ -36,6 +37,47 @@ func TestShippedVocabularyCoversEveryShippedStage(t *testing.T) { } } +// TestShippedStagesKeepTheirBehaviourThroughTheManager pins that the provider +// hands the builtin factories through unchanged. The shipped stages are typed, +// non-interpreted steps: each compiles to the stage the builtin registry +// carries and refuses settings. The one way this enumeration could keep every +// name and lose that guard is to rebuild the factories instead of forwarding +// them, and definition_test.go's assertion cannot see it -- that test drives +// BuiltinStepRegistry, which production no longer calls. +func TestShippedStagesKeepTheirBehaviourThroughTheManager(t *testing.T) { + t.Parallel() + + manager, err := NewManager() + if err != nil { + t.Fatalf("NewManager: %v", err) + } + registry := manager.Registry() + + for _, entry := range workflow.ShippedDefinitions().Definitions { + definition, err := workflow.ParseDefinition(entry.YAML, registry) + if err != nil { + t.Fatalf("parse shipped workflow %q through the registered vocabulary: %v", entry.ID, err) + } + compiled, err := workflow.ParseAndCompile(entry.YAML, registry) + if err != nil { + t.Fatalf("compile shipped workflow %q through the registered vocabulary: %v", entry.ID, err) + } + if len(compiled.Stages) != len(definition.Steps) { + t.Fatalf("%s compiled %d stages, want %d", entry.ID, len(compiled.Stages), len(definition.Steps)) + } + for i, step := range definition.Steps { + want := strings.TrimPrefix(step.Type, entry.ID+".") + if compiled.Stages[i].Name != want { + t.Errorf("%s step %d (%s) compiled to stage %q, want the shipped stage %q: the registered factory is not the builtin one", entry.ID, i, step.Type, compiled.Stages[i].Name, want) + } + } + } + + if _, err := workflow.ParseAndCompile("id: probe\nsteps:\n - type: bootstrap.apply\n settings:\n command: rm -rf /\n", registry); err == nil || !strings.Contains(err.Error(), "accepts no settings") { + t.Fatalf("ParseAndCompile() error = %v, want the shipped stage's settings refusal", err) + } +} + // TestNewManagerIsRepeatableWithinOneProcess is the regression guard for // registering the provider set into shared state: every construction is // independent, so building the vocabulary twice in one process — as `-count=2`