mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Fix MakeRegexpArray handling empty strings
This commit is contained in:
parent
4eca18b6b0
commit
63860270e3
@ -61,6 +61,9 @@ type FilterServer struct {
|
|||||||
|
|
||||||
// MakeRegexpArray splits a comma separated list of regexps into an array of Regexp objects.
|
// MakeRegexpArray splits a comma separated list of regexps into an array of Regexp objects.
|
||||||
func MakeRegexpArray(str string) ([]*regexp.Regexp, error) {
|
func MakeRegexpArray(str string) ([]*regexp.Regexp, error) {
|
||||||
|
if str == "" {
|
||||||
|
return []*regexp.Regexp{}, nil
|
||||||
|
}
|
||||||
parts := strings.Split(str, ",")
|
parts := strings.Split(str, ",")
|
||||||
result := make([]*regexp.Regexp, len(parts))
|
result := make([]*regexp.Regexp, len(parts))
|
||||||
for ix := range parts {
|
for ix := range parts {
|
||||||
|
@ -275,6 +275,28 @@ func TestAccept(t *testing.T) {
|
|||||||
method: "PUT",
|
method: "PUT",
|
||||||
expectAccept: false,
|
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 {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user