Skip to content

Commit 576c96b

Browse files
committed
feature: add test
1 parent 5be47e0 commit 576c96b

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

pkg/ingress/model_builder_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4913,6 +4913,65 @@ func Test_defaultModelBuildTask_buildSSLRedirectConfig(t *testing.T) {
49134913
want: nil,
49144914
wantErr: nil,
49154915
},
4916+
{
4917+
name: "single Ingress with ssl-redirect annotation",
4918+
fields: fields{
4919+
ingGroup: Group{
4920+
ID: GroupID{Namespace: "ns-1", Name: "ing-1"},
4921+
Members: []ClassifiedIngress{
4922+
{
4923+
Ing: &networking.Ingress{ObjectMeta: metav1.ObjectMeta{
4924+
Namespace: "ns-1",
4925+
Name: "ing-1",
4926+
Annotations: map[string]string{
4927+
"alb.ingress.kubernetes.io/ssl-redirect": "443",
4928+
},
4929+
},
4930+
Spec: networking.IngressSpec{
4931+
Rules: []networking.IngressRule{
4932+
{
4933+
Host: "app-1.example.com",
4934+
IngressRuleValue: networking.IngressRuleValue{
4935+
HTTP: &networking.HTTPIngressRuleValue{
4936+
Paths: []networking.HTTPIngressPath{
4937+
{
4938+
Path: "/svc-1",
4939+
Backend: networking.IngressBackend{
4940+
Service: &networking.IngressServiceBackend{
4941+
Name: "svc-1",
4942+
Port: networking.ServiceBackendPort{
4943+
Name: "http",
4944+
},
4945+
},
4946+
},
4947+
},
4948+
},
4949+
},
4950+
},
4951+
},
4952+
},
4953+
},
4954+
},
4955+
},
4956+
},
4957+
},
4958+
},
4959+
args: args{
4960+
listenPortConfigByPort: map[int32]listenPortConfig{
4961+
80: {
4962+
protocol: elbv2model.ProtocolHTTP,
4963+
},
4964+
443: {
4965+
protocol: elbv2model.ProtocolHTTPS,
4966+
},
4967+
},
4968+
},
4969+
want: &SSLRedirectConfig{
4970+
SSLPort: 443,
4971+
StatusCode: "HTTP_301",
4972+
},
4973+
wantErr: nil,
4974+
},
49164975
{
49174976
name: "single Ingress with IngressClassParam for ssl-redirect",
49184977
fields: fields{

0 commit comments

Comments
 (0)