@@ -48,14 +48,7 @@ func buildIngress() *networking.Ingress {
48
48
Namespace : api .NamespaceDefault ,
49
49
},
50
50
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 ,
59
52
Rules : []networking.IngressRule {
60
53
{
61
54
Host : "foo.bar.com" ,
@@ -163,15 +156,38 @@ func TestAnnotations(t *testing.T) {
163
156
if u .ValidationDepth != 2 {
164
157
t .Errorf ("expected %v but got %v" , 2 , u .ValidationDepth )
165
158
}
166
- if u .ErrorPage != "ok.com/error" {
167
- t .Errorf ("expected %v but got %v" , "ok.com/error" , u .ErrorPage )
168
- }
169
159
if u .PassCertToUpstream != true {
170
160
t .Errorf ("expected %v but got %v" , true , u .PassCertToUpstream )
171
161
}
172
162
if u .MatchCN != "CN=(hello-app|ok|goodbye)" {
173
163
t .Errorf ("expected %v but got %v" , "CN=(hello-app|ok|goodbye)" , u .MatchCN )
174
164
}
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
+ }
175
191
}
176
192
177
193
func TestInvalidAnnotations (t * testing.T ) {
0 commit comments