@@ -354,8 +354,18 @@ func TestBuildRoute(t *testing.T) {
354
354
hrInvalidFilters := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , "/filter" )
355
355
addFilterToPath (hrInvalidFilters , "/filter" , invalidFilter )
356
356
357
- hrInvalidValidRules := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , invalidPath , "/filter" , "/" )
358
- addFilterToPath (hrInvalidValidRules , "/filter" , invalidFilter )
357
+ hrDroppedInvalidMatches := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , invalidPath , "/" )
358
+
359
+ hrDroppedInvalidMatchesAndInvalidFilters := createHTTPRoute (
360
+ "hr" ,
361
+ gatewayNsName .Name ,
362
+ "example.com" ,
363
+ invalidPath , "/filter" , "/" )
364
+ addFilterToPath (hrDroppedInvalidMatchesAndInvalidFilters , "/filter" , invalidFilter )
365
+
366
+ hrDroppedInvalidFilters := createHTTPRoute ("hr" , gatewayNsName .Name , "example.com" , "/filter" , "/" )
367
+ addFilterToPath (hrDroppedInvalidFilters , "/filter" , validFilter )
368
+ addFilterToPath (hrDroppedInvalidFilters , "/" , invalidFilter )
359
369
360
370
validatorInvalidFieldsInRule := & validationfakes.FakeHTTPFieldsValidator {
361
371
ValidatePathInMatchStub : func (path string ) error {
@@ -484,9 +494,9 @@ func TestBuildRoute(t *testing.T) {
484
494
},
485
495
{
486
496
validator : validatorInvalidFieldsInRule ,
487
- hr : hrInvalidValidRules ,
497
+ hr : hrDroppedInvalidMatches ,
488
498
expected : & Route {
489
- Source : hrInvalidValidRules ,
499
+ Source : hrDroppedInvalidMatches ,
490
500
Valid : true ,
491
501
ParentRefs : []ParentRef {
492
502
{
@@ -495,9 +505,39 @@ func TestBuildRoute(t *testing.T) {
495
505
},
496
506
},
497
507
Conditions : []conditions.Condition {
498
- staticConds .NewTODO (
499
- `Some rules are invalid: ` +
500
- `[spec.rules[0].matches[0].path.value: Invalid value: "/invalid": invalid path, ` +
508
+ staticConds .NewRoutePartiallyInvalid (
509
+ `spec.rules[0].matches[0].path.value: Invalid value: "/invalid": invalid path` ,
510
+ ),
511
+ },
512
+ Rules : []Rule {
513
+ {
514
+ ValidMatches : false ,
515
+ ValidFilters : true ,
516
+ },
517
+ {
518
+ ValidMatches : true ,
519
+ ValidFilters : true ,
520
+ },
521
+ },
522
+ },
523
+ name : "dropped invalid rule with invalid matches" ,
524
+ },
525
+
526
+ {
527
+ validator : validatorInvalidFieldsInRule ,
528
+ hr : hrDroppedInvalidMatchesAndInvalidFilters ,
529
+ expected : & Route {
530
+ Source : hrDroppedInvalidMatchesAndInvalidFilters ,
531
+ Valid : true ,
532
+ ParentRefs : []ParentRef {
533
+ {
534
+ Idx : 0 ,
535
+ Gateway : gatewayNsName ,
536
+ },
537
+ },
538
+ Conditions : []conditions.Condition {
539
+ staticConds .NewRoutePartiallyInvalid (
540
+ `[spec.rules[0].matches[0].path.value: Invalid value: "/invalid": invalid path, ` +
501
541
`spec.rules[1].filters[0].requestRedirect.hostname: Invalid value: ` +
502
542
`"invalid.example.com": invalid hostname]` ,
503
543
),
@@ -517,7 +557,38 @@ func TestBuildRoute(t *testing.T) {
517
557
},
518
558
},
519
559
},
520
- name : "invalid with invalid and valid rules" ,
560
+ name : "dropped invalid rule with invalid filters and invalid rule with invalid matches" ,
561
+ },
562
+ {
563
+ validator : validatorInvalidFieldsInRule ,
564
+ hr : hrDroppedInvalidFilters ,
565
+ expected : & Route {
566
+ Source : hrDroppedInvalidFilters ,
567
+ Valid : true ,
568
+ ParentRefs : []ParentRef {
569
+ {
570
+ Idx : 0 ,
571
+ Gateway : gatewayNsName ,
572
+ },
573
+ },
574
+ Conditions : []conditions.Condition {
575
+ staticConds .NewRoutePartiallyInvalid (
576
+ `spec.rules[1].filters[0].requestRedirect.hostname: Invalid value: ` +
577
+ `"invalid.example.com": invalid hostname` ,
578
+ ),
579
+ },
580
+ Rules : []Rule {
581
+ {
582
+ ValidMatches : true ,
583
+ ValidFilters : true ,
584
+ },
585
+ {
586
+ ValidMatches : true ,
587
+ ValidFilters : false ,
588
+ },
589
+ },
590
+ },
591
+ name : "dropped invalid rule with invalid filters" ,
521
592
},
522
593
}
523
594
0 commit comments