Simplify smoke report ownership
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"go.maximumdirect.net/promptkit/internal/domain"
|
||||
"go.maximumdirect.net/promptkit/internal/generation"
|
||||
"go.maximumdirect.net/promptkit/internal/jsonvalue"
|
||||
"go.maximumdirect.net/promptkit/internal/llm"
|
||||
"go.maximumdirect.net/promptkit/internal/observation"
|
||||
)
|
||||
@@ -439,12 +438,8 @@ func httpExecutionFacts(evidence llm.HTTPExecutionEvidence) domain.SmokeTestFact
|
||||
}
|
||||
|
||||
func smokeReportTarget(target domain.SmokeTestTarget) (domain.SmokeTestTarget, error) {
|
||||
params, err := jsonvalue.CopyMap(target.EffectiveSettings.ExtraParams)
|
||||
if err != nil {
|
||||
return domain.SmokeTestTarget{}, fmt.Errorf("clone smoke-test target settings: %w", err)
|
||||
}
|
||||
target.EffectiveSettings.ExtraParams = params
|
||||
target.EffectiveSettings.APIKey = ""
|
||||
var err error
|
||||
target.Endpoint, err = endpointWithoutUserInfo(target.Endpoint)
|
||||
if err != nil {
|
||||
return domain.SmokeTestTarget{}, fmt.Errorf("%w: invalid resolved diagnostic endpoint", ErrInvalidRequest)
|
||||
|
||||
@@ -394,7 +394,7 @@ func (b cancelOnCloseSmokeBody) Close() error {
|
||||
return b.ReadCloser.Close()
|
||||
}
|
||||
|
||||
func TestSmokeReportTargetOwnsProviderValuesAndRedactsCredentials(t *testing.T) {
|
||||
func TestSmokeReportTargetRedactsCredentialsAndSanitizesEndpoints(t *testing.T) {
|
||||
target := domain.SmokeTestTarget{
|
||||
Endpoint: "https://user:password@example.invalid/key",
|
||||
EffectiveSettings: domain.ExecutionTarget{
|
||||
@@ -407,13 +407,8 @@ func TestSmokeReportTargetOwnsProviderValuesAndRedactsCredentials(t *testing.T)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] = "changed"
|
||||
if target.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] != "original" ||
|
||||
if got.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] != "original" ||
|
||||
got.EffectiveSettings.APIKey != "" || got.Endpoint != "https://example.invalid/key" || got.EffectiveSettings.Endpoint != "https://example.invalid/v1" {
|
||||
t.Fatalf("report target not detached or redacted: %+v", got)
|
||||
}
|
||||
target.EffectiveSettings.ExtraParams = map[string]any{"invalid": func() {}}
|
||||
if _, err := smokeReportTarget(target); err == nil {
|
||||
t.Fatal("invalid provider values were accepted")
|
||||
t.Fatalf("report target not redacted: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user