Fix --disable-catch-all
This commit is contained in:
parent
bd74dce19c
commit
ca74960905
3 changed files with 60 additions and 4 deletions
|
|
@ -432,6 +432,36 @@ func newSingleIngressWithRules(name, path, host, ns, service string, port int, a
|
|||
return newSingleIngress(name, ns, annotations, spec)
|
||||
}
|
||||
|
||||
// NewSingleIngressWithBackendAndRules creates an ingress with both a default backend and a rule
|
||||
func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService string, defaultPort int, service string, port int, annotations *map[string]string) *extensions.Ingress {
|
||||
spec := extensions.IngressSpec{
|
||||
Backend: &extensions.IngressBackend{
|
||||
ServiceName: defaultService,
|
||||
ServicePort: intstr.FromInt(defaultPort),
|
||||
},
|
||||
Rules: []extensions.IngressRule{
|
||||
{
|
||||
Host: host,
|
||||
IngressRuleValue: extensions.IngressRuleValue{
|
||||
HTTP: &extensions.HTTPIngressRuleValue{
|
||||
Paths: []extensions.HTTPIngressPath{
|
||||
{
|
||||
Path: path,
|
||||
Backend: extensions.IngressBackend{
|
||||
ServiceName: service,
|
||||
ServicePort: intstr.FromInt(port),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return newSingleIngress(name, ns, annotations, spec)
|
||||
}
|
||||
|
||||
// NewSingleCatchAllIngress creates a simple ingress with a catch-all backend
|
||||
func NewSingleCatchAllIngress(name, ns, service string, port int, annotations *map[string]string) *extensions.Ingress {
|
||||
spec := extensions.IngressSpec{
|
||||
|
|
|
|||
|
|
@ -109,4 +109,24 @@ var _ = framework.IngressNginxDescribe("Disabled catch-all", func() {
|
|||
Expect(errs).To(BeNil())
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusNotFound))
|
||||
})
|
||||
|
||||
It("should allow Ingress with both a default backend and rules", func() {
|
||||
host := "foo"
|
||||
|
||||
ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.IngressController.Namespace, "http-svc", 80, "http-svc", 80, nil)
|
||||
f.EnsureIngress(ing)
|
||||
|
||||
f.WaitForNginxServer(host, func(cfg string) bool {
|
||||
return strings.Contains(cfg, "server_name foo")
|
||||
})
|
||||
|
||||
resp, _, errs := gorequest.New().
|
||||
Get(f.IngressController.HTTPURL).
|
||||
Set("Host", host).
|
||||
End()
|
||||
|
||||
Expect(errs).To(BeNil())
|
||||
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
|
||||
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue