diff --git a/pkg/chartutil/jsonschema_test.go b/pkg/chartutil/jsonschema_test.go index af0fdab48..3fd0884cd 100644 --- a/pkg/chartutil/jsonschema_test.go +++ b/pkg/chartutil/jsonschema_test.go @@ -166,3 +166,21 @@ func TestValidateAgainstSchemaNegative(t *testing.T) { t.Errorf("Error string :\n`%s`\ndoes not match expected\n`%s`", errString, expectedErrString) } } + +func TestValidateAgainstBraceBug(t *testing.T) { + schemaJSON, err := os.ReadFile("./testdata/test-values-invalidBraceBug.schema.json") + if err != nil { + t.Fatalf("Error reading YAML file: %s", err) + } + values := map[string]interface{}{ + "image": map[string]interface{}{ + "repository": "nginx", + "pullPolicy": "Always", + }, + } + + if err := ValidateAgainstSingleSchema(values, schemaJSON); err == nil { + t.Error("The invalid schema should cause the validation to fail") + } + +} diff --git a/pkg/chartutil/testdata/test-values-invalidBraceBug.schema.json b/pkg/chartutil/testdata/test-values-invalidBraceBug.schema.json new file mode 100644 index 000000000..12d8758d4 --- /dev/null +++ b/pkg/chartutil/testdata/test-values-invalidBraceBug.schema.json @@ -0,0 +1,25 @@ +{ + "type": "object", + "required": [ + "image" + ], + "properties": { + "image": { + "type": "object", + "required": [ + "repository", + "pullPolicy" + ], + "properties": { + "repository": { + "type": "string", + "pattern": "^([-_/.a-z0-9]+)$" + }, + "pullPolicy": { + "type": "string", + "pattern": "^(Always|Never|IfNotPresent)$" + } + }} + } + } +}