@@ -225,6 +225,24 @@ func TestValidatingPodProbeMarker(t *testing.T) {
225225 },
226226 expectErrList : 1 ,
227227 },
228+ {
229+ name : "test10, invalid ppm" ,
230+ getPpm : func () * appsv1alpha1.PodProbeMarker {
231+ ppm := ppmDemo .DeepCopy ()
232+ ppm .Spec .Probes [0 ].Name = ""
233+ return ppm
234+ },
235+ expectErrList : 1 ,
236+ },
237+ {
238+ name : "test11, invalid ppm" ,
239+ getPpm : func () * appsv1alpha1.PodProbeMarker {
240+ ppm := ppmDemo .DeepCopy ()
241+ ppm .Spec .Probes [0 ].ContainerName = ""
242+ return ppm
243+ },
244+ expectErrList : 1 ,
245+ },
228246 }
229247
230248 decoder := admission .NewDecoder (scheme )
@@ -246,11 +264,9 @@ func TestValidateHandler(t *testing.T) {
246264 {Exec : & corev1.ExecAction {Command : []string {"echo" }}},
247265 {TCPSocket : & corev1.TCPSocketAction {
248266 Port : intstr.IntOrString {Type : intstr .Int , IntVal : int32 (8000 )},
249- Host : "3.3.3.3" ,
250267 }},
251268 {TCPSocket : & corev1.TCPSocketAction {
252269 Port : intstr.IntOrString {Type : intstr .String , StrVal : "container-port" },
253- Host : "3.3.3.3" ,
254270 }},
255271 }
256272 for _ , h := range successCases {
@@ -264,11 +280,9 @@ func TestValidateHandler(t *testing.T) {
264280 {Exec : & corev1.ExecAction {Command : []string {}}},
265281 {TCPSocket : & corev1.TCPSocketAction {
266282 Port : intstr.IntOrString {Type : intstr .String , StrVal : "container-port-v2" },
267- Host : "3.3.3.3" ,
268283 }},
269284 {TCPSocket : & corev1.TCPSocketAction {
270285 Port : intstr.IntOrString {Type : intstr .Int , IntVal : - 1 },
271- Host : "3.3.3.3" ,
272286 }},
273287 {HTTPGet : & corev1.HTTPGetAction {Path : "" , Port : intstr .FromInt (0 ), Host : "" }},
274288 {HTTPGet : & corev1.HTTPGetAction {Path : "/foo" , Port : intstr .FromInt (65536 ), Host : "host" }},
@@ -277,7 +291,6 @@ func TestValidateHandler(t *testing.T) {
277291 Exec : & corev1.ExecAction {Command : []string {}},
278292 TCPSocket : & corev1.TCPSocketAction {
279293 Port : intstr.IntOrString {Type : intstr .String , StrVal : "container-port-v2" },
280- Host : "3.3.3.3" ,
281294 },
282295 },
283296 {
@@ -287,15 +300,13 @@ func TestValidateHandler(t *testing.T) {
287300 {
288301 TCPSocket : & corev1.TCPSocketAction {
289302 Port : intstr.IntOrString {Type : intstr .String , StrVal : "container-port-v2" },
290- Host : "3.3.3.3" ,
291303 },
292304 HTTPGet : & corev1.HTTPGetAction {Path : "" , Port : intstr .FromString ("" ), Host : "" },
293305 },
294306 {
295307 Exec : & corev1.ExecAction {Command : []string {}},
296308 TCPSocket : & corev1.TCPSocketAction {
297309 Port : intstr.IntOrString {Type : intstr .String , StrVal : "container-port-v2" },
298- Host : "3.3.3.3" ,
299310 },
300311 HTTPGet : & corev1.HTTPGetAction {Path : "" , Port : intstr .FromString ("" ), Host : "" },
301312 },
@@ -447,6 +458,16 @@ func TestValidateTCPSocketAction(t *testing.T) {
447458 },
448459 fldPath : field .NewPath ("field" ),
449460 },
461+ {
462+ tcp : & corev1.TCPSocketAction {
463+ Port : intstr.IntOrString {
464+ Type : intstr .Int ,
465+ IntVal : 80 ,
466+ },
467+ Host : "127.0.0.1" ,
468+ },
469+ fldPath : field .NewPath ("field" ),
470+ },
450471 }
451472 for _ , cs := range errorCases {
452473 if getErrs := validateTCPSocketAction (cs .tcp , cs .fldPath ); len (getErrs ) == 0 {
@@ -552,6 +573,16 @@ func TestValidateHTTPGetAction(t *testing.T) {
552573 },
553574 expectErrs : 1 ,
554575 },
576+ {
577+ name : "invalid host field" ,
578+ httpGet : & corev1.HTTPGetAction {
579+ Host : "127.0.0.1" ,
580+ Path : "/healthz" ,
581+ Port : intstr .FromInt (8080 ),
582+ Scheme : corev1 .URISchemeHTTP ,
583+ },
584+ expectErrs : 1 ,
585+ },
555586 }
556587
557588 for _ , tc := range testCases {
0 commit comments