Test normalized configuration inspection and provenance
This commit is contained in:
@@ -153,6 +153,50 @@ func TestIdentifiedResourcesRejectDuplicateStrictPeers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidIdentitiesWithNormalizableFieldsAreRejected(t *testing.T) {
|
||||
for _, kind := range []string{"backends", "profiles", "prompts"} {
|
||||
for _, id := range []string{" ", "bad/id"} {
|
||||
t.Run(kind+"/"+id, func(t *testing.T) {
|
||||
record := map[string]any{"id": id}
|
||||
switch kind {
|
||||
case "backends":
|
||||
record["endpoint"] = " HTTPS://example.invalid/v1 "
|
||||
record["concurrency_limit"] = 1
|
||||
case "profiles":
|
||||
record["service_tier"] = " standard "
|
||||
case "prompts":
|
||||
record["description"] = " padded "
|
||||
}
|
||||
_, err := load(mapping("invalid", map[string]any{kind: []any{record}}), nil)
|
||||
if err == nil || strings.Contains(strings.ToLower(err.Error()), "unrecorded") {
|
||||
t.Fatalf("invalid identity error = %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuplicateIdentitiesWithNormalizableFieldsAreRejected(t *testing.T) {
|
||||
for _, kind := range []string{"backends", "profiles", "prompts"} {
|
||||
t.Run(kind, func(t *testing.T) {
|
||||
record := map[string]any{"id": "same"}
|
||||
switch kind {
|
||||
case "backends":
|
||||
record["endpoint"] = " HTTPS://example.invalid/v1 "
|
||||
record["concurrency_limit"] = 1
|
||||
case "profiles":
|
||||
record["service_tier"] = " standard "
|
||||
case "prompts":
|
||||
record["description"] = " padded "
|
||||
}
|
||||
_, err := load(mapping("duplicates", map[string]any{kind: []any{record, record}}), nil)
|
||||
if err == nil || strings.Contains(strings.ToLower(err.Error()), "unrecorded") {
|
||||
t.Fatalf("duplicate identity error = %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalIdentitiesAreCheckedAfterApplicationResolution(t *testing.T) {
|
||||
for _, kind := range []string{"backends", "profiles", "prompts"} {
|
||||
for _, namespace := range []string{"", "*"} {
|
||||
|
||||
Reference in New Issue
Block a user