@@ -48,14 +48,7 @@ func buildIngress() *networking.Ingress {
4848 Namespace : api .NamespaceDefault ,
4949 },
5050 Spec : networking.IngressSpec {
51- DefaultBackend : & networking.IngressBackend {
52- Service : & networking.IngressServiceBackend {
53- Name : "default-backend" ,
54- Port : networking.ServiceBackendPort {
55- Number : 80 ,
56- },
57- },
58- },
51+ DefaultBackend : & defaultBackend ,
5952 Rules : []networking.IngressRule {
6053 {
6154 Host : "foo.bar.com" ,
@@ -163,15 +156,38 @@ func TestAnnotations(t *testing.T) {
163156 if u .ValidationDepth != 2 {
164157 t .Errorf ("expected %v but got %v" , 2 , u .ValidationDepth )
165158 }
166- if u .ErrorPage != "ok.com/error" {
167- t .Errorf ("expected %v but got %v" , "ok.com/error" , u .ErrorPage )
168- }
169159 if u .PassCertToUpstream != true {
170160 t .Errorf ("expected %v but got %v" , true , u .PassCertToUpstream )
171161 }
172162 if u .MatchCN != "CN=(hello-app|ok|goodbye)" {
173163 t .Errorf ("expected %v but got %v" , "CN=(hello-app|ok|goodbye)" , u .MatchCN )
174164 }
165+
166+ for _ , tc := range []struct {
167+ name string
168+ errorPage string
169+ want string
170+ }{
171+ {"url redirect" , "ok.com/error" , "ok.com/error" },
172+ {"named redirect numeric" , "@401" , "@401" },
173+ {"named redirect alphanumeric with underscores" , "@four_oh_one" , "@four_oh_one" },
174+ } {
175+ t .Run (tc .name , func (t * testing.T ) {
176+ data [parser .GetAnnotationWithPrefix (annotationAuthTLSErrorPage )] = tc .errorPage
177+ ing .SetAnnotations (data )
178+ i , err := NewParser (fakeSecret ).Parse (ing )
179+ if err != nil {
180+ t .Errorf ("Unexpected error with ingress: %v" , err )
181+ }
182+ u , ok := i .(* Config )
183+ if ! ok {
184+ t .Errorf ("expected *Config but got %v" , u )
185+ }
186+ if u .ErrorPage != tc .want {
187+ t .Errorf ("expected %v but got %v" , tc .want , u .ErrorPage )
188+ }
189+ })
190+ }
175191}
176192
177193func TestInvalidAnnotations (t * testing.T ) {
0 commit comments