Skip to content

Commit 56a8dd6

Browse files
committed
Add a test
1 parent 3f711d0 commit 56a8dd6

File tree

1 file changed

+105
-1
lines changed

1 file changed

+105
-1
lines changed

pkg/ingress/model_builder_test.go

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package ingress
33
import (
44
"context"
55
"encoding/json"
6-
"sigs.k8s.io/aws-load-balancer-controller/pkg/shared_constants"
76
"testing"
87
"time"
98

9+
"sigs.k8s.io/aws-load-balancer-controller/pkg/shared_constants"
10+
1011
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
1112
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
1213

@@ -2434,6 +2435,109 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
24342435
"80:3": null
24352436
}
24362437
}
2438+
}`,
2439+
},
2440+
{
2441+
name: "Ingress - wafv2AclArn in IngressClassParams",
2442+
env: env{
2443+
svcs: []*corev1.Service{ns_1_svc_1, ns_1_svc_2, ns_1_svc_3},
2444+
},
2445+
fields: fields{
2446+
resolveViaDiscoveryCalls: []resolveViaDiscoveryCall{resolveViaDiscoveryCallForInternalLB},
2447+
listLoadBalancersCalls: []listLoadBalancersCall{listLoadBalancerCallForEmptyLB},
2448+
enableBackendSG: true,
2449+
},
2450+
args: args{
2451+
ingGroup: Group{
2452+
ID: GroupID{Namespace: "ns-1", Name: "ing-1"},
2453+
Members: []ClassifiedIngress{
2454+
{
2455+
IngClassConfig: ClassConfiguration{
2456+
IngClassParams: &v1beta1.IngressClassParams{
2457+
Spec: v1beta1.IngressClassParamsSpec{
2458+
WAFv2ACLArn: "alb.ingress.kubernetes.io/wafv2-acl-arn: arn:aws:wafv2:us-west-2:xxxxx:regional/webacl/xxxxxxx/3ab78708-85b0-49d3-b4e1-7a9615a6613b",
2459+
},
2460+
},
2461+
},
2462+
Ing: &networking.Ingress{ObjectMeta: metav1.ObjectMeta{
2463+
Namespace: "ns-1",
2464+
Name: "ing-1",
2465+
},
2466+
Spec: networking.IngressSpec{
2467+
Rules: []networking.IngressRule{
2468+
{
2469+
Host: "app-1.example.com",
2470+
IngressRuleValue: networking.IngressRuleValue{
2471+
HTTP: &networking.HTTPIngressRuleValue{
2472+
Paths: []networking.HTTPIngressPath{
2473+
{
2474+
Path: "/svc-1",
2475+
Backend: networking.IngressBackend{
2476+
Service: &networking.IngressServiceBackend{
2477+
Name: ns_1_svc_1.Name,
2478+
Port: networking.ServiceBackendPort{
2479+
Name: "http",
2480+
},
2481+
},
2482+
},
2483+
},
2484+
{
2485+
Path: "/svc-2",
2486+
Backend: networking.IngressBackend{
2487+
Service: &networking.IngressServiceBackend{
2488+
Name: ns_1_svc_2.Name,
2489+
Port: networking.ServiceBackendPort{
2490+
Name: "http",
2491+
},
2492+
},
2493+
},
2494+
},
2495+
},
2496+
},
2497+
},
2498+
},
2499+
{
2500+
Host: "app-2.example.com",
2501+
IngressRuleValue: networking.IngressRuleValue{
2502+
HTTP: &networking.HTTPIngressRuleValue{
2503+
Paths: []networking.HTTPIngressPath{
2504+
{
2505+
Path: "/svc-3",
2506+
Backend: networking.IngressBackend{
2507+
Service: &networking.IngressServiceBackend{
2508+
Name: ns_1_svc_3.Name,
2509+
Port: networking.ServiceBackendPort{
2510+
Name: "https",
2511+
},
2512+
},
2513+
},
2514+
},
2515+
},
2516+
},
2517+
},
2518+
},
2519+
},
2520+
},
2521+
},
2522+
},
2523+
},
2524+
},
2525+
},
2526+
wantStackPatch: `
2527+
{
2528+
"id":"ns-1/ing-1",
2529+
"resources":{
2530+
"AWS::WAFv2::WebACLAssociation":{
2531+
"LoadBalancer":{
2532+
"spec":{
2533+
"resourceARN":{
2534+
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::LoadBalancer/LoadBalancer/status/loadBalancerARN"
2535+
},
2536+
"webACLARN":"alb.ingress.kubernetes.io/wafv2-acl-arn: arn:aws:wafv2:us-west-2:xxxxx:regional/webacl/xxxxxxx/3ab78708-85b0-49d3-b4e1-7a9615a6613b"
2537+
}
2538+
}
2539+
}
2540+
}
24372541
}`,
24382542
},
24392543
{

0 commit comments

Comments
 (0)