Add evidence context policy preparation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
@@ -56,3 +57,33 @@ func TestOutputEncoderRegistryBehavior(t *testing.T) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestOutputProfileValidationReceivesOwnedOptionsAndLaneIDs(t *testing.T) {
|
||||
registry := NewOutputEncoderRegistry()
|
||||
if err := registry.RegisterBuilderWithProfileValidation(defaultModuleSpec("profile-output", StageOutput), func(options map[string]any) error {
|
||||
options["nested"].(map[string]any)["value"] = "changed"
|
||||
return nil
|
||||
}, func(context OutputProfileOptionContext, options map[string]any) error {
|
||||
context.LaneIDs[0] = "changed"
|
||||
options["nested"].(map[string]any)["value"] = "changed-again"
|
||||
return nil
|
||||
}, func(BuildRequest) (contracts.OutputEncoder, error) {
|
||||
return registryOutputEncoder{key: "profile-output"}, nil
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
options := map[string]any{"nested": map[string]any{"value": "original"}}
|
||||
if err := registry.ValidateOptions("profile-output", options); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
context := OutputProfileOptionContext{LaneIDs: []string{"artifact"}}
|
||||
if err := registry.ValidateProfileOptions("profile-output", context, options); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := options["nested"].(map[string]any)["value"]; got != "original" {
|
||||
t.Fatalf("options mutated by validator: %q", got)
|
||||
}
|
||||
if want := []string{"artifact"}; !reflect.DeepEqual(context.LaneIDs, want) {
|
||||
t.Fatalf("lane ids mutated by validator: %#v, want %#v", context.LaneIDs, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user