Fix MakeRegexpArray handling empty strings
Kubernetes-commit: 63860270e303476cdef282c6bb071c70952b4fbb
This commit is contained in:
		
							parent
							
								
									b3f4363d68
								
							
						
					
					
						commit
						1bc7e4aa19
					
				|  | @ -61,6 +61,9 @@ type FilterServer struct { | |||
| 
 | ||||
| // MakeRegexpArray splits a comma separated list of regexps into an array of Regexp objects.
 | ||||
| func MakeRegexpArray(str string) ([]*regexp.Regexp, error) { | ||||
| 	if str == "" { | ||||
| 		return []*regexp.Regexp{}, nil | ||||
| 	} | ||||
| 	parts := strings.Split(str, ",") | ||||
| 	result := make([]*regexp.Regexp, len(parts)) | ||||
| 	for ix := range parts { | ||||
|  |  | |||
|  | @ -275,6 +275,28 @@ func TestAccept(t *testing.T) { | |||
| 			method:        "PUT", | ||||
| 			expectAccept:  false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:          "test23", | ||||
| 			acceptPaths:   DefaultPathAcceptRE, | ||||
| 			rejectPaths:   DefaultPathRejectRE, | ||||
| 			acceptHosts:   DefaultHostAcceptRE, | ||||
| 			rejectMethods: DefaultMethodRejectRE, | ||||
| 			path:          "/api/v1/namespaces/default/pods/somepod/exec", | ||||
| 			host:          "localhost", | ||||
| 			method:        "POST", | ||||
| 			expectAccept:  false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:          "test24", | ||||
| 			acceptPaths:   DefaultPathAcceptRE, | ||||
| 			rejectPaths:   "", | ||||
| 			acceptHosts:   DefaultHostAcceptRE, | ||||
| 			rejectMethods: DefaultMethodRejectRE, | ||||
| 			path:          "/api/v1/namespaces/default/pods/somepod/exec", | ||||
| 			host:          "localhost", | ||||
| 			method:        "POST", | ||||
| 			expectAccept:  true, | ||||
| 		}, | ||||
| 	} | ||||
| 	for _, tt := range tests { | ||||
| 		t.Run(tt.name, func(t *testing.T) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue