Skip to content

Commit f58aecc

Browse files
committed
update tests
1 parent 6f86442 commit f58aecc

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

internal/mode/static/state/graph/route_common.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,11 @@ func isRouteTypeAllowedByListener(listener *Listener, routeType RouteType) bool
550550
return false
551551
}
552552

553-
if listener.Source.Protocol == v1.HTTPProtocolType || listener.Source.Protocol == v1.HTTPSProtocolType {
553+
switch listener.Source.Protocol {
554+
case v1.HTTPProtocolType, v1.HTTPSProtocolType:
554555
return routeType == RouteTypeHTTP || routeType == RouteTypeGRPC
555556
}
557+
556558
return false
557559
}
558560

internal/mode/static/state/graph/route_common_test.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,30 @@ func TestAllowedRouteType(t *testing.T) {
17621762
},
17631763
expResult: true,
17641764
},
1765+
{
1766+
name: "listener protocol set to tcp, grpcRoute is not allowed",
1767+
routeType: RouteTypeGRPC,
1768+
listener: &Listener{
1769+
Source: gatewayv1.Listener{
1770+
Protocol: gatewayv1.TCPProtocolType,
1771+
},
1772+
},
1773+
expResult: false,
1774+
},
1775+
{
1776+
name: "grpcRoute with listener allowedRoutes set to grpcRoute is allowed",
1777+
routeType: RouteTypeGRPC,
1778+
listener: &Listener{
1779+
Source: gatewayv1.Listener{
1780+
AllowedRoutes: &gatewayv1.AllowedRoutes{
1781+
Kinds: []gatewayv1.RouteGroupKind{
1782+
{Kind: kinds.GRPCRoute},
1783+
},
1784+
},
1785+
},
1786+
},
1787+
expResult: true,
1788+
},
17651789
{
17661790
name: "grpcRoute with listener allowedRoutes set to httpRoute is not allowed",
17671791
routeType: RouteTypeGRPC,
@@ -1791,18 +1815,18 @@ func TestAllowedRouteType(t *testing.T) {
17911815
expResult: false,
17921816
},
17931817
{
1794-
name: "grpcRoute with listener allowedRoutes set to grpcRoute is allowed",
1818+
name: "grpcRoute with listener allowedRoutes set to testRoute is not allowed",
17951819
routeType: RouteTypeGRPC,
17961820
listener: &Listener{
17971821
Source: gatewayv1.Listener{
17981822
AllowedRoutes: &gatewayv1.AllowedRoutes{
17991823
Kinds: []gatewayv1.RouteGroupKind{
1800-
{Kind: kinds.GRPCRoute},
1824+
{Kind: gatewayv1.Kind("testRoute")},
18011825
},
18021826
},
18031827
},
18041828
},
1805-
expResult: true,
1829+
expResult: false,
18061830
},
18071831
}
18081832

0 commit comments

Comments
 (0)