Make the pure loader regression test detect bootstrap
All checks were successful
ci/woodpecker/push/verify Pipeline was successful
All checks were successful
ci/woodpecker/push/verify Pipeline was successful
This commit is contained in:
@@ -5,17 +5,25 @@ Reviewed all ten implementation stages against committed baseline
|
||||
|
||||
## 1. Make the pure-loader regression test detect accidental bootstrap
|
||||
|
||||
Status: pending. Priority: P2. Implementation stages: 2 and 6.
|
||||
Status: completed. Priority: P2. Implementation stages: 2 and 6.
|
||||
|
||||
Completion: the test registers restoration of the original environment state,
|
||||
unsets the variable, and uses `LookupEnv` to verify that pure loading leaves it
|
||||
absent. Explicit bootstrap provides a positive control before the retained
|
||||
prepared-source handoff assertions. The focused test passes normally and fails
|
||||
at the purity assertion with bootstrap inserted through a temporary build
|
||||
overlay. Full tests and configuration-package race tests pass. Production
|
||||
loading behavior is unchanged.
|
||||
|
||||
Location: [pipeline_discovery_test.go](../../internal/config/pipeline_discovery_test.go#L99),
|
||||
`TestPipelineSourceRetainsPreparedMainAndPureLoading`.
|
||||
|
||||
The test sets its credential variable to an empty string before calling the
|
||||
ordinary library loader. ConfigKit's default bootstrap preserves existing
|
||||
The original test set its credential variable to an empty string before calling
|
||||
the ordinary library loader. ConfigKit's default bootstrap preserves existing
|
||||
variables, including empty ones. Consequently, the environment assertion still
|
||||
passes if bootstrap is accidentally introduced into `LoadPipelineWithOptions`.
|
||||
This is the only configuration-package test declaring a secrets directory, so
|
||||
the intended guard against library-owned environment mutation is ineffective.
|
||||
passed with bootstrap accidentally introduced into `LoadPipelineWithOptions`.
|
||||
This was the only configuration-package test declaring a secrets directory, so
|
||||
the intended guard against library-owned environment mutation was ineffective.
|
||||
|
||||
Confirmed with a temporary Go build overlay that inserted an actual
|
||||
`LoadSecretsIntoEnvironmentFromConfig` call into `LoadPipelineWithOptions`:
|
||||
|
||||
@@ -96,7 +96,11 @@ func TestPipelineSourceRetainsPreparedMainAndPureLoading(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const name = "NARRATIO_SOURCE_HANDOFF_TEST"
|
||||
// Register cleanup for the original value and presence before unsetting it.
|
||||
t.Setenv(name, "")
|
||||
if err := os.Unsetenv(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(secretDir, name), []byte("synthetic-secret"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -107,13 +111,16 @@ func TestPipelineSourceRetainsPreparedMainAndPureLoading(t *testing.T) {
|
||||
if _, err := LoadPipelineWithOptions(path, PipelineLoadOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := os.Getenv(name); got != "" {
|
||||
if _, present := os.LookupEnv(name); present {
|
||||
t.Fatal("pure loading changed environment")
|
||||
}
|
||||
_, prepared, err := configkit.LoadSecretsIntoEnvironmentFromConfig(PipelineSource(path, PipelineLoadOptions{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := os.Getenv(name); got != "synthetic-secret" {
|
||||
t.Fatal("explicit bootstrap did not populate the test credential")
|
||||
}
|
||||
if err := os.WriteFile(path, []byte("invalid: ["), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user