Improve `http_status` validation
This commit is contained in:
parent
2714d10d62
commit
b5a30dd3e5
|
@ -3,6 +3,7 @@ package ingress
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
@ -260,7 +261,7 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
|
|||
if err != nil {
|
||||
return Ingress{}, errors.Wrap(err, "invalid HTTP status code")
|
||||
}
|
||||
if statusCode < 100 || statusCode > 999 {
|
||||
if http.StatusText(statusCode) == "" {
|
||||
return Ingress{}, fmt.Errorf("invalid HTTP status code: %d", statusCode)
|
||||
}
|
||||
srv := newStatusCode(statusCode)
|
||||
|
|
|
@ -247,10 +247,18 @@ ingress:
|
|||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid HTTP status code",
|
||||
name: "Invalid HTTP status code(8080)",
|
||||
args: args{rawYAML: `
|
||||
ingress:
|
||||
- service: http_status:8080
|
||||
`},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid HTTP status code(666)",
|
||||
args: args{rawYAML: `
|
||||
ingress:
|
||||
- service: http_status:666
|
||||
`},
|
||||
wantErr: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue