add test case for error inside variables.
Kubernetes-commit: 3e777540fda8dda01bb72702b1e39675f21d2955
This commit is contained in:
parent
ab64beb117
commit
6f620d4d18
|
@ -502,6 +502,35 @@ func TestTypeCheck(t *testing.T) {
|
|||
toContain("found no matching overload for '_==_' applied to '(string, int)"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error in variables, not reported during type checking.",
|
||||
policy: &v1beta1.ValidatingAdmissionPolicy{Spec: v1beta1.ValidatingAdmissionPolicySpec{
|
||||
Variables: []v1beta1.Variable{
|
||||
{
|
||||
Name: "name",
|
||||
Expression: "object.foo == 'str'",
|
||||
},
|
||||
},
|
||||
Validations: []v1beta1.Validation{
|
||||
{
|
||||
Expression: "variables.name == object.foo", // foo is int64
|
||||
},
|
||||
},
|
||||
MatchConstraints: deploymentPolicy.Spec.MatchConstraints,
|
||||
},
|
||||
},
|
||||
schemaToReturn: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"foo": *spec.Int64Property(),
|
||||
},
|
||||
},
|
||||
},
|
||||
assertions: []assertionFunc{
|
||||
toHaveLengthOf(0),
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
typeChecker := buildTypeChecker(tc.schemaToReturn)
|
||||
|
|
Loading…
Reference in New Issue