1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00

Merge pull request #1946 from RinkiyaKeDad/1944_more_than_fix

fix operator matching with spacing
This commit is contained in:
Jim Bugwadia 2021-06-02 23:06:03 -07:00 committed by GitHub
commit 5dfd16ce44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -183,6 +183,7 @@ func validateValueWithStringPattern(log logr.Logger, value interface{}, pattern
operator := operator.GetOperatorFromStringPattern(pattern)
pattern = pattern[len(operator):]
pattern = strings.TrimSpace(pattern)
number, str := getNumberAndStringPartsFromPattern(pattern)
if "" == number {

View file

@ -306,6 +306,10 @@ func TestGetNumberAndStringPartsFromPattern_Empty(t *testing.T) {
assert.Equal(t, str, "")
}
func TestValidateValueWithStringPattern_WithSpace(t *testing.T) {
assert.Assert(t, validateValueWithStringPattern(log.Log, 4, ">= 3"))
}
func TestValidateNumberWithStr_LessFloatAndInt(t *testing.T) {
assert.Assert(t, validateNumberWithStr(log.Log, 7.00001, "7.000001", operator.More))
assert.Assert(t, validateNumberWithStr(log.Log, 7.00001, "7", operator.NotEqual))