@@ -568,7 +568,9 @@ func TestMutate(t *testing.T) {
568568 assert .Check (t , resp .Allowed , "response not allowed for unknown object type" )
569569 assert .Check (t , len (resp .Patch ) > 0 , "empty patch for deployment" )
570570 annotations := annotationsFromDeployment (t , resp .Patch )
571- assert .Equal (t , annotations [common .UserInfoAnnotation ].(string ), "{\" user\" :\" testExtUser\" }" )
571+ annotationValue , ok := annotations [common .UserInfoAnnotation ].(string )
572+ assert .Assert (t , ok , "UserInfoAnnotation value is not a string" )
573+ assert .Equal (t , annotationValue , "{\" user\" :\" testExtUser\" }" )
572574
573575 // deployment - annotation is not set, bypassAuth is enabled
574576 ac = prepareController (t , "" , "" , "^kube-system$,^bypass$" , "" , "^nolabel$" , true , true )
@@ -838,7 +840,9 @@ func schedulerName(t *testing.T, patch []byte) string {
838840 ops := parsePatch (t , patch )
839841 for _ , op := range ops {
840842 if op .Path == "/spec/schedulerName" {
841- return op .Value .(string )
843+ val , ok := op .Value .(string )
844+ assert .Assert (t , ok , "scheduler name value is not a string" )
845+ return val
842846 }
843847 }
844848 return ""
@@ -848,7 +852,9 @@ func labels(t *testing.T, patch []byte) map[string]interface{} {
848852 ops := parsePatch (t , patch )
849853 for _ , op := range ops {
850854 if op .Path == "/metadata/labels" {
851- return op .Value .(map [string ]interface {})
855+ val , ok := op .Value .(map [string ]interface {})
856+ assert .Assert (t , ok , "labels value is not a map" )
857+ return val
852858 }
853859 }
854860 return make (map [string ]interface {})
@@ -858,7 +864,9 @@ func annotationsFromDeployment(t *testing.T, patch []byte) map[string]interface{
858864 ops := parsePatch (t , patch )
859865 for _ , op := range ops {
860866 if op .Path == "/spec/template/metadata/annotations" {
861- return op .Value .(map [string ]interface {})
867+ val , ok := op .Value .(map [string ]interface {})
868+ assert .Assert (t , ok , "annotations value is not a map" )
869+ return val
862870 }
863871 }
864872 return make (map [string ]interface {})
0 commit comments