1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00
kyverno/pkg/engine/utils/utils_test.go
Tobias Dahlberg 19f0e7ebfe
fix: add parsing of json pointers to support special chars (#3578 #3616) (#4767)
* Added jsonpointer package that supports parsing of paths and JSON pointers that can yield either a JSON pointer string or JMESPath string.
* Replaced the use of `strings.Split` and `strings.Join` in places where paths are converted to JMESPaths.

Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com>

Signed-off-by: Tobias Dahlberg <tobias.dahlberg@sinch.com>
Co-authored-by: shuting <shuting@nirmata.com>
Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com>
Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
2022-11-10 16:03:45 +00:00

29 lines
547 B
Go

package utils
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAnchorsFromMap_ThereAreNoAnchors(t *testing.T) {
rawMap := []byte(`{
"name":"nirmata-*",
"notAnchor1":123,
"namespace":"kube-?olicy",
"notAnchor2":"sample-text",
"object":{
"key1":"value1",
"(key2)":"value2"
}
}`)
var unmarshalled map[string]interface{}
err := json.Unmarshal(rawMap, &unmarshalled)
if err != nil {
t.Error(err)
}
actualMap := GetAnchorsFromMap(unmarshalled)
assert.Equal(t, len(actualMap), 0)
}