mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
add e2e test for enforcing enums in schema.
This commit is contained in:
parent
a8175212aa
commit
52d8b53663
@ -87,6 +87,12 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Privileged:ClusterAdmin]", fu
|
|||||||
framework.Failf("failed to delete valid CR: %v", err)
|
framework.Failf("failed to delete valid CR: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ginkgo.By("client-side validation (kubectl create and apply) rejects request with value outside defined enum values")
|
||||||
|
badEnumValueCR := fmt.Sprintf(`{%s,"spec":{"bars":[{"name":"test-bar", "feeling":"NonExistentValue"}]}}`, meta)
|
||||||
|
if _, err := framework.RunKubectlInput(f.Namespace.Name, badEnumValueCR, ns, "create", "-f", "-"); err == nil || !strings.Contains(err.Error(), `Unsupported value: "NonExistentValue"`) {
|
||||||
|
framework.Failf("unexpected no error when creating CR with unknown enum value: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
ginkgo.By("client-side validation (kubectl create and apply) rejects request with unknown properties when disallowed by the schema")
|
ginkgo.By("client-side validation (kubectl create and apply) rejects request with unknown properties when disallowed by the schema")
|
||||||
unknownCR := fmt.Sprintf(`{%s,"spec":{"foo":true}}`, meta)
|
unknownCR := fmt.Sprintf(`{%s,"spec":{"foo":true}}`, meta)
|
||||||
if _, err := framework.RunKubectlInput(f.Namespace.Name, unknownCR, ns, "create", "-f", "-"); err == nil || !strings.Contains(err.Error(), `unknown field "foo"`) {
|
if _, err := framework.RunKubectlInput(f.Namespace.Name, unknownCR, ns, "create", "-f", "-"); err == nil || !strings.Contains(err.Error(), `unknown field "foo"`) {
|
||||||
@ -741,6 +747,12 @@ properties:
|
|||||||
age:
|
age:
|
||||||
description: Age of Bar.
|
description: Age of Bar.
|
||||||
type: string
|
type: string
|
||||||
|
feeling:
|
||||||
|
description: Whether Bar is feeling great.
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- Great
|
||||||
|
- Down
|
||||||
bazs:
|
bazs:
|
||||||
description: List of Bazs.
|
description: List of Bazs.
|
||||||
items:
|
items:
|
||||||
|
Loading…
Reference in New Issue
Block a user