Index debug sensitivity paths once per capture
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -15,6 +16,53 @@ import (
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestRunCaptureRoutesRootAndCollectionSensitivityMasks(t *testing.T) {
|
||||
result, err := configkit.LoadLayered(configkit.Input{Source: configkit.Bytes("mixed resources", []byte(`version: 6
|
||||
promptkit:
|
||||
profiles:
|
||||
- id: chosen
|
||||
extra_params:
|
||||
token: root-profile
|
||||
nested/key:
|
||||
a~b: [{authorization: root-nested, caption: ordinary-caption}]
|
||||
backends:
|
||||
- id: chosen
|
||||
endpoint: https://example.invalid/v1
|
||||
extra_params: {password: root-backend}
|
||||
collections:
|
||||
fixture:
|
||||
profiles:
|
||||
- id: chosen
|
||||
extra_params: {token: collection-profile}
|
||||
backends:
|
||||
- id: chosen
|
||||
endpoint: https://example.invalid/v1
|
||||
extra_params: {password: collection-backend}
|
||||
`))}, configkit.LayeredOptions[config.Document]{Definition: config.Definition(t.TempDir())})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
writer := newRunEvidenceRecorder(nil, result).(*runEvidenceRecorder)
|
||||
nested := map[string]any{"a~b": []any{map[string]any{"authorization": "root-nested", "caption": "ordinary-caption"}}}
|
||||
for _, namespace := range []string{"", "fixture/"} {
|
||||
target := promptkit.ExecutionTarget{ExtraParams: map[string]any{"token": "original-token", "password": "original-password", "nested/key": nested, "caption": "ordinary-caption"}}
|
||||
masked := writer.target(target, namespace+"chosen", namespace+"chosen")
|
||||
if masked.ExtraParams["token"] != "[REDACTED]" || masked.ExtraParams["password"] != "[REDACTED]" || masked.ExtraParams["caption"] != "ordinary-caption" {
|
||||
t.Fatalf("misrouted resource masks for %q: %#v", namespace, masked)
|
||||
}
|
||||
wantNested := nested
|
||||
if namespace == "" {
|
||||
wantNested = map[string]any{"a~b": []any{map[string]any{"authorization": "[REDACTED]", "caption": "ordinary-caption"}}}
|
||||
}
|
||||
if !reflect.DeepEqual(masked.ExtraParams["nested/key"], wantNested) {
|
||||
t.Fatalf("nested mask crossed resource boundary for %q: %#v", namespace, masked)
|
||||
}
|
||||
if target.ExtraParams["token"] != "original-token" || nested["a~b"].([]any)[0].(map[string]any)["authorization"] != "root-nested" {
|
||||
t.Fatal("native snapshot was mutated")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunCaptureUsesFrozenSecretAwareConfiguration(t *testing.T) {
|
||||
result, err := configkit.LoadLayered(configkit.Input{Source: configkit.Bytes("captured application", []byte(`version: 6
|
||||
promptkit:
|
||||
|
||||
Reference in New Issue
Block a user