MCPcopy
hub / github.com/kubernetes/kubectl / TestParamVerifyingSchema

Function TestParamVerifyingSchema

pkg/validation/schema_test.go:161–262  ·  view source on GitHub ↗

TestParamVerifyingSchema tests that client-side schema validation should be bypassed (and therefore validation succeeds) in all cases except when the field validation is "Strict" and server-side validation is unsupported.

(t *testing.T)

Source from the content-addressed store, hash-verified

159// except when the field validation is "Strict" and server-side validation is
160// unsupported.
161func TestParamVerifyingSchema(t *testing.T) {
162 bytes := []byte(`
163{
164 "kind": "Pod",
165 "apiVersion": "v1",
166 "metadata": {
167 "name": "name",
168 "labels": {
169 "name": "redis-master"
170 }
171 },
172 "spec": {
173 "containers": [
174 {
175 "name": "master",
176 "image": "gcr.io/fake_project/fake_image:fake_tag",
177 "args": "this is a bad command"
178 }
179 ]
180 }
181}
182`)
183 supportedVerifier := &mockVerifier{true}
184 unsupportedVerifier := &mockVerifier{false}
185 tests := []struct {
186 name string
187 supported bool
188 schema Schema
189 verifier resource.Verifier
190 directive string
191 shouldPass bool
192 }{
193 {
194 name: "supported, strict",
195 schema: NullSchema{},
196 verifier: supportedVerifier,
197 directive: "Strict",
198 shouldPass: true,
199 },
200 {
201 name: "supported, warn",
202 schema: NullSchema{},
203 verifier: supportedVerifier,
204 directive: "Warn",
205 shouldPass: true,
206 },
207 {
208 name: "unsupported, strict",
209 schema: NullSchema{},
210 verifier: unsupportedVerifier,
211 directive: "Strict",
212 shouldPass: true,
213 },
214 {
215 name: "unsupported, warn",
216 schema: NullSchema{},
217 verifier: unsupportedVerifier,
218 directive: "Warn",

Callers

nothing calls this directly

Calls 3

NewParamVerifyingSchemaFunction · 0.85
ValidateBytesMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…