@@ -35,6 +35,7 @@ const (
3535 TestIngressStateFilePath = "test-ingress-state.yaml"
3636 TestIngressStateWithPortNameFilePath = "test-ingress-state_withportname.yaml"
3737 TestIngressStateWithNamedClassesFilePath = "test-ingress-state_withnamedclasses.yaml"
38+ TestSslTerminationAtLb = "test-ssl-termination-lb.yaml"
3839)
3940
4041func setUp (ctx context.Context , ingressClassList * networkingv1.IngressClassList , ingressList * networkingv1.IngressList , testService * v1.ServiceList ) (networkinglisters.IngressClassLister , networkinglisters.IngressLister , corelisters.ServiceLister ) {
@@ -418,3 +419,33 @@ func TestValidateProtocolConfigWithConflict(t *testing.T) {
418419
419420 Expect (err .Error ()).Should (ContainSubstring (fmt .Sprintf (ProtocolConflictMessage , 900 )))
420421}
422+
423+ func TestSslTerminationAtLB (t * testing.T ) {
424+ RegisterTestingT (t )
425+ ctx , cancel := context .WithCancel (context .Background ())
426+ defer cancel ()
427+
428+ ingressClassList := testutil .GetIngressClassList ()
429+
430+ ingressList := testutil .ReadResourceAsIngressList (TestSslTerminationAtLb )
431+
432+ certificateId := "certificateId"
433+ ingressList .Items [0 ].Spec .TLS = []networkingv1.IngressTLS {}
434+ ingressList .Items [0 ].Annotations = map [string ]string {util .IngressListenerTlsCertificateAnnotation : certificateId }
435+
436+ testService := testutil .GetServiceListResource ("default" , "tls-test" , 443 )
437+ ingressClassLister , ingressLister , serviceLister := setUp (ctx , ingressClassList , ingressList , testService )
438+
439+ stateStore := NewStateStore (ingressClassLister , ingressLister , serviceLister , nil )
440+ err := stateStore .BuildState (& ingressClassList .Items [0 ])
441+ Expect (err ).NotTo (HaveOccurred ())
442+
443+ bsName := util .GenerateBackendSetName ("default" , "tls-test" , 443 )
444+ bsTlsConfig := stateStore .IngressGroupState .BackendSetTLSConfigMap [bsName ]
445+ Expect (bsTlsConfig .Artifact ).Should (Equal ("" ))
446+ Expect (bsTlsConfig .Type ).Should (Equal ("" ))
447+
448+ lstTlsConfig := stateStore .IngressGroupState .ListenerTLSConfigMap [443 ]
449+ Expect (lstTlsConfig .Artifact ).Should (Equal (certificateId ))
450+ Expect (lstTlsConfig .Type ).Should (Equal (ArtifactTypeCertificate ))
451+ }
0 commit comments