diff --git a/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go b/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go index cf8eadcaaca..c1129efa896 100644 --- a/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go +++ b/staging/src/k8s.io/apiserver/pkg/cel/common/equality_test.go @@ -238,6 +238,64 @@ func TestCorrelation(t *testing.T) { NewValue: "b", OldValue: "oldB", }, + { + Name: "Replaced Key In Old Object", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: map[string]interface{}{ + "b": "a", + }, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: map[string]interface{}{"b": "a"}, + }, + { + Name: "Added Key In Old Object", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: map[string]interface{}{}, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: map[string]interface{}{}, + }, + { + Name: "Changed list to map", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: []interface{}{"a", "b"}, + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: []interface{}{"a", "b"}, + }, + { + Name: "Changed string to map", + RootObject: map[string]interface{}{ + "a": "b", + }, + RootOldObject: "a string", + Schema: mustSchema(` + properties: + a: { type: string } + `), + KeyPath: []interface{}{}, + NewValue: map[string]interface{}{"a": "b"}, + OldValue: "a string", + }, { Name: "Map list type", RootObject: mustUnstructured(`