@@ -42,7 +42,7 @@ func createGRPCHeadersMatch(headerType, headerName, headerValue string) v1.GRPCR
4242 {
4343 Headers : []v1.GRPCHeaderMatch {
4444 {
45- Type : (* v1 .HeaderMatchType )(& headerType ),
45+ Type : (* v1 .GRPCHeaderMatchType )(& headerType ),
4646 Name : v1 .GRPCHeaderName (headerName ),
4747 Value : headerValue ,
4848 },
@@ -242,6 +242,19 @@ func TestBuildGRPCRoute(t *testing.T) {
242242 methodMatchNilType := createGRPCMethodMatch ("myService" , "myMethod" , "nilType" )
243243 headersMatchInvalid := createGRPCHeadersMatch ("" , "MyHeader" , "SomeValue" )
244244
245+ headersMatchEmptyType := v1.GRPCRouteRule {
246+ Matches : []v1.GRPCRouteMatch {
247+ {
248+ Headers : []v1.GRPCHeaderMatch {
249+ {
250+ Name : v1 .GRPCHeaderName ("MyHeader" ),
251+ Value : "SomeValue" ,
252+ },
253+ },
254+ },
255+ },
256+ }
257+
245258 grBoth := createGRPCRoute (
246259 "gr-1" ,
247260 gatewayNsName .Name ,
@@ -290,12 +303,19 @@ func TestBuildGRPCRoute(t *testing.T) {
290303 "example.com" ,
291304 []v1.GRPCRouteRule {methodMatchNilType },
292305 )
293- grInvalidHeadersEmptyType := createGRPCRoute (
306+ grInvalidHeadersInvalidType := createGRPCRoute (
294307 "gr-1" ,
295308 gatewayNsName .Name ,
296309 "example.com" ,
297310 []v1.GRPCRouteRule {headersMatchInvalid },
298311 )
312+
313+ grInvalidHeadersEmptyType := createGRPCRoute (
314+ "gr-1" ,
315+ gatewayNsName .Name ,
316+ "example.com" ,
317+ []v1.GRPCRouteRule {headersMatchEmptyType },
318+ )
299319 grOneInvalid := createGRPCRoute (
300320 "gr-1" ,
301321 gatewayNsName .Name ,
@@ -736,6 +756,44 @@ func TestBuildGRPCRoute(t *testing.T) {
736756 },
737757 name : "invalid headers and valid method" ,
738758 },
759+ {
760+ validator : createAllValidValidator (),
761+ gr : grInvalidHeadersInvalidType ,
762+ expected : & L7Route {
763+ Source : grInvalidHeadersInvalidType ,
764+ RouteType : RouteTypeGRPC ,
765+ Valid : false ,
766+ Attachable : true ,
767+ ParentRefs : []ParentRef {
768+ {
769+ Idx : 0 ,
770+ Gateway : gatewayNsName ,
771+ SectionName : grInvalidHeadersInvalidType .Spec .ParentRefs [0 ].SectionName ,
772+ },
773+ },
774+ Conditions : []conditions.Condition {
775+ staticConds .NewRouteUnsupportedValue (
776+ `All rules are invalid: spec.rules[0].matches[0].headers[0].type: ` +
777+ `Unsupported value: "": supported values: "Exact"` ,
778+ ),
779+ },
780+ Spec : L7RouteSpec {
781+ Hostnames : grInvalidHeadersInvalidType .Spec .Hostnames ,
782+ Rules : []RouteRule {
783+ {
784+ ValidMatches : false ,
785+ Filters : RouteRuleFilters {
786+ Valid : true ,
787+ Filters : []Filter {},
788+ },
789+ Matches : convertGRPCMatches (grInvalidHeadersInvalidType .Spec .Rules [0 ].Matches ),
790+ RouteBackendRefs : []RouteBackendRef {},
791+ },
792+ },
793+ },
794+ },
795+ name : "invalid headers with invalid type" ,
796+ },
739797 {
740798 validator : createAllValidValidator (),
741799 gr : grInvalidHeadersEmptyType ,
@@ -754,7 +812,7 @@ func TestBuildGRPCRoute(t *testing.T) {
754812 Conditions : []conditions.Condition {
755813 staticConds .NewRouteUnsupportedValue (
756814 `All rules are invalid: spec.rules[0].matches[0].headers[0].type: ` +
757- `Unsupported value: "": supported values: "Exact" ` ,
815+ `Required value: cannot be empty ` ,
758816 ),
759817 },
760818 Spec : L7RouteSpec {
@@ -772,7 +830,7 @@ func TestBuildGRPCRoute(t *testing.T) {
772830 },
773831 },
774832 },
775- name : "invalid headers with empty type" ,
833+ name : "invalid headers with no header type specified " ,
776834 },
777835 {
778836 validator : createAllValidValidator (),
0 commit comments