@@ -394,38 +394,6 @@ func TestBindRouteToListeners(t *testing.T) {
394
394
return normalHTTPRoute
395
395
}
396
396
397
- normalHTTPRouteWithH2CBackendRef := & L7Route {
398
- RouteType : RouteTypeHTTP ,
399
- Source : hr ,
400
- Spec : L7RouteSpec {
401
- Hostnames : hr .Spec .Hostnames ,
402
- Rules : []RouteRule {
403
- {
404
- BackendRefs : []BackendRef {
405
- {
406
- Valid : true ,
407
- ServicePort : v1.ServicePort {
408
- AppProtocol : helpers .GetPointer (AppProtocolTypeH2C ),
409
- },
410
- },
411
- },
412
- },
413
- },
414
- },
415
- Valid : true ,
416
- Attachable : true ,
417
- ParentRefs : []ParentRef {
418
- {
419
- Idx : 0 ,
420
- Gateway : & ParentRefGateway {NamespacedName : client .ObjectKeyFromObject (gw )},
421
- SectionName : hr .Spec .ParentRefs [0 ].SectionName ,
422
- },
423
- },
424
- }
425
-
426
- invalidBackendRefH2c := * normalHTTPRouteWithH2CBackendRef
427
- invalidBackendRefH2c .Spec .Rules [0 ].BackendRefs [0 ].Valid = false
428
-
429
397
getLastNormalHTTPRoute := func () * L7Route {
430
398
return normalHTTPRoute
431
399
}
@@ -603,7 +571,6 @@ func TestBindRouteToListeners(t *testing.T) {
603
571
tests := []struct {
604
572
route * L7Route
605
573
gateway * Gateway
606
- expectedModifiedRoute * L7Route
607
574
name string
608
575
expectedGatewayListeners []* Listener
609
576
expectedSectionNameRefs []ParentRef
@@ -643,90 +610,6 @@ func TestBindRouteToListeners(t *testing.T) {
643
610
},
644
611
name : "normal case" ,
645
612
},
646
- {
647
- route : normalHTTPRouteWithH2CBackendRef ,
648
- gateway : & Gateway {
649
- Source : gw ,
650
- Valid : true ,
651
- Listeners : []* Listener {
652
- createListener ("listener-80-1" ),
653
- },
654
- EffectiveNginxProxy : & EffectiveNginxProxy {
655
- DisableHTTP2 : helpers .GetPointer (false ),
656
- },
657
- },
658
- expectedSectionNameRefs : []ParentRef {
659
- {
660
- Idx : 0 ,
661
- Gateway : & ParentRefGateway {NamespacedName : client .ObjectKeyFromObject (gw )},
662
- SectionName : hr .Spec .ParentRefs [0 ].SectionName ,
663
- Attachment : & ParentRefAttachmentStatus {
664
- Attached : true ,
665
- AcceptedHostnames : map [string ][]string {
666
- CreateGatewayListenerKey (
667
- client .ObjectKeyFromObject (gw ),
668
- "listener-80-1" ,
669
- ): {"foo.example.com" },
670
- },
671
- },
672
- },
673
- },
674
- expectedGatewayListeners : []* Listener {
675
- createModifiedListener ("listener-80-1" , func (l * Listener ) {
676
- l .Routes = map [RouteKey ]* L7Route {
677
- CreateRouteKey (hr ): normalHTTPRouteWithH2CBackendRef ,
678
- }
679
- }),
680
- },
681
- name : "httpRoute with h2c service port protocol in backend and h2c is enabled" ,
682
- },
683
- {
684
- route : normalHTTPRouteWithH2CBackendRef ,
685
- gateway : & Gateway {
686
- Source : gw ,
687
- Valid : true ,
688
- Listeners : []* Listener {
689
- createListener ("listener-80-1" ),
690
- },
691
- EffectiveNginxProxy : & EffectiveNginxProxy {
692
- DisableHTTP2 : helpers .GetPointer (true ),
693
- },
694
- },
695
- expectedSectionNameRefs : []ParentRef {
696
- {
697
- Idx : 0 ,
698
- Gateway : & ParentRefGateway {NamespacedName : client .ObjectKeyFromObject (gw )},
699
- SectionName : hr .Spec .ParentRefs [0 ].SectionName ,
700
- Attachment : & ParentRefAttachmentStatus {
701
- Attached : true ,
702
- AcceptedHostnames : map [string ][]string {
703
- CreateGatewayListenerKey (
704
- client .ObjectKeyFromObject (gw ),
705
- "listener-80-1" ,
706
- ): {"foo.example.com" },
707
- },
708
- },
709
- },
710
- },
711
- expectedGatewayListeners : []* Listener {
712
- createModifiedListener ("listener-80-1" , func (l * Listener ) {
713
- route := * normalHTTPRouteWithH2CBackendRef
714
- route .Conditions = []conditions.Condition {
715
- conditions .NewRouteBackendRefUnsupportedProtocol (
716
- "HTTP2 is disabled - cannot support appProtocol h2c on route type http" ),
717
- }
718
- l .Routes = map [RouteKey ]* L7Route {
719
- CreateRouteKey (hr ): & route ,
720
- }
721
- }),
722
- },
723
- expectedConditions : []conditions.Condition {
724
- conditions .NewRouteBackendRefUnsupportedProtocol (
725
- "HTTP2 is disabled - cannot support appProtocol h2c on route type http" ),
726
- },
727
- expectedModifiedRoute : & invalidBackendRefH2c ,
728
- name : "httpRoute with h2c service port protocol in backend and h2c is disabled" ,
729
- },
730
613
{
731
614
route : routeWithMissingSectionName ,
732
615
gateway : & Gateway {
@@ -1515,12 +1398,6 @@ func TestBindRouteToListeners(t *testing.T) {
1515
1398
g .Expect (test .route .ParentRefs ).To (Equal (test .expectedSectionNameRefs ))
1516
1399
g .Expect (helpers .Diff (test .gateway .Listeners , test .expectedGatewayListeners )).To (BeEmpty ())
1517
1400
g .Expect (helpers .Diff (test .route .Conditions , test .expectedConditions )).To (BeEmpty ())
1518
-
1519
- // in situations where bindRouteToListeners modifies the route spec, for instance marking a backendRef
1520
- // as invalid
1521
- if test .expectedModifiedRoute != nil {
1522
- g .Expect (helpers .Diff (test .route .Spec , test .expectedModifiedRoute .Spec )).To (BeEmpty ())
1523
- }
1524
1401
})
1525
1402
}
1526
1403
}
0 commit comments