diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning/algorithm_test.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning/algorithm_test.go index 58aba203490..4ddf9301144 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning/algorithm_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning/algorithm_test.go @@ -85,7 +85,13 @@ func TestPrune(t *testing.T) { "pruning": {"unspecified": "bar"}, "preserving": {"unspecified": "bar"} }, - "preservingAdditionalProperties": { + "preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": { + "foo": { + "specified": {"unspecified":"bar"}, + "unspecified": "bar" + } + }, + "preservingAdditionalPropertiesKeyPruneValues": { "foo": { "specified": {"unspecified":"bar"}, "unspecified": "bar" @@ -123,7 +129,8 @@ func TestPrune(t *testing.T) { }, }, }, - "preservingAdditionalProperties": { + "preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": { + // this x-kubernetes-preserve-unknown-fields is not inherited by the schema inside of additionalProperties Extensions: structuralschema.Extensions{XPreserveUnknownFields: true}, Generic: structuralschema.Generic{ Type: "object", @@ -137,6 +144,19 @@ func TestPrune(t *testing.T) { }, }, }, + "preservingAdditionalPropertiesKeyPruneValues": { + Generic: structuralschema.Generic{ + Type: "object", + AdditionalProperties: &structuralschema.StructuralOrBool{ + Structural: &structuralschema.Structural{ + Generic: structuralschema.Generic{Type: "object"}, + Properties: map[string]structuralschema.Structural{ + "specified": {Generic: structuralschema.Generic{Type: "object"}}, + }, + }, + }, + }, + }, }, }, expected: ` { @@ -154,7 +174,12 @@ func TestPrune(t *testing.T) { "pruning": {}, "preserving": {"unspecified": "bar"} }, - "preservingAdditionalProperties": { + "preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": { + "foo": { + "specified": {} + } + }, + "preservingAdditionalPropertiesKeyPruneValues": { "foo": { "specified": {} }